summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-28 03:09:44 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-28 03:09:44 +0000
commit49936f76ecfe2202393dfd4ea237aff3ba29dbf0 (patch)
tree4c3f52502b44401c713500b1f9f21cadaeead53a /clang
parentc3884be98373acf44e036f591750ee2330c7eb20 (diff)
downloadbcm5719-llvm-49936f76ecfe2202393dfd4ea237aff3ba29dbf0.tar.gz
bcm5719-llvm-49936f76ecfe2202393dfd4ea237aff3ba29dbf0.zip
CFG: 'WhileStmts' needs an extra block to indicate the "loop back" path.
llvm-svn: 70280
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/CFG.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp
index 00f5960e11f..ea29259f9ed 100644
--- a/clang/lib/AST/CFG.cpp
+++ b/clang/lib/AST/CFG.cpp
@@ -934,7 +934,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
if (Stmt* C = W->getCond()) {
Block = ExitConditionBlock;
EntryConditionBlock = addStmt(C);
- assert (Block == EntryConditionBlock);
+ assert(Block == EntryConditionBlock);
if (Block) FinishBlock(EntryConditionBlock);
}
@@ -944,15 +944,20 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
// Process the loop body.
{
- assert (W->getBody());
+ assert(W->getBody());
// Save the current values for Block, Succ, and continue and break targets
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ),
save_continue(ContinueTargetBlock),
save_break(BreakTargetBlock);
-
- // All continues within this loop should go to the condition block
- ContinueTargetBlock = EntryConditionBlock;
+
+ // Create an empty block to represent the transition block for looping
+ // back to the head of the loop.
+ Block = 0;
+ assert(Succ == EntryConditionBlock);
+ Succ = createBlock();
+ Succ->setLoopTarget(W);
+ ContinueTargetBlock = Succ;
// All breaks should go to the code following the loop.
BreakTargetBlock = LoopSuccessor;
OpenPOWER on IntegriCloud