diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-12-24 01:49:06 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-12-24 01:49:06 +0000 |
commit | ec92f9492b46f70d5191b53622f0a5150d2fbc69 (patch) | |
tree | 7edee2726a73aace4cb7217f3c86a5f08e1c6448 /clang/lib/Analysis/CFG.cpp | |
parent | 1c3ab079685147288c3a315108a23bd56567ac21 (diff) | |
download | bcm5719-llvm-ec92f9492b46f70d5191b53622f0a5150d2fbc69.tar.gz bcm5719-llvm-ec92f9492b46f70d5191b53622f0a5150d2fbc69.zip |
Add CFG support for the initializer of the condition variable of a ForStmt.
llvm-svn: 92113
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index a317e0452cf..eab7da7e837 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -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; |