Name Date Size #Lines LOC

..--

README.mdH A D13-Feb-20231.6 KiB5145

apply-clang-tidy.shH A D16-Nov-20224.6 KiB117105

README.md

1### Apply clang-tidy fixes on the repo
2
3This script runs clang-tidy on every C++ source file in MLIR and commit
4the results of the checks individually. Be aware that it'll take over
510h to process the entire codebase.
6
7The advised way to use this is to build clang-tidy (in release mode) and
8have another build directory for MLIR. Here is a sample invocation from
9the root of the repo:
10
11```bash
12{ time \
13  CLANG_TIDY=build-clang/bin/clang-tidy \
14  TIMING_TIDY=time \
15  ./mlir/utils/clang-tidy/apply-clang-tidy.sh build mlir ~/clang-tidy-fails/
16} 2>&1 | tee ~/clang-tidy.log
17```
18
19- `build-clang/` contains the result of a build of clang-tidy, configured
20  and built somehow with:
21```bash
22$ cmake ../llvm \
23  -DLLVM_ENABLE_PROJECTS="clang;mlir;clang-tools-extra" \
24  -DCMAKE_BUILD_TYPE=Release \
25  -DLLVM_TARGETS_TO_BUILD=Native \
26  -G Ninja
27$ ninja clang-tidy
28```
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.
32```bash
33$ cmake ../llvm \
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 \
44  -G Ninja
45```
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.
50
51