diff options
author | Richard Trieu <rtrieu@google.com> | 2015-08-19 21:33:54 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2015-08-19 21:33:54 +0000 |
commit | 1cd076eb34980ae49cf11e5d2c21363269b8a117 (patch) | |
tree | 74c6ba7bb43d3624bf4f2029ddb0ca6f1a228806 /clang/lib/Sema/SemaExpr.cpp | |
parent | 9e5927fdc3a91e2916fc6012a7abe69b894b7a4f (diff) | |
download | bcm5719-llvm-1cd076eb34980ae49cf11e5d2c21363269b8a117.tar.gz bcm5719-llvm-1cd076eb34980ae49cf11e5d2c21363269b8a117.zip |
Fix -Wlogical-not-parentheses to work better with C code.
Remove the assumption of a Boolean type by checking if an expression is known
to have a boolean value. Disable warning in two other tests.
llvm-svn: 245507
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0d3913448f3..76b9aecdac8 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8374,19 +8374,16 @@ static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned OpaqueOpc) { - // This checking requires bools. - if (!S.getLangOpts().Bool) return; - // Check that left hand side is !something. UnaryOperator *UO = dyn_cast<UnaryOperator>(LHS.get()->IgnoreImpCasts()); if (!UO || UO->getOpcode() != UO_LNot) return; // Only check if the right hand side is non-bool arithmetic type. - if (RHS.get()->getType()->isBooleanType()) return; + if (RHS.get()->isKnownToHaveBooleanValue()) return; // Make sure that the something in !something is not bool. Expr *SubExpr = UO->getSubExpr()->IgnoreImpCasts(); - if (SubExpr->getType()->isBooleanType()) return; + if (SubExpr->isKnownToHaveBooleanValue()) return; // Emit warning. S.Diag(UO->getOperatorLoc(), diag::warn_logical_not_on_lhs_of_comparison) |