Skip to content

Commit 968350e

Browse files
juru1234PiotrZSL
andcommitted
[clang-tidy] Add an option to treat warnings as errors
This patch allows to treat warnings as erros using clang-tidy-diff. Co-authored-by: Piotr Zegar <[email protected]>
1 parent b11e1ba commit 968350e

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
@@ -88,6 +88,9 @@ Improvements to clang-query
8888
Improvements to clang-tidy
8989
--------------------------
9090

91+
- Improved :program:`clang-tidy-diff.py` script. Add the `-warnings-as-errors`
92+
to treat warnings as errors.
93+
9194
New checks
9295
^^^^^^^^^^
9396

0 commit comments

Comments
 (0)