diff options
author | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2016-10-03 08:28:51 +0000 |
---|---|---|
committer | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2016-10-03 08:28:51 +0000 |
commit | 042a3c5a2d3ace9b3e67425576971e47cf1a65cb (patch) | |
tree | f29c6d1c326319c2462ada048d21d8c77c5a576f /clang/lib | |
parent | c87d2a613ec0e99e43ea683743736c8acc9bd47c (diff) | |
download | bcm5719-llvm-042a3c5a2d3ace9b3e67425576971e47cf1a65cb.tar.gz bcm5719-llvm-042a3c5a2d3ace9b3e67425576971e47cf1a65cb.zip |
[StaticAnalyzer] Fix UnreachableCode false positives.
When there is 'do { } while (0);' in the code the ExplodedGraph and UnoptimizedCFG did not match.
Differential Revision: https://reviews.llvm.org/D24759
llvm-svn: 283095
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index a67f0910e15..3e5e54868d2 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -2983,20 +2983,19 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) { return nullptr; } - if (!KnownVal.isFalse()) { - // Add an intermediate block between the BodyBlock and the - // ExitConditionBlock to represent the "loop back" transition. Create an - // empty block to represent the transition block for looping back to the - // head of the loop. - // FIXME: Can we do this more efficiently without adding another block? - Block = nullptr; - Succ = BodyBlock; - CFGBlock *LoopBackBlock = createBlock(); - LoopBackBlock->setLoopTarget(D); + // Add an intermediate block between the BodyBlock and the + // ExitConditionBlock to represent the "loop back" transition. Create an + // empty block to represent the transition block for looping back to the + // head of the loop. + // FIXME: Can we do this more efficiently without adding another block? + Block = nullptr; + Succ = BodyBlock; + CFGBlock *LoopBackBlock = createBlock(); + LoopBackBlock->setLoopTarget(D); + if (!KnownVal.isFalse()) // Add the loop body entry as a successor to the condition. addSuccessor(ExitConditionBlock, LoopBackBlock); - } else addSuccessor(ExitConditionBlock, nullptr); } |