Parsing field types from ClassTemplateSpecializationDecl

Hello,

I’m trying to parse fields of an explicitly instantiated template, like this:

Not sure if I understand correctly, but you specialize your template
without any fields in your example.

What you want to do is I think:

   template class Foo<float>;

which yields the correct result for me:

teemperor@ftlserver ~/test> cat test.cpp
template <class T>
class Foo
{
       T bar;
};

template class Foo<float>;
teemperor@ftlserver ~/test> clang++ -cc1 -fcolor-diagnostics -ast-dump
-x c++ test.cpp
TranslationUnitDecl 0x5578e347d9a0 <<invalid sloc>> <invalid sloc>

-TypedefDecl 0x5578e347df30 <<invalid sloc>> <invalid sloc> implicit

__int128_t '__int128'

`-BuiltinType 0x5578e347dc10 '__int128'
-TypedefDecl 0x5578e347df98 <<invalid sloc>> <invalid sloc> implicit

__uint128_t 'unsigned __int128'

`-BuiltinType 0x5578e347dc30 'unsigned __int128'
-TypedefDecl 0x5578e347e2d8 <<invalid sloc>> <invalid sloc> implicit

__NSConstantString 'struct __NSConstantString_tag'

`-RecordType 0x5578e347e080 'struct __NSConstantString_tag'
  `-CXXRecord 0x5578e347dfe8 '__NSConstantString_tag'
-TypedefDecl 0x5578e347e370 <<invalid sloc>> <invalid sloc> implicit

__builtin_ms_va_list 'char *'

`-PointerType 0x5578e347e330 'char *'
  `-BuiltinType 0x5578e347da30 'char'
-TypedefDecl 0x5578e34b2320 <<invalid sloc>> <invalid sloc> implicit

__builtin_va_list 'struct __va_list_tag [1]'

`-ConstantArrayType 0x5578e347e650 'struct __va_list_tag [1]' 1
  `-RecordType 0x5578e347e460 'struct __va_list_tag'
    `-CXXRecord 0x5578e347e3c0 '__va_list_tag'
-ClassTemplateDecl 0x5578e34b24b8 <test.cpp:1:1, line:5:1> line:2:7 Foo
>-TemplateTypeParmDecl 0x5578e34b2370 <line:1:11, col:17> col:17

referenced class T

>-CXXRecordDecl 0x5578e34b2420 <line:2:1, line:5:1> line:2:7 class

Foo definition

> >-CXXRecordDecl 0x5578e34b2728 <col:1, col:7> col:7 implicit class Foo
> `-FieldDecl 0x5578e34b27d0 <line:4:2, col:4> col:4 bar 'T'
`-ClassTemplateSpecialization 0x5578e34b2850 'Foo'

`-ClassTemplateSpecializationDecl 0x5578e34b2850 <line:7:1, col:25>
col:16 class Foo definition
>-TemplateArgument type 'float'
>-CXXRecordDecl 0x5578e34b2a48 prev 0x5578e34b2850 <line:2:1, col:7>
col:7 implicit class Foo
`-FieldDecl 0x5578e34b2b18 <line:4:2, col:4> col:4 bar 'float':'float'

- Raphael

You are right, embarrassingly my test case was incorrectly written, it works now. Thank you.