Skip to content
Snippets Groups Projects
Commit ec92f949 authored by Ted Kremenek's avatar Ted Kremenek
Browse files

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

llvm-svn: 92113
parent 1c3ab079
No related branches found
No related tags found
No related merge requests found
...@@ -888,6 +888,19 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) { ...@@ -888,6 +888,19 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
if (Stmt* C = F->getCond()) { if (Stmt* C = F->getCond()) {
Block = ExitConditionBlock; Block = ExitConditionBlock;
EntryConditionBlock = addStmt(C); 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 (Block) {
if (!FinishBlock(EntryConditionBlock)) if (!FinishBlock(EntryConditionBlock))
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment