summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMarcin Swiderski <marcin.sfider@gmail.com>2010-10-01 00:52:17 +0000
committerMarcin Swiderski <marcin.sfider@gmail.com>2010-10-01 00:52:17 +0000
commitf883ade88082ac65f093077337e5dbcfe77287c6 (patch)
treea02e84f2c5762580930a105cc109593b4a011bb6 /clang/lib
parent33e5c354e5db561790740a5ce505d3e60ae75d95 (diff)
downloadbcm5719-llvm-f883ade88082ac65f093077337e5dbcfe77287c6.tar.gz
bcm5719-llvm-f883ade88082ac65f093077337e5dbcfe77287c6.zip
Added generating CFGAutomaticObjDtors for condition variable and implicit scopes in if statement.
llvm-svn: 115256
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/CFG.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 33e0ff94c24..fd8b009abae 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1136,6 +1136,18 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) {
// middle of a block, we stop processing that block. That block is then the
// implicit successor for the "then" and "else" clauses.
+ // Save local scope position because in case of condition variable ScopePos
+ // won't be restored when traversing AST.
+ SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
+
+ // Create local scope for possible condition variable.
+ // Store scope position. Add implicit destructor.
+ if (VarDecl* VD = I->getConditionVariable()) {
+ LocalScope::const_iterator BeginScopePos = ScopePos;
+ addLocalScopeForVarDecl(VD);
+ addAutomaticObjDtors(ScopePos, BeginScopePos, I);
+ }
+
// The block we were proccessing is now finished. Make it the successor
// block.
if (Block) {
@@ -1153,6 +1165,12 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) {
// NULL out Block so that the recursive call to Visit will
// create a new basic block.
Block = NULL;
+
+ // If branch is not a compound statement create implicit scope
+ // and add destructors.
+ if (!isa<CompoundStmt>(Else))
+ addLocalScopeAndDtors(Else);
+
ElseBlock = addStmt(Else);
if (!ElseBlock) // Can occur when the Else body has all NullStmts.
@@ -1170,6 +1188,12 @@ CFGBlock* CFGBuilder::VisitIfStmt(IfStmt* I) {
assert(Then);
SaveAndRestore<CFGBlock*> sv(Succ);
Block = NULL;
+
+ // If branch is not a compound statement create implicit scope
+ // and add destructors.
+ if (!isa<CompoundStmt>(Then))
+ addLocalScopeAndDtors(Then);
+
ThenBlock = addStmt(Then);
if (!ThenBlock) {
OpenPOWER on IntegriCloud