[cfe-dev] clang_visitChildren skips template parameters of non-class type

Matthieu Nottale matthieu at nottale.net
Wed Jul 24 01:45:17 PDT 2013


Hi.

With llvm/clang trunk, I'm having an issue when visiting template type 
instanciation using the C API clang_visitChildren: I only see template 
parameters of class type, not of basic type.

With this code:



   template<typename A, typename B> struct TemplB{};
   class Bar {};

   int boz(TemplB<char, Bar>);
   int boz2(TemplB<Bar, char>);




I get the following with visitChildren (using a visitor that dump 
kindSpelling, spelling and recurse with indent:

TypedefDecl __builtin_va_list
ClassTemplate TemplB
   TemplateTypeParameter A
   TemplateTypeParameter B
ClassDecl Bar
FunctionDecl boz
   ParmDecl
     TemplateRef TemplB
     TypeRef class Bar
FunctionDecl boz2
   ParmDecl
     TemplateRef TemplB
     TypeRef class Bar


As you can see there is a node for the Bar template parameter, but none 
for the char.

I can access the CXType from the ParmDecl node, but I see no CXType API 
that could get me the template parameters.

clang_getCursorReferenced of the ParmDecl node is itself.

clang_getTypeDeclaration of the type given by clang_getCursorType is a 
StructDecl node with no children (with or without a 
clang_getCanonicalType)

Is this a bug?

Is there a way I overlooked to access the missing template parameter?

Cheers,

   Matthieu




More information about the cfe-dev mailing list