[cfe-dev] [Lifetime, Temporary] Generate ExprWithCleanups for trivially destructible tempoararies

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Tue May 3 16:49:46 PDT 2016


On Tue, May 3, 2016 at 4:35 PM, Tim Shen via cfe-dev <cfe-dev at lists.llvm.org
> wrote:

> On Thu, Apr 28, 2016 at 11:54 AM Richard Smith wrote:
>
>> but not to do this:
>>
>> 1) call ~B()
>> 2) end lifetime of B temporary
>> 3) end lifetime of int temporary
>> 4) call ~A()
>> 5) end lifetime of A temporary
>>
>
> Does this apply to non-temporaries?
>

Yes.


> For:
>
> struct A { ~A(); };
> struct B { ~B(); };
> void Bar(int&);
> void Foo() {
>   B b;
>   int c;
>   A a;
>   Bar(c);
> }
>
> Today Clang generates:
>   call void @_ZN1AD1Ev(%struct.A* nonnull %a) #4
>   call void @llvm.lifetime.end(i64 1, i8* %2) #4
>   call void @llvm.lifetime.end(i64 4, i8* %1) #4
>   call void @_ZN1BD1Ev(%struct.B* nonnull %b) #4
>   call void @llvm.lifetime.end(i64 1, i8* %0) #4
>
> which is exactly what we want to avoid for now.
>

Yep, this is technically a bug. (As mentioned, I'm working on getting the
standard fixed to be a bit less ridiculous here. We'll see how that goes.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160503/d69efa60/attachment.html>


More information about the cfe-dev mailing list