1 ### Apply clang-tidy fixes on the repo
3 This script runs clang-tidy on every C++ source file in MLIR and commit
4 the results of the checks individually. Be aware that it'll take over
5 10h to process the entire codebase.
7 The advised way to use this is to build clang-tidy (in release mode) and
8 have another build directory for MLIR. Here is a sample invocation from
13 CLANG_TIDY=build-clang/bin/clang-tidy \
15 ./mlir/utils/clang-tidy/apply-clang-tidy.sh build mlir ~/clang-tidy-fails/
16 } 2>&1 | tee ~/clang-tidy.log
19 - `build-clang/` contains the result of a build of clang-tidy, configured
20 and built somehow with:
23 -DLLVM_ENABLE_PROJECTS="clang;mlir;clang-tools-extra" \
24 -DCMAKE_BUILD_TYPE=Release \
25 -DLLVM_TARGETS_TO_BUILD=Native \
29 - `build/` must be a directory with MLIR onfigured. It is highly advised to
30 use `ccache` as well, as this directory will be used to rerun
31 `ninja check-mlir` after every single clang-tidy fix.
34 -DLLVM_ENABLE_PROJECTS="mlir" \
35 -DCMAKE_BUILD_TYPE=Release \
36 -DLLVM_ENABLE_ASSERTIONS=ON \
37 -DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" \
38 -DLLVM_CCACHE_BUILD=ON \
39 -DCMAKE_C_COMPILER=clang \
40 -DCMAKE_CXX_COMPILER=clang++ \
41 -DLLVM_ENABLE_LLD=ON \
42 -DLLVM_BUILD_EXAMPLES=OFF \
43 -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
46 - `mlir/` is the directory where to find the files, it can be replaced by a
47 subfolder or the path to a single file.
48 - `mkdir -p ~/clang-tidy-fails/` will be a directory containing the patches
49 that clang-tidy produces but also fail the build.