Skip to content

Commit ccfabe8

Browse files
juru1234PiotrZSL
andauthored
[clang-tidy-diff] Add an option to treat warnings as errors (#128221)
This patch allows to treat warnings as erros using clang-tidy-diff. Co-authored-by: Piotr Zegar <[email protected]>
1 parent 9b1ce47 commit ccfabe8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ def main():
259259
action="store_true",
260260
help="Only check files in the compilation database",
261261
)
262+
parser.add_argument(
263+
"-warnings-as-errors",
264+
help="Upgrades clang-tidy warnings to errors. Same format as '-checks'.",
265+
default="",
266+
)
262267

263268
clang_tidy_args = []
264269
argv = sys.argv[1:]
@@ -374,6 +379,8 @@ def main():
374379
common_clang_tidy_args.append("-extra-arg-before=%s" % arg)
375380
for plugin in args.plugins:
376381
common_clang_tidy_args.append("-load=%s" % plugin)
382+
if args.warnings_as_errors:
383+
common_clang_tidy_args.append("-warnings-as-errors=" + args.warnings_as_errors)
377384

378385
for name in lines_by_file:
379386
line_filter_json = json.dumps(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Improvements to clang-tidy
9797
Note: this may lead to false negatives; downstream users may need to adjust
9898
their checks to preserve existing behavior.
9999

100+
- Improved :program:`clang-tidy-diff.py` script. Add the `-warnings-as-errors`
101+
argument to treat warnings as errors.
102+
100103
New checks
101104
^^^^^^^^^^
102105

0 commit comments

Comments
 (0)