Use compat::getSubExprAsWritten; clean up
Change-Id: I8f984c3b3833437f6b4d65ab99da608a6868ff74
This commit is contained in:
@@ -859,30 +859,31 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ExplicitCastExpr const * sub = dyn_cast<ExplicitCastExpr>(
|
if (auto const sub = dyn_cast<ExplicitCastExpr>(
|
||||||
expr->getSubExpr()->IgnoreParenImpCasts());
|
compat::getSubExprAsWritten(expr)))
|
||||||
if (sub != nullptr
|
{
|
||||||
&& (sub->getSubExpr()->IgnoreParenImpCasts()->getType().IgnoreParens()
|
auto const subsub = compat::getSubExprAsWritten(sub);
|
||||||
== expr->getType().IgnoreParens())
|
if (subsub->getType().IgnoreParens() == expr->getType().IgnoreParens()
|
||||||
&& isBool(sub->getSubExpr()->IgnoreParenImpCasts()))
|
&& isBool(subsub))
|
||||||
{
|
{
|
||||||
// Ignore "normalizing cast" bool(b) from sal_Bool b to bool, then
|
// Ignore "normalizing cast" bool(b) from sal_Bool b to bool, then
|
||||||
// implicitly cast back again to sal_Bool:
|
// implicitly cast back again to sal_Bool:
|
||||||
if (dyn_cast<CXXFunctionalCastExpr>(sub) != nullptr
|
if (dyn_cast<CXXFunctionalCastExpr>(sub) != nullptr
|
||||||
&& sub->getType()->isBooleanType() && isSalBool(expr->getType())
|
&& sub->getType()->isBooleanType() && isSalBool(expr->getType())
|
||||||
&& isSalBool(sub->getSubExpr()->IgnoreParenImpCasts()->getType()))
|
&& isSalBool(subsub->getType()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
report(
|
report(
|
||||||
DiagnosticsEngine::Warning,
|
DiagnosticsEngine::Warning,
|
||||||
"explicit conversion (%0) from %1 to %2 implicitly cast back to %3",
|
("explicit conversion (%0) from %1 to %2 implicitly cast back"
|
||||||
|
" to %3"),
|
||||||
expr->getLocStart())
|
expr->getLocStart())
|
||||||
<< sub->getCastKindName()
|
<< sub->getCastKindName() << subsub->getType() << sub->getType()
|
||||||
<< sub->getSubExpr()->IgnoreParenImpCasts()->getType()
|
<< expr->getType() << expr->getSourceRange();
|
||||||
<< sub->getType() << expr->getType() << expr->getSourceRange();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (expr->getType()->isBooleanType() && !isBoolExpr(expr->getSubExpr())
|
if (expr->getType()->isBooleanType() && !isBoolExpr(expr->getSubExpr())
|
||||||
&& !calls.empty())
|
&& !calls.empty())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user