[cfe-commits] r119044 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/temp-obj-dtors-cfg-output.cpp

Zhongxing Xu xuzhongxing at gmail.com
Sun Nov 14 07:23:50 PST 2010


Author: zhongxingxu
Date: Sun Nov 14 09:23:50 2010
New Revision: 119044

URL: http://llvm.org/viewvc/llvm-project?rev=119044&view=rev
Log:
Revert r118991.

Elidable CXXConstructExpr should inhibit calling destructor for temporary 
that is copied, not the one created. This is because eliding copy constructor 
means that the object that was to be copied will be constructed directly in 
memory the copy would be constructed in.


Modified:
    cfe/trunk/lib/Analysis/CFG.cpp
    cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=119044&r1=119043&r2=119044&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Sun Nov 14 09:23:50 2010
@@ -2579,18 +2579,11 @@
   return RHSBlock ? RHSBlock : LHSBlock;
 }
 
-static bool hasElidableCXXConstructExpr(CXXBindTemporaryExpr *E) {
-  if (CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E->getSubExpr()))
-    if (CE->isElidable())
-      return true;
-  return false;
-}
-
 CFGBlock *CFGBuilder::VisitCXXBindTemporaryExprForTemporaryDtors(
     CXXBindTemporaryExpr *E, bool BindToTemporary) {
   // First add destructors for temporaries in subexpression.
   CFGBlock *B = VisitForTemporaryDtors(E->getSubExpr());
-  if (!BindToTemporary && !hasElidableCXXConstructExpr(E)) {
+  if (!BindToTemporary) {
     // If lifetime of temporary is not prolonged (by assigning to constant
     // reference) add destructor for it.
     autoCreateBlock();

Modified: cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp?rev=119044&r1=119043&r2=119044&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp (original)
+++ cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp Sun Nov 14 09:23:50 2010
@@ -264,11 +264,14 @@
 // CHECK:    Successors (2): B3 B2
 // CHECK: [ B5 ]
 // CHECK:      1: ~A() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
 // CHECK:    Predecessors (1): B7
 // CHECK:    Successors (1): B4
 // CHECK: [ B6 ]
 // CHECK:      1: ~A() (Temporary object destructor)
-// CHECK:      2: ~B() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
+// CHECK:      3: ~A() (Temporary object destructor)
+// CHECK:      4: ~B() (Temporary object destructor)
 // CHECK:    Predecessors (1): B7
 // CHECK:    Successors (1): B4
 // CHECK: [ B7 ]
@@ -308,11 +311,14 @@
 // CHECK:    Successors (1): B0
 // CHECK: [ B2 ]
 // CHECK:      1: ~A() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
 // CHECK:    Predecessors (1): B4
 // CHECK:    Successors (1): B1
 // CHECK: [ B3 ]
 // CHECK:      1: ~A() (Temporary object destructor)
-// CHECK:      2: ~B() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
+// CHECK:      3: ~A() (Temporary object destructor)
+// CHECK:      4: ~B() (Temporary object destructor)
 // CHECK:    Predecessors (1): B4
 // CHECK:    Successors (1): B1
 // CHECK: [ B4 ]
@@ -345,7 +351,8 @@
 // CHECK:    Successors (1): B7
 // CHECK: [ B9 ]
 // CHECK:      1: ~A() (Temporary object destructor)
-// CHECK:      2: ~B() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
+// CHECK:      3: ~B() (Temporary object destructor)
 // CHECK:    Predecessors (1): B10
 // CHECK:    Successors (1): B7
 // CHECK: [ B10 ]
@@ -385,6 +392,7 @@
 // CHECK:    Successors (1): B0
 // CHECK: [ B2 ]
 // CHECK:      1: ~A() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
 // CHECK:    Predecessors (1): B3
 // CHECK:    Successors (1): B1
 // CHECK: [ B3 ]
@@ -418,6 +426,7 @@
 // CHECK:    Successors (1): B0
 // CHECK: [ B2 ]
 // CHECK:      1: ~A() (Temporary object destructor)
+// CHECK:      2: ~A() (Temporary object destructor)
 // CHECK:    Predecessors (1): B3
 // CHECK:    Successors (1): B1
 // CHECK: [ B3 ]





More information about the cfe-commits mailing list