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

Tim Shen via cfe-dev cfe-dev at lists.llvm.org
Tue May 3 16:35:53 PDT 2016


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? 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160503/6cddc4c1/attachment.html>


More information about the cfe-dev mailing list