[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:47:31 PST 2025
https://github.com/juru1234 created https://github.com/llvm/llvm-project/pull/128221
This patch allows to treat warnings as erros using clang-tidy-diff.
>From 1c205282d5e9390d2498a2a308a9ac3d0deb8b6b 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 | 9 +++++++++
1 file changed, 9 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..863b504539b58 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,12 @@ 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 +380,9 @@ 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