diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-28 04:22:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-28 04:22:00 +0000 |
commit | 8f08c9d83fdabb6f27c44a4dbce78487519c89eb (patch) | |
tree | 3a8f5df62f04ed2603b1ace361236649640b726b | |
parent | 2962f4d71d26817780e7441b23e0e91214fceb5e (diff) |
CFG: Add "loop back" block for do...while statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70284 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/CFG.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index ea29259f9e..5658386a08 100644 --- a/lib/AST/CFG.cpp +++ b/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. |