LibTooling Tutorial directory paths

I’m trying to work through the “Create a ClangTool” tutorial at https://clang.llvm.org/docs/LibASTMatchersTutorial.html

The instructions include “cd ~/clang-llvm/llvm/tools/clang”, but this directory does not exist within the tree that’s generated from the previous stages. “~/clang-llvm/llvm/tools/” is there.

Various other commands also depend on similar paths.

Where should the loop-convert directory be placed?

Thanks

Phil.

Hi Phil,

Use ~/clang-llvm/clang instead of ~/clang-llvm/tools/clang, and put the new tool in ~/clang-llvm/clang-tools-extra instead of ~/clang-llvm/tools/clang/tools/extra.
LLVM has two supported directory layouts and the tutorial was only partially updated to use the new monorepo layout.

Thanks for the clarification.

I’ve tried putting the files in ~/clang-llvm/clang-tool-extra/loop-convert and adding add_subdirectory(loop-convert) to ~/clang-llvm/clang-tool-extra/CMakeLists.txt.

However, I think there must be something else I need to do as a “make” does not result in anything new being built!

Do I need to pass -DLLVM_ENABLE_PROJECTS= to cmake?

Phil.

Hi Phil,

Use ~/clang-llvm/clang instead of ~/clang-llvm/tools/clang, and put the new tool in ~/clang-llvm/clang-tools-extra instead of ~/clang-llvm/tools/clang/tools/extra.
LLVM has two supported directory layouts and the tutorial was only partially updated to use the new monorepo layout.

Ah, yes, this changed as well after writing this documentation… You need to pass ‘-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra’.
I’ll update the docs accordingly.

Thanks, that’s got it going.

Phil.

Ah, yes, this changed as well after writing this documentation… You need to pass ‘-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra’.
I’ll update the docs accordingly.