[cfe-dev] CXCursor_CXXBaseSpecifier for template instantiated base class

Jusufadis Bakamovic via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 16 13:05:58 PDT 2017


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?

Yes, that's right. `CXCursor_TypeRef` is going to be a child of
`CXCursor_CXXBaseSpecifier` cursor.

But I would advise you to make yourself a big favor and write a simple AST
traversal function which dumps _all_ the information you can extract from
cursors. Clang built-in AST dump is a good one but does not contain every
bit of information which might be quite important while you're debugging or
developing a new specific use-case which, for example, is not covered by
libclang API. Given you have such debugging tool you would immediately see
that `CXCursor_TypeRef`s are descendants of `CXCursor_CXXBaseSpecifier`
cursors as well as many other similar details for other use-cases.

I've developed such debugging tool for myself and you can have a look at it
to get some inspiration:
    *
https://github.com/JBakamovic/yavide/blob/clang_indexer/core/services/parser/clang_parser.py#L332

On Fri, Mar 17, 2017 at 3:01 AM, Michael <redm at gmx.de> wrote:
> Well, at least for me it didn't really help, it did not do what I would
have
> expected it to do... i.e. return the specialized versions of the template,
> "RecursiveBase<Base>" and more importantly it's base "Base" in your
example.

How come? This is the AST representation of that piece of code (reads as
CursorKind : CursorSpelling):

|-`CXCursor_ClassDecl`: 'Derived'
|    |-`CXCursor_CXXBaseSpecifier`: 'RecursiveBase<class Base>'
|        |-`CXCursor_TemplateRef`: 'RecursiveBase'
|        |-`CXCursor_TypeRef`: 'class Base'
|    |-`CXCursor_CXXBaseSpecifier`: 'class Base2'
|       |-`CXCursor_TypeRef`: 'class Base2'
|    |-`CXCursor_CXXBaseSpecifier`: 'class Base3'
|        |-`CXCursor_TypeRef`: 'class Base3'

Cheers,
Adi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170316/6bec98bd/attachment.html>


More information about the cfe-dev mailing list