summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2015-11-14 00:36:50 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2015-11-14 00:36:50 +0000
commit09a134eca3960d16325090631428b3dbc535ce4b (patch)
tree2a6cd0c8ee3115290514de7b496265203ed247fa /clang/lib/Analysis/CFG.cpp
parent6d048942c563dff83fb743ccf16959fe8e240d11 (diff)
downloadbcm5719-llvm-09a134eca3960d16325090631428b3dbc535ce4b.tar.gz
bcm5719-llvm-09a134eca3960d16325090631428b3dbc535ce4b.zip
CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
Summary: VisitReturnStmt would create a new block with including Dtors, so the Dtors created in VisitCompoundStmts would be in an unreachable block. Example: struct S { ~S(); }; void f() { S s; return; } void g() { S s; } Before this patch, f has one additional unreachable block containing just the destructor of S. With this patch, both f and g have the same blocks. Reviewers: krememek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13973 llvm-svn: 253107
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r--clang/lib/Analysis/CFG.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 6cb63f2b175..fba9a41f232 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1942,7 +1942,15 @@ CFGBlock *CFGBuilder::VisitChooseExpr(ChooseExpr *C,
CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C) {
- addLocalScopeAndDtors(C);
+ LocalScope::const_iterator scopeBeginPos = ScopePos;
+ if (BuildOpts.AddImplicitDtors) {
+ addLocalScopeForStmt(C);
+ }
+ if (!C->body_empty() && !isa<ReturnStmt>(*C->body_rbegin())) {
+ // If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt
+ addAutomaticObjDtors(ScopePos, scopeBeginPos, C);
+ }
+
CFGBlock *LastBlock = Block;
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
OpenPOWER on IntegriCloud