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

Enea Zaffanella zaffanella at cs.unipr.it
Wed Apr 21 12:20:05 PDT 2010


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.

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

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?

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

Enea Zaffanella.

More information about the cfe-dev mailing list