<div dir="ltr"><div style="font-size:12.8px">It is hard to tell without more context why you're getting this error, but my guess is that you're missing some command line args (i.e. include paths, preprocessor flags, etc.) which is specific to the code you're analyzing and which is required in order to get the parsing stage done right. Very often this is the case and which is why you should, whenever you have doubts, always try to come up with a small reproducible example (without dependencies) and have it validated separately.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Additionally, you can try to extract diagnostics for the given translation unit and see if you get any hints there. Normally, you should get hints if clang parser was not able to fully parse the source code because it was missing some information such as failing to find particular headers.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Cheers,</div><div style="font-size:12.8px">Adi</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 March 2017 at 10:13, Nestal Wan <span dir="ltr"><<a href="mailto:me@nestal.net" target="_blank">me@nestal.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the reply.<br>
<br>
-CXXRecordDecl 0x55e6db0f5ad8 <line:53:1, line:59:1> line:53:7 invalid class<br>
Derived definition<br>
<br>
| |-public 'class Base2'<br>
| |-public 'class Base3'<br>
| |-CXXRecordDecl 0x55e6db0f5df8 <col:1, col:7> col:7 implicit referenced<br>
<br>
class Derived<br>
<br>
| |-AccessSpecDecl 0x55e6db0f5e88 <line:55:1, col:7> col:1 public<br>
| |-CXXConstructorDecl 0x55e6db0f5ef0 <line:56:2, col:20> col:2 Derived 'void<br>
<br>
(void)' noexcept-unevaluated 0x55e6db0f5ef0<br>
<br>
| `-CXXMethodDecl 0x55e6db0f5fd0 <line:58:2, col:24> col:7 Func 'void (void)'<br>
| `-CompoundStmt 0x55e6db0f6118 <col:23, col:24><br>
<br>
<br>
Sometimes I got "invalid class Derived definition", but if I extract the<br>
classes in another source file, the result is different:<br>
<br>
|-CXXRecordDecl 0x55ccfcb583b0 <line:33:1, line:39:1> line:33:7 class Derived<br>
<br>
definition<br>
<br>
| |-public 'RecursiveBase<class Base>':'class RecursiveBase<class Base>'<br>
| |-public 'class Base2'<br>
| |-public 'class Base3'<br>
| |-CXXRecordDecl 0x55ccfcb58c70 <col:1, col:7> col:7 implicit referenced<br>
<br>
class Derived<br>
<br>
What does it mean the class definition is invalid? There is no compile error.<br>
<span class="HOEnZb"><font color="#888888"><br>
Nestal<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Sun, Mar 12, 2017 at 4:46 PM, Jusufadis Bakamovic <<a href="mailto:jbakam@gmail.com">jbakam@gmail.com</a>> wrote:<br>
> You should be getting three times the `CXCursor_CXXBaseSpecifier`, one for<br>
> each class you're inheriting from. I ran the analysis on my machine (clang<br>
> 3.8) and that is exactly what I am getting: `RecursiveBase<class Base>`,<br>
> `Base2`, `Base3`. Maybe you could use `clang -Xclang -ast-dump -fsyntax-only<br>
> <this_demo>` to see the output of Clang's built-in AST dumper. It should<br>
> contain these entries. Otherwise, clang version you're running might be an<br>
> older one.<br>
><br>
> On 12 March 2017 at 05:09, Nestal Wan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> When I use clang_visitChildren() to visit a class, I can't get a<br>
>> CXCursor_CXXBaseSpecifier for its base class if the base class is a<br>
>> template. For example:<br>
>><br>
>> template <typename BaseType><br>
>> class RecursiveBase : public BaseType<br>
>> {<br>
>> public:<br>
>>    virtual void SomeFunc()<br>
>>    {<br>
>>       // prevent optimizer to remove the function<br>
>>       global_var++;<br>
>>    }<br>
>> };<br>
>><br>
>> class Derived : public RecursiveBase<Base>, public Base2, public Base3<br>
>> {<br>
>> public:<br>
>>    Derived() = default;<br>
>><br>
>>    void Func() override {}<br>
>> };<br>
>><br>
>> I can get a CXCursor_CXXBaseSpecifier cursor as children of the<br>
>> "Derived" cursor, but not RecursiveBase. How can I find out references<br>
>> to all base classes including templates?<br>
>><br>
>> Thanks.<br>
>><br>
>> Nestal<br>
>> ______________________________<wbr>_________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
><br>
><br>
</div></div></blockquote></div><br></div>