]> granicus.if.org Git - clang/commitdiff
For gotos, breaks, and continues where we cannot find a target successor
authorTed Kremenek <kremenek@apple.com>
Thu, 23 Aug 2007 17:29:58 +0000 (17:29 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 23 Aug 2007 17:29:58 +0000 (17:29 +0000)
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.

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

AST/CFG.cpp

index 162b34c4233f7178a962387d13f332812993062a..495cfb8d1ec41d1cff6a8a22613d755fd197c233 100644 (file)
@@ -104,8 +104,9 @@ public:
         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 @@ public:
     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 @@ public:
     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;  
   }