[cfe-dev] TraverseDecl: a problem with a header
Pedro Delgado Perez
pedro.delgadoperez at mail.uca.es
Mon Jan 27 05:04:18 PST 2014
Hi,
This is part of my code using TraverseDecl:
list<const CXXRecordDecl*> allClasses;
void MyClass::HandleTranslationUnit(ASTContext &Context) {
TranslationUnitDecl *D = Context.getTranslationUnitDecl();
// Run Recursive AST Visitor
TraverseDecl(D);
}
bool MyClass::VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
if(!(Declaration->hasDefinition()))
return false;
allClasses.push_back(Declaration);
return true;
}
And I use them in this way:
void MyClass::run(const MatchFinder::MatchResult &Result) {
Context = Result.Context;
...
HandleTranslationUnit(*Context);
if(!allClasses.empty()){
for(list<const CXXRecordDecl*>::const_iterator i = allClasses.begin(); i != allClasses.end(); i++){
const CXXRecordDecl *BaseClass = *i;
...
}
}
}
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:
1. First, I got this at the beginning
> In file included from /home/pedro/prueba_op.cpp:1:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/iostream:40:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/ostream:40:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/ios:39:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/iosfwd:42:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/postypes.h:42:
> In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/cwchar:46:
> /usr/include/wchar.h:40:11: fatal error: 'stdarg.h' file not found
> # include <stdarg.h>
>
This hasn't been a problem so far, but I was wondering how I can avoid that message.
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.
Thanks in advance,
Pedro.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140127/c030a55e/attachment.html>
More information about the cfe-dev
mailing list