]> granicus.if.org Git - clang/commitdiff
Fix CFG bug where the 'increment' block for a 'for' statement would not be
authorTed Kremenek <kremenek@apple.com>
Mon, 24 Nov 2008 20:50:24 +0000 (20:50 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 24 Nov 2008 20:50:24 +0000 (20:50 +0000)
properly reversed once constructed.

This fixes PR 3125:

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59982 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CFG.cpp

index f8c3c26bb110a599711ce17fe9a632b2462e618f..82336a44e08ebfad1538f3413860e0eb102d4ac0 100644 (file)
@@ -745,8 +745,15 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
     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 @@ void CFG::print(llvm::raw_ostream& OS) const {
   
   // 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.