diff options
author | Marcin Swiderski <marcin.sfider@gmail.com> | 2010-10-01 01:24:41 +0000 |
---|---|---|
committer | Marcin Swiderski <marcin.sfider@gmail.com> | 2010-10-01 01:24:41 +0000 |
commit | e407a3ba1ec9f04d592511cc7540b6e541e0fceb (patch) | |
tree | 8de60af1e0064e659cebfc50f25979e4b1034194 /clang/lib/Analysis | |
parent | aa433018421139bb5f779cb413eccd607d32e9d1 (diff) | |
download | bcm5719-llvm-e407a3ba1ec9f04d592511cc7540b6e541e0fceb.tar.gz bcm5719-llvm-e407a3ba1ec9f04d592511cc7540b6e541e0fceb.zip |
dded generating CFGAutomaticObjDtors for condition variable and implicit scopes in switch statement.
llvm-svn: 115264
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 212f3ea7f3e..bc83e207538 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1907,6 +1907,18 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) { // block. CFGBlock* SwitchSuccessor = NULL; + // 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 = Terminator->getConditionVariable()) { + LocalScope::const_iterator SwitchBeginScopePos = ScopePos; + addLocalScopeForVarDecl(VD); + addAutomaticObjDtors(ScopePos, SwitchBeginScopePos, Terminator); + } + if (Block) { if (badCFG) return 0; @@ -1936,6 +1948,12 @@ CFGBlock* CFGBuilder::VisitSwitchStmt(SwitchStmt* Terminator) { // control-flow from the switch goes to case/default statements. assert(Terminator->getBody() && "switch must contain a non-NULL body"); Block = NULL; + + // If body is not a compound statement create implicit scope + // and add destructors. + if (!isa<CompoundStmt>(Terminator->getBody())) + addLocalScopeAndDtors(Terminator->getBody()); + addStmt(Terminator->getBody()); if (Block) { if (badCFG) |