I've got an AST visitor defined with the following method:<br><br><div>class MyASTVisitor : public RecursiveASTVisitor<MyASTVisitor></div><div>{</div><div><br></div><div>...</div><div>   bool VisitCXXRecordDecl( CXXRecordDecl* r )<br>
</div><div>   {</div><div>      cout << "VisitCXXRecordDecl:: CLASS: " << r->getName().str() << endl ;</div>
<div><br></div><div>      for ( CXXRecordDecl::base_class_iterator b = r->bases_begin(), e = r->bases_end() ;</div><div>            b != e ; ++b )</div><div>      {</div><div>         CXXBaseSpecifier & a = *b ;</div>

<div><br></div><div>         const QualType & q = a.getType() ;</div><div><br></div><div>         cout << r->getName().str() << " : " << q.getAsString() << endl ;</div><div>      }<br>

</div><div><br></div><div>      return true ;</div><div>   }</div><div><br></div><div>This is triggering the following assertion:</div><div><br></div><div><div>classvisitor: /home/peeterj/clang/optimized/include/clang/AST/DeclCXX.h:522: struct DefinitionData &clang::CXXRecordDecl::data(): Assertion `DefinitionData && "queried property of class with no definition"' failed.</div>

<div><br></div><div>Program received signal SIGABRT, Aborted.</div><div>0x00007ffff6f20645 in raise () from /lib64/libc.so.6</div><div>(gdb) where</div><div>#0  0x00007ffff6f20645 in raise () from /lib64/libc.so.6</div><div>

#1  0x00007ffff6f21c33 in abort () from /lib64/libc.so.6</div><div>#2  0x00007ffff6f19329 in __assert_fail () from /lib64/libc.so.6</div><div>#3  0x0000000000467b85 in clang::CXXRecordDecl::data (this=0x155f740) at /home/peeterj/clang/optimized/include/clang/AST/DeclCXX.h:522</div>

<div>#4  0x0000000000467ade in clang::CXXRecordDecl::bases_begin (this=0x155f740) at /home/peeterj/clang/optimized/include/clang/AST/DeclCXX.h:640</div><div>#5  0x00000000004681af in MyASTVisitor::VisitCXXRecordDecl (this=0x7fffffff8f70, r=0x155f740) at classvisitor.cpp:61</div>

<div>#6  0x0000000000467ffa in clang::RecursiveASTVisitor<MyASTVisitor>::WalkUpFromCXXRecordDecl (this=0x7fffffff8f70, D=0x155f740)</div><div>    at /home/peeterj/clang/optimized/include/clang/AST/DeclNodes.inc:207</div>

<div>#7  0x000000000041f13f in clang::RecursiveASTVisitor<MyASTVisitor>::TraverseCXXRecordDecl (this=0x7fffffff8f70, D=0x155f740)</div><div>    at /home/peeterj/clang/optimized/include/clang/AST/RecursiveASTVisitor.h:1586</div>

<div>#8  0x000000000041d0f9 in clang::RecursiveASTVisitor<MyASTVisitor>::TraverseDecl (this=0x7fffffff8f70, D=0x155f740)</div><div>    at /home/peeterj/clang/optimized/include/clang/AST/DeclNodes.inc:207</div><div>
#9  0x000000000041c7f4 in MyASTConsumer::HandleTopLevelDecl (this=0x7fffffff8f60, DR=...) at classvisitor.cpp:122</div>
<div>#10 0x0000000000612c75 in clang::ParseAST(clang::Sema&, bool, bool) ()</div><div>#11 0x0000000000612f70 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, clang::TranslationUnitKind, clang::CodeCompleteConsumer*, bool) ()</div>

<div>#12 0x0000000000419b31 in main (argc=77, argv=0x7fffffffd008) at classvisitor.cpp:314</div><div>(gdb) frame 5</div><div>#5  0x00000000004681af in MyASTVisitor::VisitCXXRecordDecl (this=0x7fffffff8f70, r=0x155f740) at classvisitor.cpp:61</div>

<div>61            for ( CXXRecordDecl::base_class_iterator b = r->bases_begin(), e = r->bases_end() ;</div><div>(gdb) p *r</div><div>$1 = {<clang::RecordDecl> = {<clang::TagDecl> = {<clang::TypeDecl> = {<clang::NamedDecl> = {<clang::Decl> = {_vptr$Decl = 0x132a350,</div>

<div>            NextInContextAndBits = {Value = 0}, DeclCtx = {Val = {Value = 20481056}}, Loc = {ID = 1203259}, DeclKind = 25, InvalidDecl = 0,</div><div>            HasAttrs = 0, Implicit = 0, Used = 0, Referenced = 0, Access = 3, FromASTFile = 0, Hidden = 0, IdentifierNamespace = 6,</div>

<div>            HasCachedLinkage = 0, CachedLinkage = 0}, Name = {Ptr = 22363280}}, TypeForDecl = 0x155f7d0, LocStart = {</div><div>          ID = 1203253}}, <clang::DeclContext> = {DeclKind = 25, ExternalLexicalStorage = 0, ExternalVisibleStorage = 0, LookupPtr = {Value = 0},</div>

<div>        FirstDecl = 0x0, LastDecl = 0x0}, <clang::Redeclarable<clang::TagDecl>> = {RedeclLink = {NextAndIsPrevious = {Value = 22411074}}},</div><div>      TagDeclKind = 3, IsCompleteDefinition = false, IsBeingDefined = false, IsEmbeddedInDeclarator = false, IsFreeStanding = true,</div>

<div>      NumPositiveBits = 0, NumNegativeBits = 0, IsScoped = false, IsScopedUsingClassTag = false, IsFixed = false, RBraceLoc = {ID = 0},</div><div>      TypedefNameDeclOrQualifier = {Val = {Value = 0}}}, HasFlexibleArrayMember = false, AnonymousStructOrUnion = false, HasObjectMember = false,</div>

<div>    LoadedFieldsFromExternalStorage = false}, DefinitionData = 0x0, TemplateOrInstantiation = {Val = {Value = 0}}}</div></div><div><br></div><div>Is it appropriate for me to be attempting to iterate over the base classes in this CXXRecordDecl() override, or is this a bug in the AST visitor library?</div>

<div><br></div><div><div>$ ~/clang/optimized/bin/clang --version</div><div><br></div><div>clang version 3.3 (trunk 169628)</div><div>Target: x86_64-unknown-linux-gnu</div><div>Thread model: posix</div></div><div><br></div>
<div>-- <br></div>Peeter<br>