summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-12-23 04:49:01 +0000
committerTed Kremenek <kremenek@apple.com>2009-12-23 04:49:01 +0000
commita7bcbde814070b71306dfbee42841d8fe3699e66 (patch)
tree7f28395c80c082e491ed85a717ad4d15a5fa1ecb /clang/lib/Analysis/CFG.cpp
parent857f41c6505f168c9cd08d3f5e1c07d3eb0ae441 (diff)
downloadbcm5719-llvm-a7bcbde814070b71306dfbee42841d8fe3699e66.tar.gz
bcm5719-llvm-a7bcbde814070b71306dfbee42841d8fe3699e66.zip
Add CFG support for the condition variable that can appear in IfStmts in C++ mode.
Add transfer function support in GRExprEngine for IfStmts with initialized condition variables. llvm-svn: 91987
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r--clang/lib/Analysis/CFG.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 884188acd78..8f2a5719f68 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -776,7 +776,19 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) {
// Add the condition as the last statement in the new block. This may create
// new blocks as the condition may contain control-flow. Any newly created
// blocks will be pointed to be "Block".
- return addStmt(I->getCond());
+ Block = addStmt(I->getCond());
+
+ // Finally, if the IfStmt contains a condition variable, add both the IfStmt
+ // and the condition variable initialization to the CFG.
+ if (VarDecl *VD = I->getConditionVariable()) {
+ if (Expr *Init = VD->getInit()) {
+ autoCreateBlock();
+ AppendStmt(Block, I, AddStmtChoice::AlwaysAdd);
+ addStmt(Init);
+ }
+ }
+
+ return Block;
}
OpenPOWER on IntegriCloud