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

David Blaikie dblaikie at gmail.com
Wed Feb 13 08:03:11 PST 2013


On Feb 13, 2013 12:55 AM, "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.

Would it be worth/possible to add a test case to that effect (I assume
there isn't one already or you would've noticed when you were developing
this patch)?

>
> 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
>>
>
>
> _______________________________________________
> 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/20130213/6511ea5e/attachment.html>


More information about the cfe-commits mailing list