PATCH: don't mark pure derived method odr because of a qualified call to base method

Nick Lewycky nlewycky at google.com
Wed Feb 13 15:40:06 PST 2013


On 13 February 2013 00:53, Nick Lewycky <nlewycky at google.com> wrote:

> Thinking about this issue more, I'd like to retract this patch. Consider
> the case where we're implementing the rule that all ODR-used inline
> functions must have a definition. If Derived::fn is marked inline, we'll
> see a fictitious use of it and reject a valid translation unit.
>

Richard talked with me a minute ago and convinced me that this case is
impossible (notably, the inline function would need to be pure virtual) and
that the original patch I sent out is in fact correct.

Nick

My next plan is to remove this code from Sema entirely and do the
> equivalent work inside codegen proper. No reason it can't keep track of
> probable virtual function targets when writing out a virtual dispatch.
>
> Nick
>
>
> On 12 February 2013 19:30, Nick Lewycky <nlewycky at google.com> wrote:
>
>> I failed to produce a concise explanation of the patch, so I'll lead off
>> with the testcase:
>>
>>   struct Base { virtual void fn() { } };
>>   struct Derived : public Base { virtual void fn() = 0;
>>     void test() { Base::fn(); /* triggers an ODR-use of Derived::fn() */ }
>>   };
>>
>> This is because we repurpose the odr bit on virtual functions to mean "it
>> would be convenient for codegen to emit this", to help devirtualization for
>> instance. This is implemented in Sema with a scan through all known derived
>> classes when building a member expression, in this case "this->Base::fn".
>> This patch makes that scan skip pure methods.
>>
>> Patch attached, please review.
>>
>> Nick
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130213/add2366e/attachment.html>


More information about the cfe-commits mailing list