[cfe-dev] Howto build clang tools using cmake

Nikola Smiljanic popizdeh at gmail.com
Mon Jul 21 03:08:13 PDT 2014


Have you read this
http://clang.llvm.org/docs/LibASTMatchersTutorial.html#step-1-create-a-clangtool


On Mon, Jul 21, 2014 at 7:12 PM, Anwar Ludin <anwar.ludin at gmail.com> wrote:

> Hello,
>
> Sorry if this question has already been asked. I am trying to compile the
> "How to write RecursiveASTVisitor based ASTFrontedActions" tutorial located
> here http://clang.llvm.org/docs/RAVFrontendAction.html by using CMake.
>
> In order to do this, I created a new "mytool" directory in the clang
> source tree containing the source code provided in the tutorial:
>
> ~/llvm/tools/clang/tools/mytool
>
> The directory contains the CMakeLists.txt and FindClassDecls.cpp provided
> in the tutorial.
>
> 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.
>
> However when I try to build the tool, I get the following errors (I
> suspect the clangTooling library is not found).
>
> [ 98%] Building CXX object
> tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/FindClassDecls.cpp.o
> /Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:17:43:
> error: member access into incomplete type
>       'clang::ASTContext'
>       FullSourceLoc FullLocation =
> Context->getFullLoc(Declaration->getLocStart());
>                                           ^
> /Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9:
> note: forward declaration of
>       'clang::ASTContext'
>   class ASTContext;
>         ^
> /Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:36:33:
> error: member access into incomplete type
>       'clang::ASTContext'
>     Visitor.TraverseDecl(Context.getTranslationUnitDecl());
>                                 ^
> /Users/aludin/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:20:9:
> note: forward declaration of
>       'clang::ASTContext'
>   class ASTContext;
>         ^
> /Users/aludin/clang-llvm/llvm/tools/clang/tools/mytool/FindClassDecls.cpp:44:31:
> error: virtual function 'CreateASTConsumer'
>       has a different return type ('clang::ASTConsumer *') than the
> function it overrides (which has return type
>       'std::unique_ptr<ASTConsumer>')
>   virtual clang::ASTConsumer *CreateASTConsumer(
>                               ^
> /Users/aludin/clang-llvm/llvm/tools/clang/include/clang/Frontend/FrontendAction.h:64:40:
> note: overridden virtual function is
>       here
>   virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance
> &CI,
>                                        ^
> 3 errors generated.
> make[2]: ***
> [tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/FindClassDecls.cpp.o]
> Error 1
> make[1]: ***
> [tools/clang/tools/mytool/CMakeFiles/find-class-decls.dir/all] Error 2
> make: *** [all] Error 2
>
> Any help on how to build this would be greatly appreciated.
>
> Thanks!
>
> Anwar
>
>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140721/752ebca7/attachment.html>


More information about the cfe-dev mailing list