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 | 1f07b4c439a742d8ccb3499f0726bd46ddaebf20 (patch) | |
tree | bfe2c16c14905076c17ce64df84c7deaad20abf6 /clang/lib/Analysis/CFG.cpp | |
parent | b04c5cb0ba3a75ac45e5e37fdc16773f11b358ed (diff) | |
download | bcm5719-llvm-1f07b4c439a742d8ccb3499f0726bd46ddaebf20.tar.gz bcm5719-llvm-1f07b4c439a742d8ccb3499f0726bd46ddaebf20.zip |
Add CFG support for the initializer of the condition variable of a WhileStmt.
llvm-svn: 92105
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index cfdee4927bb..fcdc95ec53d 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/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; } |