]> granicus.if.org Git - clang/commitdiff
CFG: Add "loop back" block for do...while statements.
authorTed Kremenek <kremenek@apple.com>
Tue, 28 Apr 2009 04:22:00 +0000 (04:22 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 28 Apr 2009 04:22:00 +0000 (04:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70284 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CFG.cpp

index ea29259f9eda6aa4f812b042585e5425180f10dd..5658386a0838e01c871946f32431678eb6f9f6aa 100644 (file)
@@ -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.