[cfe-dev] Why is an out-of-line ctor isInlined?

Xu Zhongxing xu_zhong_xing at 163.com
Mon Dec 26 17:23:22 PST 2011



于 2011/12/27 1:00, Richard Smith 写道:
> On Mon, December 26, 2011 03:07, Xu Zhongxing wrote:
>> For the following code,
>>
>> class A { int x; public:
>> A(int);
>> ~A();
>> };
>>
>>
>> void f() { A a(1);
>> }
>>
>>
>> FunctionDecl::isInlined() returns true for A's ctor A(int), because it
>> is a CXXMethodDecl and it is not out-of-line. This is the implementation of
>> isOutOfLine()
>>
>> virtual bool isOutOfLine() const { return getLexicalDeclContext() !=
>> getDeclContext(); }
>>
>>
>> I suspect the logic is not correct for a CXXMethodDecl.
> Decl::isOutOfLine is missing documentation, so it's hard to be sure what the
> intent is -- it may be intended to apply to this declaration of the function
> (for which it gives correct answers) rather than to the function in general.
> You can get the behavior you want by asking the definition of the function
> (and assuming that functions with no definition are out-of-line).
It's ok for isOutOfLine() to have this sematic. But the logic for 
FunctionDecl::isInlined() might not be appropriate.





More information about the cfe-dev mailing list