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

Ted Kremenek kremenek at apple.com
Mon Apr 27 20:09:47 PDT 2009


Author: kremenek
Date: Mon Apr 27 22:09:44 2009
New Revision: 70280

URL: http://llvm.org/viewvc/llvm-project?rev=70280&view=rev
Log:
CFG: 'WhileStmts' needs an extra block to indicate the "loop back" path.

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=70280&r1=70279&r2=70280&view=diff

==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Mon Apr 27 22:09:44 2009
@@ -934,7 +934,7 @@
   if (Stmt* C = W->getCond()) {
     Block = ExitConditionBlock;
     EntryConditionBlock = addStmt(C);
-    assert (Block == EntryConditionBlock);
+    assert(Block == EntryConditionBlock);
     if (Block) FinishBlock(EntryConditionBlock);
   }
   
@@ -944,15 +944,20 @@
   
   // 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;





More information about the cfe-commits mailing list