Fixed bug in CFG construction involving use of labels and "empty"
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
diff --git a/AST/CFG.cpp b/AST/CFG.cpp
index 014dc86..f6b74e7 100644
--- a/AST/CFG.cpp
+++ b/AST/CFG.cpp
@@ -463,8 +463,10 @@
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;