Bug fix in CFG construction: Properly register the loop head as the implicit

successor of blocks created above it.

llvm-svn: 47666
This commit is contained in:
Ted Kremenek 2008-02-27 07:20:00 +00:00
parent cbb21b61c8
commit a1523a38f9
1 changed files with 4 additions and 3 deletions

View File

@ -679,6 +679,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
// There is no loop initialization. We are thus basically a while
// loop. NULL out Block to force lazy block construction.
Block = NULL;
Succ = EntryConditionBlock;
return EntryConditionBlock;
}
}
@ -758,6 +759,7 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
Block = NULL;
// Return the condition block, which is the dominating block for the loop.
Succ = EntryConditionBlock;
return EntryConditionBlock;
}
@ -790,11 +792,9 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
if (Block) FinishBlock(EntryConditionBlock);
}
// The condition block is the implicit successor for the loop body as
// well as any code above the loop.
// The condition block is the implicit successor for the loop body.
Succ = EntryConditionBlock;
// Process the loop body.
CFGBlock* BodyBlock = NULL;
{
@ -836,6 +836,7 @@ CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) {
Block = NULL;
// Return the loop body, which is the dominating block for the loop.
Succ = BodyBlock;
return BodyBlock;
}