]> granicus.if.org Git - clang/commitdiff
Bug fix in CFG construction: Properly register the loop head as the implicit
authorTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 07:20:00 +0000 (07:20 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 07:20:00 +0000 (07:20 +0000)
successor of blocks created above it.

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

AST/CFG.cpp

index 431b2e23af14c25b58b548ede0da275cd3938b08..3ea531361947bb9988f6785b8e0de4f781149607 100644 (file)
@@ -679,6 +679,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
     // There is no loop initialization.   We are thus basically a while 
     // loop.  NULL out Block to force lazy block construction.
     Block = NULL;
+    Succ = EntryConditionBlock;
     return EntryConditionBlock;
   }
 }
@@ -758,6 +759,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
   Block = NULL;
   
   // Return the condition block, which is the dominating block for the loop.
+  Succ = EntryConditionBlock;
   return EntryConditionBlock;
 }
 
@@ -790,11 +792,9 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
     if (Block) FinishBlock(EntryConditionBlock);
   }
   
-  // The condition block is the implicit successor for the loop body as
-  // well as any code above the loop.
+  // The condition block is the implicit successor for the loop body.
   Succ = EntryConditionBlock;
 
-
   // Process the loop body.
   CFGBlock* BodyBlock = NULL;
   {
@@ -836,6 +836,7 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
   Block = NULL;
   
   // Return the loop body, which is the dominating block for the loop.
+  Succ = BodyBlock;
   return BodyBlock;
 }