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

Ted Kremenek kremenek at apple.com
Mon Nov 24 12:50:24 PST 2008


Author: kremenek
Date: Mon Nov 24 14:50:24 2008
New Revision: 59982

URL: http://llvm.org/viewvc/llvm-project?rev=59982&view=rev
Log:
Fix CFG bug where the 'increment' block for a 'for' statement would not be
properly reversed once constructed.

This fixes PR 3125:

http://llvm.org/bugs/show_bug.cgi?id=3125

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=59982&r1=59981&r2=59982&view=diff

==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Mon Nov 24 14:50:24 2008
@@ -745,8 +745,15 @@
     if (Stmt* I = F->getInc()) {
       // Generate increment code in its own basic block.  This is the target
       // of continue statements.
-      Succ = addStmt(I);
-      Block = 0;
+      Succ = Visit(I);
+      
+      // Finish up the increment block if it hasn't been already.
+      if (Block) {
+        assert (Block == Succ);
+        FinishBlock(Block);
+        Block = 0;
+      }
+      
       ContinueTargetBlock = Succ;    
     }
     else {
@@ -1621,6 +1628,7 @@
   
   // Print the exit block.
   print_block(OS, this, getExit(), &Helper, true);
+  OS.flush();
 }  
 
 /// dump - A simply pretty printer of a CFGBlock that outputs to stderr.





More information about the cfe-commits mailing list