[cfe-dev] Parsing field types from ClassTemplateSpecializationDecl

Marko Pintera via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 19 07:30:40 PDT 2017


Hello,

I'm trying to parse fields of an explicitly instantiated template, like
this:
~~~
template <class T>
class Foo
{
T bar;
};

template<> class Foo<float>;
~~~

In the example above, I'd like to know that "Foo<float>" has a field "bar"
of type "float".

I am able to access "ClassTemplateSpecializationDecl" of "Foo<float>", but
it reports no fields. It does contain a list of template arguments (a
"float" for the specific example above), but since there are no fields I am
unsure how to interpret them.

I can also access "CXXRecordDecl" of "Foo<T>" by calling
"ClassTemplateSpecializationDecl::getSpecializedTemplate()->GetTemplatedDecl()".
This does report the "bar" field, but I do not appear to have information
about its actual type from the explicit instantiation.

How can I learn the type of "bar" in an explicit instantiation of "Foo<T>"?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170719/803d26fa/attachment.html>


More information about the cfe-dev mailing list