[LLVMdev] Inline hint for methods defined in-class

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jun 24 16:49:11 PDT 2015


> 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.

    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.

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?)



More information about the llvm-dev mailing list