Problems with tutorial

Hello everyone,

To get started with Clang, I’m trying to reproduce the examles in tutorial. I began with:

http://clang.llvm.org/docs/LibASTMatchersTutorial.html

I accomplished Step 0 and 1 without any problems, but I had trouble with Step 2.

  1. The directory ~/clang-llvm/llvm/llvm_build doesn’t exist. So, I tried to rerun ninja in ~/clang-llvm/build as I did in Step 1, but it says: “ninja: no work to do”
    How can I recompile LoopConvert?

  2. If I run now bin/loop-convert test.cpp as in Step1, it says:
    LLVM ERROR: Could not auto-detect compilation database for file “test.cpp”
    No compilation database found in /home/pedro/clang-llvm/build or any parent directory
    json-compilation-database: Error while opening JSON database: No such file or directory

What’s the problem now? What have changed?

After this, I tried to follow this other tutorial:
ttp://clang.llvm.org/docs/RAVFrontendAction.html

As in Step1, I put FindClassDecls.cpp in a directory called find-class-decls in ~/clang-llvm/llvm/tools/clang/tools andc hanged the CMakeLists.txt in tools. Then, I run ninja in ~/clang-llvm/build and I get the next error:

/home/pedro/clang-llvm/llvm/tools/clang/tools/find-class-decls/FindClassDecls.cpp:17:43: error: member access into incomplete type ‘clang::ASTContext’
FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());
^
/home/pedro/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:18:9: note: forward declaration of ‘clang::ASTContext’
class ASTContext;
^
/home/pedro/clang-llvm/llvm/tools/clang/tools/find-class-decls/FindClassDecls.cpp:36:33: error: member access into incomplete type ‘clang::ASTContext’
Visitor.TraverseDecl(Context.getTranslationUnitDecl());
^
/home/pedro/clang-llvm/llvm/tools/clang/include/clang/AST/ASTConsumer.h:18:9: note: forward declaration of ‘clang::ASTContext’
class ASTContext;
^
2 errors generated.

What’s happening here?

Thanks in advance.

Pedro.

PD; By the way, LoopPrinter class in http://clang.llvm.org/docs/LibASTMatchersTutorial.html lacks a ‘}’ before ‘};’

Hello everyone,

To get started with Clang, I'm trying to reproduce the examles in tutorial.
I began with:

http://clang.llvm.org/docs/LibASTMatchersTutorial.html

I accomplished Step 0 and 1 without any problems, but I had trouble with
Step 2.
1. The directory ~/clang-llvm/llvm/llvm_build doesn't exist. So, I tried to
rerun ninja in ~/clang-llvm/build as I did in Step 1, but it says: "ninja:
no work to do"
How can I recompile LoopConvert?

I assume "llvm_build" is a mistype and it should be
~/clang-llvm/build. Are you sure you followed the steps in (1) to
change the CMakeLists.txt file, for example?

If you're not sure how to /rebuild/ - that should happen
automatically, if you make any changes. If it's not rebuilding, try
editing the source files and running the ninja command again.

2. If I run now bin/loop-convert test.cpp as in Step1, it says:
LLVM ERROR: Could not auto-detect compilation database for file "test.cpp"
No compilation database found in /home/pedro/clang-llvm/build or any parent
directory
json-compilation-database: Error while opening JSON database: No such file
or directory

What's the problem now? What have changed?

http://clang.llvm.org/docs/JSONCompilationDatabase.html might provide some help.

After this, I tried to follow this other tutorial:
ttp://clang.llvm.org/docs/RAVFrontendAction.html

As in Step1, I put FindClassDecls.cpp in a directory called find-class-decls
in ~/clang-llvm/llvm/tools/clang/tools andc hanged the CMakeLists.txt in
tools. Then, I run ninja in ~/clang-llvm/build and I get the next error:

/home/pedro/clang-llvm/llvm/tools/clang/tools/find-class-decls/FindClassDecls.cpp:17:43:
error: member access into incomplete type 'clang::ASTContext'

Looks like it needs "ASTContext.h" included.