]> granicus.if.org Git - clang/commitdiff
Fixed bug in CFG construction involving use of labels and "empty"
authorTed Kremenek <kremenek@apple.com>
Thu, 30 Aug 2007 18:20:57 +0000 (18:20 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 30 Aug 2007 18:20:57 +0000 (18:20 +0000)
blocks involving only ';' statements.  We now correctly handle the following:

void empty_label() { l1: ; }

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

AST/CFG.cpp

index 014dc861de707b01fd2d41ddeb7dffc0ac912127..f6b74e7f7b7580b0b60aba2eae5cef9cfd930d85 100644 (file)
@@ -463,8 +463,10 @@ CFGBlock* CFGBuilder::VisitReturnStmt(ReturnStmt* R) {
 CFGBlock* CFGBuilder::VisitLabelStmt(LabelStmt* L) {
   // Get the block of the labeled statement.  Add it to our map.
   CFGBlock* LabelBlock = Visit(L->getSubStmt());
-  assert (LabelBlock);    
-
+  
+  if (!LabelBlock)            // This can happen when the body is empty, i.e.
+    LabelBlock=createBlock(); // scopes that only contains NullStmts.
+  
   assert (LabelMap.find(L) == LabelMap.end() && "label already in map");
   LabelMap[ L ] = LabelBlock;