<div dir="ltr">Have you read this <a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html#step-1-create-a-clangtool">http://clang.llvm.org/docs/LibASTMatchersTutorial.html#step-1-create-a-clangtool</a></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Mon, Jul 21, 2014 at 7:12 PM, Anwar Ludin <span dir="ltr"><<a href="mailto:anwar.ludin@gmail.com" target="_blank">anwar.ludin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello,<br>
<br>
Sorry if this question has already been asked. I am trying to compile the "How to write RecursiveASTVisitor based ASTFrontedActions" tutorial located here <a href="http://clang.llvm.org/docs/RAVFrontendAction.html" target="_blank">http://clang.llvm.org/docs/RAVFrontendAction.html</a> by using CMake.<br>


<br>
In order to do this, I created a new "mytool" directory in the clang source tree containing the source code provided in the tutorial:<br>
<br>
~/llvm/tools/clang/tools/mytool<br>
<br>
The directory contains the CMakeLists.txt and FindClassDecls.cpp provided in the tutorial.<br>
<br>
I have also updated the CMakeLists.txt file located at ~/llvm/tools/clang/tools/ so that the mytool directory is included in the CMake build process.<br>
<br>
However when I try to build the tool, I get the following errors (I suspect the clangTooling library is not found).<br>
<br>
[ 98%] Building CXX object tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/FindClassDecls.cpp.o<br>
/Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:17:43: error: member access into incomplete type<br>
      'clang::ASTContext'<br>
      FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());<br>
                                          ^<br>
/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9: note: forward declaration of<br>
      'clang::ASTContext'<br>
  class ASTContext;<br>
        ^<br>
/Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:36:33: error: member access into incomplete type<br>
      'clang::ASTContext'<br>
    Visitor.TraverseDecl(Context.getTranslationUnitDecl());<br>
                                ^<br>
/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9: note: forward declaration of<br>
      'clang::ASTContext'<br>
  class ASTContext;<br>
        ^<br>
/Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:44:31: error: virtual function 'CreateASTConsumer'<br>
      has a different return type ('clang::ASTConsumer *') than the function it overrides (which has return type<br>
      'std::unique_ptr<ASTConsumer>')<br>
  virtual clang::ASTConsumer *CreateASTConsumer(<br>
                              ^<br>
/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/Frontend/FrontendAction.h:64:40: note: overridden virtual function is<br>
      here<br>
  virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,<br>
                                       ^<br>
3 errors generated.<br>
make[2]: *** [tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/FindClassDecls.cpp.o] Error 1<br>
make[1]: *** [tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/all] Error 2<br>
make: *** [all] Error 2<br>
<br>
Any help on how to build this would be greatly appreciated.<br>
<br>
Thanks!<br>
<br>
Anwar<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>