Lines Matching +full:clang +full:- +full:build
2 How To Setup Clang Tooling For LLVM
5 Clang Tooling provides infrastructure to write tools that need syntactic
7 of specific tools using this infrastructure (e.g. ``clang-check``). This
8 document provides information on how to set up and use Clang Tooling for
14 Clang Tooling needs a compilation database to figure out specific build
17 invoking clang tools, you can either specify a path to a build directory
18 using a command line parameter ``-p`` or let Clang Tooling find this
20 build using CMake to use clang tools.
22 Setup Clang Tooling Using CMake and Make
25 If you intend to use make to build LLVM, you should have CMake 2.8.6 or
29 make a build directory and run CMake from it:
31 .. code-block:: console
33 $ mkdir your/build/directory
34 $ cd your/build/directory
35 $ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources
37 If you want to use clang instead of GCC, you can add
38 ``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``.
44 Clang Tooling is able to use it:
46 .. code-block:: console
48 $ ln -s $PWD/compile_commands.json path/to/llvm/source/
50 Now you are ready to build and test LLVM using make:
52 .. code-block:: console
54 $ make check-all
56 Setup Clang Tooling Using CMake on Windows
72 <https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#path_and_env…
74 is to use a `developer command-prompt window
75 <https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#developer_co…
77 <https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#developer_co…
83 .. code-block:: console
85 C:\> mkdir build-ninja
86 C:\> cd build-ninja
87 C:\build-ninja> cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources
89 It is best to keep your Visual Studio IDE build folder separate from the
90 Ninja build folder. This prevents the two build systems from negatively
94 use that compilation database with Clang Tooling. One caveat is that because
96 you may need to run any Clang Tooling executables through a command prompt
98 alternative, e.g. for using the Visual Studio debugger on a Clang Tooling
102 IDE from a suitable command-prompt window.
104 Using Clang Tools
107 After you completed the previous steps, you are ready to run clang tools. If
108 you have a recent clang installed, you should have ``clang-check`` in
111 .. code-block:: console
113 $ clang-check tools/clang/lib/Tooling/CompilationDatabase.cpp
115 If you're using vim, it's convenient to have clang-check integrated. Put
136 call ClangCheckImpl("clang-check " . l:filename)
140 echo "Can't detect file's compilation arguments and no previous clang-check invocation!"
148 will re-run the last clang-check invocation made from this vim instance
150 automatically when clang-check finds errors, and can be re-opened with
153 Other ``clang-check`` options that can be useful when working with clang
156 * ``-ast-print`` --- Build ASTs and then pretty-print them.
157 * ``-ast-dump`` --- Build ASTs and then debug dump them.
158 * ``-ast-dump-filter=<string>`` --- Use with ``-ast-dump`` or ``-ast-print`` to
160 qualified name. Use ``-ast-list`` to list all filterable declaration node
162 * ``-ast-list`` --- Build ASTs and print the list of declaration node qualified
167 .. code-block:: console
169 …$ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-dump -ast-dump-filter ActionFactor…
170 Processing: tools/clang/tools/clang-check/ClangCheck.cpp.
172 …clang::ASTConsumer *newASTConsumer() (CompoundStmt 0x44da290 </home/alexfh/local/llvm/tools/clang/…
177 …$ clang-check tools/clang/tools/clang-check/ClangCheck.cpp -ast-print -ast-dump-filter ActionFacto…
178 Processing: tools/clang/tools/clang-check/ClangCheck.cpp.
180 clang::ASTConsumer *newASTConsumer() {
181 if (this->ASTList.operator _Bool())
182 return clang::CreateASTDeclNodeLister();
183 if (this->ASTDump.operator _Bool())
184 return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
185 this->ASTDumpFilter);
186 if (this->ASTPrint.operator _Bool())
187 return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter);
188 return new clang::ASTConsumer();
191 Using Ninja Build System
194 Optionally you can use the `Ninja`_ build system instead of make. It is
198 To take advantage of using Clang Tools along with Ninja build you need
201 Clone the Ninja git repository and build Ninja from sources:
203 .. code-block:: console
213 .. code-block:: console
218 After doing all of this, you'll need to generate Ninja build files for
219 LLVM with CMake. You need to make a build directory and run CMake from
222 .. code-block:: console
224 $ mkdir your/build/directory
225 $ cd your/build/directory
226 $ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/llvm/sources
228 If you want to use clang instead of GCC, you can add
229 ``-DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++``.
235 Clang Tooling is able to use it:
237 .. code-block:: console
239 $ ln -s $PWD/compile_commands.json path/to/llvm/source/
241 Now you are ready to build and test LLVM using Ninja:
243 .. code-block:: console
245 $ ninja check-all
249 .. _Ninja: https://ninja-build.org/