[cfe-dev] CXCursor_CXXBaseSpecifier for template instantiated base class
Nestal Wan via cfe-dev
cfe-dev at lists.llvm.org
Thu Mar 16 11:42:27 PDT 2017
Looking at the ast-dump, I think I want to get a cursor to this node:
ClassTemplateSpecializationDecl 0x557ff8ef4e10 <line:16:1, line:25:1>
line:17:7 class RecursiveBase definition
The dump indicates it to be under:
ClassTemplateDecl 0x557ff8eed798 <line:16:1, line:25:1> line:17:7 RecursiveBase
But I can't see this ClassTemplateSpecializationDecl to be a child of
the CXCursor_ClassTemplate. Am I missing something here?
Does the CXCursor_ClassTemplate cursor corresponds to the
ClassTemplateSpecializationDecl in the AST dump?
Many thanks!
On Fri, Mar 17, 2017 at 2:16 AM, Nestal Wan <me at nestal.net> wrote:
> Thanks, Adi! Do you mean that CXCursor_TypeRef is a child under the
> CXCursor_CXXBaseSpecifier?
>
> On Fri, Mar 17, 2017 at 1:10 AM, Jusufadis Bakamovic <jbakam at gmail.com> wrote:
>> Hi Nestal,
>>
>> I am not sure if I understood you correctly but you want to find out the
>> structure/hierarchy of your "Derived" class, that is all of the base classes
>> that your derived class is inheriting from? If this is what you are asking
>> for, then you can accomplish this by enumerating all of the
>> `CXCursor_TypeRef`'s of corresponding `CXCursor_CXXBaseSpecifier` cursors
>> which are descendants (children) of class declaration (`CXCursor_ClassDecl`)
>> which you're interested in (i.e. "Derived").
>>
>> When parser is run on your example, `CXCursor_CXXBaseSpecifier` cursors are
>> `RecursiveBase<class Base>`, `class Base2` and `class Base3`. Corresponding
>> `CXCursor_TypeRef` cursors are `class Base`, `class Base2` and `class
>> Base3`. This is what I believe you're looking for.
>>
>> For a generic and full-proof solution, you will want to do the same thing
>> recursively for each `CXCursor_CXXBaseSpecifier` found.
>>
>> Cheers,
>> Adi
More information about the cfe-dev
mailing list