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

Richard Smith richard at metafoo.co.uk
Mon Dec 26 09:00:22 PST 2011


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

- Richard




More information about the cfe-dev mailing list