[-Wunreachable-code] Expand paren-suppression heuristic to C++/ObjC bools.

llvm-svn: 205074
This commit is contained in:
Ted Kremenek
2014-03-29 04:49:20 +00:00
parent 48fb488706
commit ab57a1555a
3 changed files with 77 additions and 6 deletions

View File

@@ -141,12 +141,15 @@ static bool isConfigurationValue(const Stmt *S,
// Special case looking for the sigil '()' around an integer literal.
if (const ParenExpr *PE = dyn_cast<ParenExpr>(S))
return isConfigurationValue(PE->getSubExpr(), PP, SilenceableCondVal,
IncludeIntegers, true);
if (!PE->getLocStart().isMacroID())
return isConfigurationValue(PE->getSubExpr(), PP, SilenceableCondVal,
IncludeIntegers, true);
if (const Expr *Ex = dyn_cast<Expr>(S))
S = Ex->IgnoreParenCasts();
bool IgnoreYES_NO = false;
switch (S->getStmtClass()) {
case Stmt::CallExprClass: {
const FunctionDecl *Callee =
@@ -155,19 +158,21 @@ static bool isConfigurationValue(const Stmt *S,
}
case Stmt::DeclRefExprClass:
return isConfigurationValue(cast<DeclRefExpr>(S)->getDecl(), PP);
case Stmt::ObjCBoolLiteralExprClass:
IgnoreYES_NO = true;
// Fallthrough.
case Stmt::CXXBoolLiteralExprClass:
case Stmt::IntegerLiteralClass: {
const IntegerLiteral *E = cast<IntegerLiteral>(S);
const Expr *E = cast<Expr>(S);
if (IncludeIntegers) {
if (SilenceableCondVal && !SilenceableCondVal->getBegin().isValid())
*SilenceableCondVal = E->getSourceRange();
return WrappedInParens || isExpandedFromConfigurationMacro(E, PP);
return WrappedInParens || isExpandedFromConfigurationMacro(E, PP, IgnoreYES_NO);
}
return false;
}
case Stmt::MemberExprClass:
return isConfigurationValue(cast<MemberExpr>(S)->getMemberDecl(), PP);
case Stmt::ObjCBoolLiteralExprClass:
return isExpandedFromConfigurationMacro(S, PP, /* IgnoreYES_NO */ true);
case Stmt::UnaryExprOrTypeTraitExprClass:
return true;
case Stmt::BinaryOperatorClass: {