CFGBuilder: don't create the empty "loop back" block for DoStmts if the loop edge can never be taken.

llvm-svn: 111282
This commit is contained in:
Ted Kremenek 2010-08-17 20:59:56 +00:00
parent e0db9d01d9
commit 110974dfa4
1 changed files with 15 additions and 11 deletions

View File

@ -1476,6 +1476,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) {
return 0;
}
if (!KnownVal.isFalse()) {
// Add an intermediate block between the BodyBlock and the
// ExitConditionBlock to represent the "loop back" transition. Create an
// empty block to represent the transition block for looping back to the
@ -1487,7 +1488,10 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) {
LoopBackBlock->setLoopTarget(D);
// Add the loop body entry as a successor to the condition.
AddSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : LoopBackBlock);
AddSuccessor(ExitConditionBlock, LoopBackBlock);
}
else
AddSuccessor(ExitConditionBlock, NULL);
}
// Link up the condition block with the code that follows the loop.