[cfe-dev] CXCursor_CXXBaseSpecifier for template instantiated base class

Jusufadis Bakamovic via cfe-dev cfe-dev at lists.llvm.org
Sun Mar 12 00:46:15 PST 2017


You should be getting three times the `CXCursor_CXXBaseSpecifier`, one for
each class you're inheriting from. I ran the analysis on my machine (clang
3.8) and that is exactly what I am getting: `RecursiveBase<class Base>`,
`Base2`, `Base3`. Maybe you could use `clang -Xclang -ast-dump
-fsyntax-only <this_demo>` to see the output of Clang's built-in AST
dumper. It should contain these entries. Otherwise, clang version you're
running might be an older one.

On 12 March 2017 at 05:09, Nestal Wan via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> Hi,
>
> When I use clang_visitChildren() to visit a class, I can't get a
> CXCursor_CXXBaseSpecifier for its base class if the base class is a
> template. For example:
>
> template <typename BaseType>
> class RecursiveBase : public BaseType
> {
> public:
>    virtual void SomeFunc()
>    {
>       // prevent optimizer to remove the function
>       global_var++;
>    }
> };
>
> class Derived : public RecursiveBase<Base>, public Base2, public Base3
> {
> public:
>    Derived() = default;
>
>    void Func() override {}
> };
>
> I can get a CXCursor_CXXBaseSpecifier cursor as children of the
> "Derived" cursor, but not RecursiveBase. How can I find out references
> to all base classes including templates?
>
> Thanks.
>
> Nestal
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170312/4f2ce385/attachment.html>


More information about the cfe-dev mailing list