[clang-tools-extra] [clang-tidy][docs] Add documentation for Clang-Tidy Automation (PR #153166)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 13 23:02:25 PDT 2025
================
@@ -331,6 +331,104 @@ An overview of all the command-line options:
some-check.SomeOption: 'some value'
...
+Clang-Tidy Automation
+=====================
+
+:program:`clang-tidy` can analyze multiple source files by specifying them on the
+command line. For larger projects, automation
+scripts provide additional functionality like parallel execution and integration
+with version control systems.
+
+Running Clang-Tidy in Parallel
+-------------------------------
+
+:program:`clang-tidy` can process multiple files sequentially, but for projects
+with many source files, the :program:`run-clang-tidy.py` script provides parallel
+execution to significantly reduce analysis time. This script is included with
+clang-tidy and runs :program:`clang-tidy` over all files in a compilation database
+or a specified path concurrently.
+
+The script requires a compilation database (``compile_commands.json``) which can
+be generated by build systems like CMake (using ``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON``)
+or by tools like `Bear`_.
+
+The script supports most of the same options as :program:`clang-tidy` itself,
+including ``-checks=``, ``-fix``, ``-header-filter=``, and configuration options.
+Run ``run-clang-tidy.py --help`` for a complete list of available options.
+
+Example invocations:
+
+.. code-block:: console
+
+ # Run clang-tidy on all files in the compilation database in parallel
+ $ run-clang-tidy.py -p=build/
+
+ # Run with specific checks and apply fixes
+ $ run-clang-tidy.py -p=build/ -fix -checks=-*,readability-*
+
+ # Run on specific files/directories with header filtering
+ $ run-clang-tidy.py -p=build/ -header-filter=src/ src/
+
+ # Run with parallel execution (uses all CPU cores by default)
+ $ run-clang-tidy.py -p=build/ -j 4
+
+Running Clang-Tidy on Diff
+---------------------------
+
+The :program:`clang-tidy-diff.py` script allows you to run :program:`clang-tidy`
+on the lines that have been modified in your working directory or in a
+specific diff. Importantly, clang-tidy-diff only reports diagnostics for changed
----------------
vbvictor wrote:
```suggestion
specific diff. Importantly, :program:`clang-tidy-diff.py` only reports diagnostics for changed
```
Note about line length, section should be reformatted after this change
https://github.com/llvm/llvm-project/pull/153166
More information about the cfe-commits
mailing list