Add CFG support for the initializer of the condition variable of a WhileStmt.

llvm-svn: 92105
This commit is contained in:
Ted Kremenek 2009-12-24 00:54:37 +00:00
parent b04c5cb0ba
commit 1f07b4c439
1 changed files with 14 additions and 1 deletions

View File

@ -1188,8 +1188,21 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
// to this block. NULL out Block to force lazy creation of another block.
Block = NULL;
// Return the condition block, which is the dominating block for the loop.
// Set Succ to be the condition block, which is the dominating block
// for the loop.
Succ = EntryConditionBlock;
// Finally, if the WhileStmt contains a condition variable, add both the
// WhileStmt and the condition variable initialization to the CFG.
if (VarDecl *VD = W->getConditionVariable()) {
if (Expr *Init = VD->getInit()) {
autoCreateBlock();
AppendStmt(Block, W, AddStmtChoice::AlwaysAdd);
Succ = addStmt(Init);
return Succ;
}
}
return EntryConditionBlock;
}