[cfe-commits] r41327 - /cfe/trunk/AST/CFG.cpp

Ted Kremenek kremenek at apple.com
Thu Aug 23 10:29:58 PDT 2007


Author: kremenek
Date: Thu Aug 23 12:29:58 2007
New Revision: 41327

URL: http://llvm.org/viewvc/llvm-project?rev=41327&view=rev
Log:
For gotos, breaks, and continues where we cannot find a target successor
block (because we are creating a CFG from an incomplete AST) we now
(gracefully) have a block ending with such statements not have any successors
instead of firing an assertion.

Modified:
    cfe/trunk/AST/CFG.cpp

Modified: cfe/trunk/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/CFG.cpp?rev=41327&r1=41326&r2=41327&view=diff

==============================================================================
--- cfe/trunk/AST/CFG.cpp (original)
+++ cfe/trunk/AST/CFG.cpp Thu Aug 23 12:29:58 2007
@@ -104,8 +104,9 @@
         GotoStmt* G = cast<GotoStmt>(B->getTerminator());
         LabelMapTy::iterator LI = LabelMap.find(G->getLabel());
 
-        if (LI == LabelMap.end())
-          return NULL; // No matching label.  Bad CFG.
+        // If there is no target for the goto, then we are looking at an
+        // incomplete AST.  Handle this by not registering a successor.
+        if (LI == LabelMap.end()) continue;
         
         B->addSuccessor(LI->second);                   
       }                          
@@ -511,10 +512,10 @@
     Block = createBlock(false);
     Block->setTerminator(C);
     
-    // FIXME: We should gracefully handle continues without resolved targets.
-    assert (ContinueTargetBlock);
+    // If there is no target for the continue, then we are looking at an
+    // incomplete AST.  Handle this by not registering a successor.
+    if (ContinueTargetBlock) Block->addSuccessor(ContinueTargetBlock);
     
-    Block->addSuccessor(ContinueTargetBlock);
     return Block;
   }
   
@@ -527,10 +528,10 @@
     Block = createBlock(false);
     Block->setTerminator(B);
     
-    // FIXME: We should gracefully handle breaks without resolved targets.
-    assert (BreakTargetBlock);
-    
-    Block->addSuccessor(BreakTargetBlock);
+    // If there is no target for the break, then we are looking at an
+    // incomplete AST.  Handle this by not registering a successor.
+    if (BreakTargetBlock) Block->addSuccessor(BreakTargetBlock);
+
     return Block;  
   }
   





More information about the cfe-commits mailing list