[clang-tools-extra] [clang-tidy] Add an option to treat warnings as errors (PR #128221)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 21 11:58:04 PST 2025
https://github.com/juru1234 updated https://github.com/llvm/llvm-project/pull/128221
>From 057d62357c813dcfccf7ecfa8b272e2564fe07f3 Mon Sep 17 00:00:00 2001
From: Julian Ruess <julianonline+github at posteo.de>
Date: Fri, 21 Feb 2025 20:42:46 +0100
Subject: [PATCH] [clang-tidy] Add an option to treat warnings as errors
This patch allows to treat warnings as erros using clang-tidy-diff.
---
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 33de2077dfb1a..74321f2642ff2 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -259,6 +259,11 @@ def main():
action="store_true",
help="Only check files in the compilation database",
)
+ parser.add_argument(
+ "-warnings-as-errors",
+ help="Upgrades clang-tidy warnings to errors. Same format as '-checks'.",
+ default="",
+ )
clang_tidy_args = []
argv = sys.argv[1:]
@@ -374,6 +379,8 @@ def main():
common_clang_tidy_args.append("-extra-arg-before=%s" % arg)
for plugin in args.plugins:
common_clang_tidy_args.append("-load=%s" % plugin)
+ if args.warnings_as_errors != "":
+ common_clang_tidy_args.append("-warnings-as-errors=" + args.warnings_as_errors)
for name in lines_by_file:
line_filter_json = json.dumps(
More information about the cfe-commits
mailing list