[PATCH] [ms-cxxabi] Destroy temporary record arguments in the callee

Richard Smith richard at metafoo.co.uk
Mon Jun 10 13:55:29 PDT 2013


On Mon, Jun 10, 2013 at 12:58 PM, Reid Kleckner <rnk at google.com> wrote:
> On Mon, Jun 10, 2013 at 1:29 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>>
>>
>>   You're likely to need a Sema change to ensure that a destructor for the
>> parameter type is implicitly declared (if needed) in the TU containing the
>> caller (otherwise IR generation will probably crash or assert when trying to
>> emit a call to it).
>
>
> I think I solved this with a forthcoming patch.
>
>>
>>   You'll presumably also need either a Sema change or a CodeGen change to
>> ensure that a definition of the destructor ends up in the program -- either
>> mark the dtor as used in the TU containing the callee (which is likely to
>> match MSVC but is non-conforming), or demote it from linkonce_odr to
>> weak_odr in the TU containing the call (which is conforming but may hinder
>> inlining etc).
>
>
> What's wrong with marking the dtor as used?  You need a full class
> definition to take a class by value, right?

For a destructor in a class template, there may be no point of
instantiation for that destructor in the TU containing the function
definition. I don't think we really need to care about this too much,
though, since this problem will exist regardless for code like:

  struct A { ~A(); };
  void f(A) {}

... which will need a definition of ~A whether or not this function is
ever called.



More information about the cfe-commits mailing list