[cfe-dev] clang_visitChildren skips template parameters of non-class type
Matthieu Nottale
matthieu at nottale.net
Thu Jul 25 00:48:33 PDT 2013
On 2013-07-25 09:35, Jacob Carlborg wrote:
> On 2013-07-24 10:45, Matthieu Nottale wrote:
>>
>> 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?
>
> I'm not sure if this is the problem, but as far as I can recall you
> cannot get the spelling of a built in type. I just created a function
> with a switch-statement that returns the spelling for built in types.
Here I can't figure out how to access a CXType or CXCursor for the
"char" I expect, this is a different issue I think.
More information about the cfe-dev
mailing list