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

llvm-svn: 92113
This commit is contained in:
Ted Kremenek 2009-12-24 01:49:06 +00:00
parent 1c3ab07968
commit ec92f9492b
1 changed files with 13 additions and 0 deletions

View File

@ -888,6 +888,19 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
if (Stmt* C = F->getCond()) {
Block = ExitConditionBlock;
EntryConditionBlock = addStmt(C);
assert(Block == EntryConditionBlock);
// If this block contains a condition variable, add both the condition
// variable and initializer to the CFG.
if (VarDecl *VD = F->getConditionVariable()) {
if (Expr *Init = VD->getInit()) {
autoCreateBlock();
AppendStmt(Block, F, AddStmtChoice::AlwaysAdd);
EntryConditionBlock = addStmt(Init);
assert(Block == EntryConditionBlock);
}
}
if (Block) {
if (!FinishBlock(EntryConditionBlock))
return 0;