[cfe-commits] r118991 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/temp-obj-dtors-cfg-output.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Sat Nov 13 03:37:36 PST 2010
I see some unbalancing before this patch. (See the test case that was
modified.) Could you provide an example that is unbalanced by this patch?
2010/11/13 Marcin Ĺwiderski <marcin.sfider at gmail.com>
> Hi Zhongxing
>
> Won't it lead to unbalancing ctors/dtors like I've written in discusion
> after commit r118159?
>
> 2010/11/13 Zhongxing Xu <xuzhongxing at gmail.com>
>
> Author: zhongxingxu
>> Date: Sat Nov 13 01:30:59 2010
>> New Revision: 118991
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=118991&view=rev
>> Log:
>> Do not add implicit dtors for CXXBindTemporaryExpr with elidable
>> CXXConstructExpr.
>>
>> 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=118991&r1=118990&r2=118991&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
>> +++ cfe/trunk/lib/Analysis/CFG.cpp Sat Nov 13 01:30:59 2010
>> @@ -2579,11 +2579,18 @@
>> 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) {
>> + if (!BindToTemporary && !hasElidableCXXConstructExpr(E)) {
>> // 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=118991&r1=118990&r2=118991&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp (original)
>> +++ cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp Sat Nov 13
>> 01:30:59 2010
>> @@ -264,14 +264,11 @@
>> // 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: ~A() (Temporary object destructor)
>> -// CHECK: 3: ~A() (Temporary object destructor)
>> -// CHECK: 4: ~B() (Temporary object destructor)
>> +// CHECK: 2: ~B() (Temporary object destructor)
>> // CHECK: Predecessors (1): B7
>> // CHECK: Successors (1): B4
>> // CHECK: [ B7 ]
>> @@ -311,14 +308,11 @@
>> // 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: ~A() (Temporary object destructor)
>> -// CHECK: 3: ~A() (Temporary object destructor)
>> -// CHECK: 4: ~B() (Temporary object destructor)
>> +// CHECK: 2: ~B() (Temporary object destructor)
>> // CHECK: Predecessors (1): B4
>> // CHECK: Successors (1): B1
>> // CHECK: [ B4 ]
>> @@ -351,8 +345,7 @@
>> // CHECK: Successors (1): B7
>> // CHECK: [ B9 ]
>> // CHECK: 1: ~A() (Temporary object destructor)
>> -// CHECK: 2: ~A() (Temporary object destructor)
>> -// CHECK: 3: ~B() (Temporary object destructor)
>> +// CHECK: 2: ~B() (Temporary object destructor)
>> // CHECK: Predecessors (1): B10
>> // CHECK: Successors (1): B7
>> // CHECK: [ B10 ]
>> @@ -392,7 +385,6 @@
>> // 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 ]
>> @@ -426,7 +418,6 @@
>> // 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 ]
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101113/a1f50459/attachment.html>
More information about the cfe-commits
mailing list