diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:54:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:54:37 +0000 |
commit | 76525467cfe07a2cec3a4e58043ec308ae5d67a3 (patch) | |
tree | f13f663412a151f7a03998f15e946d25a02f1f1a /lib/Analysis/CFG.cpp | |
parent | 7d02b8c3be58676a03046eef9d056063e55ada3e (diff) |
Add CFG support for the initializer of the condition variable of a WhileStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r-- | lib/Analysis/CFG.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index cfdee4927b..fcdc95ec53 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -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; } |