Merge bitcoin/bitcoin#35149: doc: clarify clang-tidy in developer notes

a1e534bbf0 doc: clarify clang-tidy in developer notes (rkrux)

Pull request description:

  Recently, I ran clang-tidy in my system and had to figure out setting it up
  correcty on my system (macOS) & understanding its output while tweaking
  few arguments that made the output easier to parse.

  This patch documents those in the developer notes.

ACKs for top commit:
  sedited:
    ACK a1e534bbf0

Tree-SHA512: e95cd44cdad9a9011c18136ec7f1db4e73f78f11c517f94c14cf128beaaea150881868c27e7c5c710c9cab94d285d61dc5e5278f347c229f5df495cd49c532ab
This commit is contained in:
merge-script
2026-04-27 16:01:54 +02:00

View File

@@ -164,7 +164,7 @@ To run clang-tidy on Ubuntu/Debian, install the dependencies:
apt install clang-tidy clang
```
Configure with clang as the compiler:
Configure with clang as the compiler with the below command that should create a `compile_commands.json` file within the build directory:
```sh
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
@@ -172,12 +172,19 @@ cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXP
The output is denoised of errors from external dependencies.
To run clang-tidy on all source files:
To run clang-tidy on all source files using the checks mentioned in the `./src/.clang-tidy` file:
```sh
( cd ./src/ && run-clang-tidy -p ../build -j $(nproc) )
```
To run clang-tidy on one file:
```sh
( cd ./src/ && run-clang-tidy -p ../build -j $(nproc) ./path/to/single_file.cpp )
```
Optionally, append the `run-clang-tidy` command with the `-quiet` option to suppress printing of statistics and ignored warnings that can clutter the output. The `-fix` option also comes in handy to apply the fixes suggested by the tool but need to ensure that unrelated changes in the file are not committed.
To run clang-tidy on the changed source lines:
```sh