> > I will see that. To simplify my tests, could you provide an example to > reproduce that ? >
I give you an example which compiles and links with a compilation of clang by hand. Be aware that this example does not use all clang libraries and maybe I link with clang libraries that the program does not need. I tried this example with llvm-3.1 and libclang-dev from debian repository, it compiles but does not link. With llvm-3.0 it does not compile. If you have to modify the Makefile be aware that you need to link with clang in the given order or you will have undefined symbols. Regards, Damien R.
#include <clang/AST/ASTConsumer.h> #include <clang/AST/RecursiveASTVisitor.h> #include <clang/Frontend/CompilerInstance.h> #include <clang/Frontend/FrontendAction.h> #include <clang/Tooling/Tooling.h> using namespace clang; class FindNamedClassVisitor : public RecursiveASTVisitor<FindNamedClassVisitor> { public: explicit FindNamedClassVisitor(ASTContext *Context): Context(Context) {} bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) { if (Declaration->getQualifiedNameAsString() == "n::m::C") { FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart()); if (FullLocation.isValid()) llvm::outs() << "Found declaration at " << FullLocation.getSpellingLineNumber() << ":" << FullLocation.getSpellingColumnNumber() << "\n"; } return true; } private: ASTContext *Context; }; class FindNamedClassConsumer : public clang::ASTConsumer { public: explicit FindNamedClassConsumer(ASTContext *Context): Visitor(Context) {} virtual void HandleTranslationUnit(clang::ASTContext &Context) { Visitor.TraverseDecl(Context.getTranslationUnitDecl()); } private: FindNamedClassVisitor Visitor; }; class FindNamedClassAction : public clang::ASTFrontendAction { public: virtual clang::ASTConsumer *CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { return new FindNamedClassConsumer(&Compiler.getASTContext()); } }; int main(int argc, char **argv) { if (argc > 1) { clang::tooling::runToolOnCode(new FindNamedClassAction, argv[1]); } }
Makefile
Description: Binary data