<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Nikola,<div><br></div><div>Thanks for the pointer. Moved the sources to ~/llvm/tools/clang/tools/extra/mytool and updated the CMakeLists.txt to reflect the link you provided, but I am getting the exact same build errors.</div><div>Are the docs in synch with  the current Clang API (3.5)? Am I missing a library?</div><div><br></div><div>Content of my CMakeLists.txt:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">set(LLVM_LINK_COMPONENTS support)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">set(LLVM_USED_LIBS clangTooling clangBasic clangAST)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">add_clang_executable(find-class-decls FindClassDecls.cpp)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">target_link_libraries(find-class-decls</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  clangTooling</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  clangBasic</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  clangASTMatchers</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  )</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">Compiler errors:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px;"><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">[100%] Building CXX object tools/clang/tools/extra/mytool/CMakeFiles/find-class-decls.dir/FindClassDecls.cpp.o</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/tools/extra/mytool/FindClassDecls.cpp:17:43: error: member access into incomplete</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      type 'clang::ASTContext'</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">                                          ^</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9: note: forward declaration of</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      'clang::ASTContext'</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">  class ASTContext;</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">        ^</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/tools/extra/mytool/FindClassDecls.cpp:36:33: error: member access into incomplete</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      type 'clang::ASTContext'</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">    Visitor.TraverseDecl(Context.getTranslationUnitDecl());</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">                                ^</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9: note: forward declaration of</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      'clang::ASTContext'</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">  class ASTContext;</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">        ^</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/tools/extra/mytool/FindClassDecls.cpp:44:31: error: virtual function</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      'CreateASTConsumer' has a different return type ('clang::ASTConsumer *') than the function it overrides (which has</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      return type 'std::unique_ptr<ASTConsumer>')</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">  virtual clang::ASTConsumer *CreateASTConsumer(</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">                              ^</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">/Users/aludin/clang-llvm/llvm/tools/clang/include/clang/Frontend/FrontendAction.h:64:40: note: overridden virtual function is</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">      here</span></font></div><div style="margin: 0px;"><font face="Menlo"><span style="font-size: 11px;">  virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,</span></font></div></div><div><br></div><div><br></div><div>Thanks!</div><div><br></div><div>Anwar</div><div><div><br></div><div><br></div><div><br><div><div>On 21 Jul 2014, at 12:08, Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com">popizdeh@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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>
</blockquote></div><br></div></div></body></html>