[cfe-dev] CXCursor_CXXBaseSpecifier for template instantiated base class
Nestal Wan via cfe-dev
cfe-dev at lists.llvm.org
Sun Mar 12 01:13:07 PST 2017
Thanks for the reply.
-CXXRecordDecl 0x55e6db0f5ad8 <line:53:1, line:59:1> line:53:7 invalid class
Derived definition
| |-public 'class Base2'
| |-public 'class Base3'
| |-CXXRecordDecl 0x55e6db0f5df8 <col:1, col:7> col:7 implicit referenced
class Derived
| |-AccessSpecDecl 0x55e6db0f5e88 <line:55:1, col:7> col:1 public
| |-CXXConstructorDecl 0x55e6db0f5ef0 <line:56:2, col:20> col:2 Derived 'void
(void)' noexcept-unevaluated 0x55e6db0f5ef0
| `-CXXMethodDecl 0x55e6db0f5fd0 <line:58:2, col:24> col:7 Func 'void (void)'
| `-CompoundStmt 0x55e6db0f6118 <col:23, col:24>
Sometimes I got "invalid class Derived definition", but if I extract the
classes in another source file, the result is different:
|-CXXRecordDecl 0x55ccfcb583b0 <line:33:1, line:39:1> line:33:7 class Derived
definition
| |-public 'RecursiveBase<class Base>':'class RecursiveBase<class Base>'
| |-public 'class Base2'
| |-public 'class Base3'
| |-CXXRecordDecl 0x55ccfcb58c70 <col:1, col:7> col:7 implicit referenced
class Derived
What does it mean the class definition is invalid? There is no compile error.
Nestal
On Sun, Mar 12, 2017 at 4:46 PM, Jusufadis Bakamovic <jbakam at gmail.com> wrote:
> 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
>
>
More information about the cfe-dev
mailing list