Skip to content

Commit c019ed9

Browse files
Allow to pass config file to clang-tidy-diff (#75457)
Adds a `-config-file` command line option that passes on the path of .`clang-tidy` or custom config file to the `clang-tidy` executable.
1 parent 66922a5 commit c019ed9

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ def main():
173173
help="checks filter, when not specified, use clang-tidy " "default",
174174
default="",
175175
)
176+
parser.add_argument(
177+
"-config-file",
178+
dest="config_file",
179+
help="Specify the path of .clang-tidy or custom config file",
180+
default="",
181+
)
176182
parser.add_argument("-use-color", action="store_true", help="Use colors in output")
177183
parser.add_argument(
178184
"-path", dest="build_path", help="Path used to read a compile command database."
@@ -313,6 +319,8 @@ def main():
313319
common_clang_tidy_args.append("-fix")
314320
if args.checks != "":
315321
common_clang_tidy_args.append("-checks=" + args.checks)
322+
if args.config_file != "":
323+
common_clang_tidy_args.append("-config-file=" + args.config_file)
316324
if args.quiet:
317325
common_clang_tidy_args.append("-quiet")
318326
if args.build_path is not None:

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,22 @@ Improvements to clang-tidy
119119

120120
- Improved `--dump-config` to print check options in alphabetical order.
121121

122-
- Improved :program:`clang-tidy-diff.py` script. It now returns exit code `1`
123-
if any :program:`clang-tidy` subprocess exits with a non-zero code or if
124-
exporting fixes fails. It now accepts a directory as a value for
125-
`-export-fixes` to export individual yaml files for each compilation unit.
122+
- Improved :program:`clang-tidy-diff.py` script.
123+
* Return exit code `1` if any :program:`clang-tidy` subprocess exits with
124+
a non-zero code or if exporting fixes fails.
125+
126+
* Accept a directory as a value for `-export-fixes` to export individual
127+
yaml files for each compilation unit.
128+
129+
* Introduce a `-config-file` option that forwards a configuration file to
130+
:program:`clang-tidy`. Corresponds to the `--config-file` option in
131+
:program:`clang-tidy`.
126132

127133
- Improved :program:`run-clang-tidy.py` script. It now accepts a directory
128134
as a value for `-export-fixes` to export individual yaml files for each
129135
compilation unit.
130136

137+
131138
New checks
132139
^^^^^^^^^^
133140

0 commit comments

Comments
 (0)