summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-28 00:51:56 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-28 00:51:56 +0000
commit902393b4b79c7fc40635fc5556b856ec121abaf0 (patch)
tree8599f6a51c62366b07c70b016a8a3b25ba7e726e /clang/lib/AST
parent5d72d411899ce70d60b6ca58f92e61afd6349f2d (diff)
downloadbcm5719-llvm-902393b4b79c7fc40635fc5556b856ec121abaf0.tar.gz
bcm5719-llvm-902393b4b79c7fc40635fc5556b856ec121abaf0.zip
CFG:
- Add 'LoopTarget' pointer field to CFGBlock. This records if the block is used as the 'loop back' path back to the head of a loop. - For ForStmt, encode the loop back target as the increment code. llvm-svn: 70274
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/CFG.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp
index 14c93f398e8..00f5960e11f 100644
--- a/clang/lib/AST/CFG.cpp
+++ b/clang/lib/AST/CFG.cpp
@@ -752,21 +752,27 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
// Generate increment code in its own basic block. This is the target
// of continue statements.
Succ = Visit(I);
-
- // Finish up the increment block if it hasn't been already.
- if (Block) {
- assert (Block == Succ);
- FinishBlock(Block);
- Block = 0;
- }
-
- ContinueTargetBlock = Succ;
}
else {
- // No increment code. Continues should go the the entry condition block.
- ContinueTargetBlock = EntryConditionBlock;
+ // No increment code. Create a special, empty, block that is used as
+ // the target block for "looping back" to the start of the loop.
+ assert(Succ == EntryConditionBlock);
+ Succ = createBlock();
}
+ // Finish up the increment (or empty) block if it hasn't been already.
+ if (Block) {
+ assert(Block == Succ);
+ FinishBlock(Block);
+ Block = 0;
+ }
+
+ ContinueTargetBlock = Succ;
+
+ // The starting block for the loop increment is the block that should
+ // represent the 'loop target' for looping back to the start of the loop.
+ ContinueTargetBlock->setLoopTarget(F);
+
// All breaks should go to the code following the loop.
BreakTargetBlock = LoopSuccessor;
OpenPOWER on IntegriCloud