jordan_rose accepted this revision.
jordan_rose added a comment.
This revision is now accepted and ready to land.
Let's just go with your simple version that makes the common case better. There
are a lot of problems with `throw`, so I wouldn't worry about that right now.
(By the way, we don't
klimek added a comment.
> I currently see the following ways forward:
>
> 1. Extend this patch to cover also "throw", fixing case B)
> 2. Do 1) plus loop over the whole body to also fix case C)
> 3. Drop this patch and instead remove unreachable blocks after the whole CFG
> has been
jordan_rose added a subscriber: dcoughlin.
jordan_rose added a comment.
Hm. On the one hand, getting this right seems like a nice property, and even
adding another loop wouldn't change the order of growth. On the other hand, not
having the extra destructors seems like the same sort of property
mgehre added a comment.
Basically, there are the following cases:
A)
void f() {
S s;
}
Everything OK, only one (reachable) destructor is generated
B)
int f() {
S s;
return 1;
}
In current trunk, this first generates dtor in a block when visiting the
CompoundStmt,
and then
klimek added inline comments.
Comment at: lib/Analysis/CFG.cpp:1949-1952
@@ +1948,6 @@
+ }
+ if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
+addAutomaticObjDtors(ScopePos,
klimek added a reviewer: jordan_rose.
klimek added a comment.
+jordan for an opinion on whether we want to fix the more general case.
My main problem is that while we're at it we need to fully understand the
change anyway, and if somebody runs into this later, they'll need a long time
mgehre added inline comments.
Comment at: lib/Analysis/CFG.cpp:1949-1952
@@ +1948,6 @@
+ }
+ if (!C->body_empty() && !isa(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
+addAutomaticObjDtors(ScopePos,
mgehre added a comment.
I see. Thinking about this, the same issue should also apply to a throw
inside the compound stmt. And it's not only about suppressing the dtors but
any CFG entries after return/throw. I'll prepare an updated patch.
Manuel Klimek schrieb am So., 1. Nov.
mgehre updated this revision to Diff 38359.
mgehre added a comment.
Update for review comments
http://reviews.llvm.org/D13973
Files:
lib/Analysis/CFG.cpp
test/Analysis/no-unreachable-dtors.cpp
Index: test/Analysis/no-unreachable-dtors.cpp
klimek added inline comments.
Comment at: lib/Analysis/CFG.cpp:1949-1952
@@ +1948,6 @@
+ }
+ if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
+addAutomaticObjDtors(ScopePos,
mgehre added inline comments.
Comment at: lib/Analysis/CFG.cpp:1949-1952
@@ +1948,6 @@
+ }
+ if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
+addAutomaticObjDtors(ScopePos,
majnemer added a subscriber: majnemer.
Comment at: lib/Analysis/CFG.cpp:1949
@@ +1948,3 @@
+ }
+ if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
mgehre wrote:
>
klimek added inline comments.
Comment at: lib/Analysis/CFG.cpp:1949-1952
@@ +1948,6 @@
+ }
+ if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in
VisitReturnStmt
+addAutomaticObjDtors(ScopePos,
mgehre updated this revision to Diff 38090.
mgehre added a comment.
Fix formatting
http://reviews.llvm.org/D13973
Files:
lib/Analysis/CFG.cpp
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@
mgehre updated this revision to Diff 38157.
mgehre added a comment.
Add test case
http://reviews.llvm.org/D13973
Files:
lib/Analysis/CFG.cpp
test/Analysis/no-unreachable-dtors.cpp
Index: test/Analysis/no-unreachable-dtors.cpp
klimek added a subscriber: klimek.
klimek added a comment.
A test that fails before this patch and passes afterwards is needed :) If you
need help writing that test, let me know.
http://reviews.llvm.org/D13973
___
cfe-commits mailing list
mgehre created this revision.
mgehre added a reviewer: krememek.
mgehre added a subscriber: cfe-commits.
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;
17 matches
Mail list logo