[LLVMdev] Inline hint for methods defined in-class

Xinliang David Li davidxl at google.com
Wed Jun 24 18:10:34 PDT 2015


On Wed, Jun 24, 2015 at 4:49 PM, Duncan P. N. Exon Smith
<dexonsmith at apple.com> wrote:
>
>> On 2015 Jun 24, at 14:58, Xinliang David Li <davidxl at google.com> wrote:
>>
>> On Wed, Jun 24, 2015 at 2:52 PM, Robinson, Paul
>> <Paul_Robinson at playstation.sony.com> wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Xinliang David Li [mailto:davidxl at google.com]
>>>> Sent: Wednesday, June 24, 2015 2:50 PM
>>>> To: Robinson, Paul
>>>> Cc: Easwaran Raman; Xinliang David Li; <llvmdev at cs.uiuc.edu> List
>>>> Subject: Re: [LLVMdev] Inline hint for methods defined in-class
>>>>
>>>> Sorry for misinterpreting, but what is the basis for the simple fact
>>>> you mentioned?
>>>
>>> The patch causes all in-class-defined methods to be treated as if
>>> they had the 'inline' keyword attached.
>>> Therefore, with the patch, explicitly adding the 'inline' keyword to
>>> these methods has no effect; it becomes noise.
>>
>> I agree the noise can come from template class template functions
>> where users do not have a choice.  There should ways to detect those
>> and filter them out.
>
> Users do have a choice, even for template functions.

What I really meant is that user does not have choice but to put defs
inside headers. You are totally right that users do have the following
choices even for template functions:

1) in-class definition without inline keyword
2) in-class definition with inline keyword
3) out of line/class definition with inline keyword
4) out of line definition without inline keyword

>
>     template <class T> struct Foo {
>       void thisIsInline() {}
>       void thisIsNotInline();
>       template <class U> void thisIsInlineToo() {}
>       template <class U> void thisIsNotInlineEither();
>     };
>     template <class T> void Foo<T>::thisIsNotInline() {}
>     template <class T>
>     template <class U>
>     void Foo<T>::thisIsNotInlineEither() {}
>
> An `inline` keyword on a function defined inline in a class has always
> looked like noise to me.

yes.

>
> I think adding the `inline` keyword to methods defined inline in a class
> *should* have no effect.  (Maybe this is just bias from having used GCC
> for years?)

Agree. Sine adding inline keyword to in-class defs is a no-op
essentially, the in-class definition with 'inline' hint is expected.

David



More information about the llvm-dev mailing list