<html>
<head></head>
<body>
<p>Hi,</p>
<p>As I was already suspecting, I overlooked something:</p>
<p>bool MyClass::VisitCXXRecordDecl(CXXRecordDecl *Declaration) {<br /> if(!(Declaration->hasDefinition()))<br /> <strong>return false;</strong><br /> allClasses.push_back(Declaration);<br /> return true;<br />}</p>
<p>I was returning false in this method, so it stopped traversing the tree. Sorry for the mistake.</p>
<p>However, by the way, I am still interested in knowing how can I fix the problem of the missing header.</p>
<p>Pedro.</p>
<br/>
<div><em>El día 27 ene 2014 14:04, Pedro Delgado Perez <pedro.delgadoperez@mail.uca.es> escribió:</em></div><blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p>Hi,<br /><br />This is part of my code using TraverseDecl:</p>
<p>list<const CXXRecordDecl*> allClasses;</p>
<p>void MyClass::HandleTranslationUnit(ASTContext &Context) {<br /> TranslationUnitDecl *D = Context.getTranslationUnitDecl();<br /> // Run Recursive AST Visitor<br /> TraverseDecl(D);<br />}<br /><br />bool MyClass::VisitCXXRecordDecl(CXXRecordDecl *Declaration) {<br /> if(!(Declaration->hasDefinition()))<br /> return false;<br /> allClasses.push_back(Declaration);<br /> return true;<br />}<br /> <br /><br />And I use them in this way:<br /><br />void MyClass::run(const MatchFinder::MatchResult &Result) { <br /><br /> Context = Result.Context;<br /> ...<br /> HandleTranslationUnit(*Context);<br /> <br /> if(!allClasses.empty()){<br /> <br /> for(list<const CXXRecordDecl*>::const_iterator i = allClasses.begin(); i != allClasses.end(); i++){<br /> <br /> const CXXRecordDecl *BaseClass = *i;<br /> ...<br /> }<br /> }<br />}</p>
<p>Well, up to now I have been using this with simple fragments of code, and it was working perfectly. But then, I tested a file with the header "iostream" and:<br /><br />1. First, I got this at the beginning</p>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p>In file included from /home/pedro/prueba_op.cpp:1:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/iostream:40:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/ostream:40:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/ios:39:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/iosfwd:42:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/postypes.h:42:<br />In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/cwchar:46:<br />/usr/include/wchar.h:40:11: fatal error: 'stdarg.h' file not found<br /># include <stdarg.h></p>
</blockquote><p><br />This hasn't been a problem so far, but I was wondering how I can avoid that message.</p>
<p>2. Second, when I include this header, the classes in my file are not visited with TraverseDecl, in spite of they are in the same TranslationUnitDecl; it only processes some classes in the header, as _Rep or basic_ios... Does anybody know what can be the problem? Maybe is a detail that I am overlooking, but I'm not able to find the solution.</p>
<p>Thanks in advance,</p>
<p>Pedro.</p>
</blockquote>
</body>
</html>