summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2017-01-04 00:46:30 +0000
committerRichard Trieu <rtrieu@google.com>2017-01-04 00:46:30 +0000
commit6a6af52ba604a1b837249b211e6d16cbb5ceca45 (patch)
tree5b0e2e435a061860eca2f0da3c1914c5bf5a081b /clang/lib
parent287d9496670c3b017a6c64b9cd701028d32a0274 (diff)
downloadbcm5719-llvm-6a6af52ba604a1b837249b211e6d16cbb5ceca45.tar.gz
bcm5719-llvm-6a6af52ba604a1b837249b211e6d16cbb5ceca45.zip
Extend -Wtautological-overlap-compare to more cases.
Previously, -Wtautological-overlap-compare did not warn on cases where the boolean expression was in an assignment or return statement. This patch should cause all boolean statements to be passed to the tautological compare checks in the CFG analysis. This is one of the issues from PR13101 llvm-svn: 290920
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/CFG.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index bf3cc05cdb6..a1a463f1d03 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1690,15 +1690,19 @@ CFGBuilder::VisitLogicalOperator(BinaryOperator *B,
// we have been provided.
ExitBlock = RHSBlock = createBlock(false);
+ // Even though KnownVal is only used in the else branch of the next
+ // conditional, tryEvaluateBool performs additional checking on the
+ // Expr, so it should be called unconditionally.
+ TryResult KnownVal = tryEvaluateBool(RHS);
+ if (!KnownVal.isKnown())
+ KnownVal = tryEvaluateBool(B);
+
if (!Term) {
assert(TrueBlock == FalseBlock);
addSuccessor(RHSBlock, TrueBlock);
}
else {
RHSBlock->setTerminator(Term);
- TryResult KnownVal = tryEvaluateBool(RHS);
- if (!KnownVal.isKnown())
- KnownVal = tryEvaluateBool(B);
addSuccessor(RHSBlock, TrueBlock, !KnownVal.isFalse());
addSuccessor(RHSBlock, FalseBlock, !KnownVal.isTrue());
}
OpenPOWER on IntegriCloud