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.

llvm-svn: 41327
This commit is contained in:
Ted Kremenek 2007-08-23 17:29:58 +00:00
parent a0f12c5493
commit 9ee3bcf81c
1 changed files with 10 additions and 9 deletions

View 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;
}