[cfe-dev] Template parameters for out-of-line definitions of class template methods.

Douglas Gregor dgregor at apple.com
Thu Apr 22 07:11:01 PDT 2010

On Apr 21, 2010, at 12:20 PM, Enea Zaffanella wrote:

> Hello.
> We have a somewhat naive question regarding the AST generated for the 
> following program fragment:
> ======================================
> template <typename T>
> struct S {
>   void foo();
> };
> template <class W>
> void S<W>::foo() {}
> ======================================
> We would like to retrieve the template parameter list for the 
> out-of-line definition of method foo(), that is
>   template <class W>
> but we cannot see if and how this could be achieved.

Clang's AST doesn't actually store the template parameter list that was used in the out-of-line definition. It should.

> Apparently, clang++ produces a plain CXXMethodDecl, with no explicit 
> indication that this is actually a "member function template" (C++98 

Technically, it's a member function of a class template. 

> Are we missing some existing clang methods that allow to retrieve this 
> info or is it really missing? In the latter case, is there any plan to 
> add this info to the generated AST?

It is missing, and we will add this info to the generated AST at some point. 

> The same question can be asked for the case of an out-of-line definition 
> of a static data member (which generates a VarDecl node) and of a member 
> class (generating a plain CXXRecordDecl).

Right, this is the same kind of issue. We're missing this information for out-of-line definitions of everything.

	- Doug

More information about the cfe-dev mailing list