]> granicus.if.org Git - clang/commitdiff
Fixed CFG construction bug that occurred when a condition for a loop spanned
authorTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 00:28:17 +0000 (00:28 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 27 Feb 2008 00:28:17 +0000 (00:28 +0000)
multiple basic blocks (which can happen when they contain '&&', '||', '?'). The
bug was that the loop backedge when to the last block in the loop condition, not
the first.

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

AST/CFG.cpp

index 335d833e262c3d18cfaf528dcab67d213dc899e5..431b2e23af14c25b58b548ede0da275cd3938b08 100644 (file)
@@ -656,7 +656,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
     CFGBlock* BodyBlock = Visit(F->getBody());      
 
     if (!BodyBlock)
-      BodyBlock = ExitConditionBlock; // can happen for "for (...;...; ) ;"
+      BodyBlock = EntryConditionBlock; // can happen for "for (...;...; ) ;"
     else if (Block)
       FinishBlock(BodyBlock);
     
@@ -710,6 +710,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
   if (Stmt* C = W->getCond()) {
     Block = ExitConditionBlock;
     EntryConditionBlock = addStmt(C);
+    assert (Block == EntryConditionBlock);
     if (Block) FinishBlock(EntryConditionBlock);
   }
   
@@ -739,7 +740,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
     CFGBlock* BodyBlock = Visit(W->getBody());
     
     if (!BodyBlock)
-      BodyBlock = ExitConditionBlock; // can happen for "while(...) ;"
+      BodyBlock = EntryConditionBlock; // can happen for "while(...) ;"
     else if (Block)
       FinishBlock(BodyBlock);
     
@@ -817,7 +818,7 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
     BodyBlock = Visit(D->getBody());
     
     if (!BodyBlock)
-      BodyBlock = ExitConditionBlock; // can happen for "do ; while(...)"
+      BodyBlock = EntryConditionBlock; // can happen for "do ; while(...)"
     else if (Block)
       FinishBlock(BodyBlock);