summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-28 04:22:00 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-28 04:22:00 +0000
commitcb37bb0f20cf399484adc4ca4c15ce140d391378 (patch)
treedf773f98463eb29ccac9a8e79294d6823fe16cc3 /clang
parent6bba2adc95c4c188d073039aa1ed95159efd85d7 (diff)
downloadbcm5719-llvm-cb37bb0f20cf399484adc4ca4c15ce140d391378.tar.gz
bcm5719-llvm-cb37bb0f20cf399484adc4ca4c15ce140d391378.zip
CFG: Add "loop back" block for do...while statements.
llvm-svn: 70284
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/CFG.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp
index ea29259f9ed..5658386a083 100644
--- a/clang/lib/AST/CFG.cpp
+++ b/clang/lib/AST/CFG.cpp
@@ -1069,8 +1069,18 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
else if (Block)
FinishBlock(BodyBlock);
+ // 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 = NULL;
+ Succ = BodyBlock;
+ CFGBlock *LoopBackBlock = createBlock();
+ LoopBackBlock->setLoopTarget(D);
+
// Add the loop body entry as a successor to the condition.
- ExitConditionBlock->addSuccessor(BodyBlock);
+ ExitConditionBlock->addSuccessor(LoopBackBlock);
}
// Link up the condition block with the code that follows the loop.
OpenPOWER on IntegriCloud