[cfe-commits] r70284 - /cfe/trunk/lib/AST/CFG.cpp

Ted Kremenek kremenek at apple.com
Mon Apr 27 21:22:01 PDT 2009


Author: kremenek
Date: Mon Apr 27 23:22:00 2009
New Revision: 70284

URL: http://llvm.org/viewvc/llvm-project?rev=70284&view=rev
Log:
CFG: Add "loop back" block for do...while statements.

Modified:
    cfe/trunk/lib/AST/CFG.cpp

Modified: cfe/trunk/lib/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CFG.cpp?rev=70284&r1=70283&r2=70284&view=diff

==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Mon Apr 27 23:22:00 2009
@@ -1069,8 +1069,18 @@
     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.





More information about the cfe-commits mailing list