[PATCH] D24759: [RFC][StaticAnalyser] fix unreachable code false positives when block numbers mismatch
Daniel Marjamäki via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 05:07:06 PDT 2016
danielmarjamaki updated this revision to Diff 72461.
danielmarjamaki marked 2 inline comments as done.
danielmarjamaki added a comment.
Fixed review comments by Devin. It works better now!
https://reviews.llvm.org/D24759
Files:
lib/Analysis/CFG.cpp
test/Analysis/unreachable-code-path.c
Index: test/Analysis/unreachable-code-path.c
===================================================================
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,14 @@
}
}
}
+
+// Ensure that ExplodedGraph and unoptimized CFG match.
+void test12(int x) {
+ switch (x) {
+ case 1:
+ break; // not unreachable
+ case 2:
+ do { } while (0);
+ break;
+ }
+}
Index: lib/Analysis/CFG.cpp
===================================================================
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -2983,20 +2983,19 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24759.72461.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160926/6228fbea/attachment.bin>
More information about the cfe-commits
mailing list