Author: Julian Ruess
Date: 2025-03-17T15:55:40+08:00
New Revision: ccfabe8380572d99a6833bfff09a62018aca1a15

URL: 
https://github.com/llvm/llvm-project/commit/ccfabe8380572d99a6833bfff09a62018aca1a15
DIFF: 
https://github.com/llvm/llvm-project/commit/ccfabe8380572d99a6833bfff09a62018aca1a15.diff

LOG: [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 <m...@piotrzegar.pl>

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
    clang-tools-extra/docs/ReleaseNotes.rst

Removed: 
    


################################################################################
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..0f8ac7344aca3 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(

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 2252efb498c2c..72aa05eb4dcd1 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -97,6 +97,9 @@ Improvements to clang-tidy
   Note: this may lead to false negatives; downstream users may need to adjust
   their checks to preserve existing behavior.
 
+- Improved :program:`clang-tidy-
diff .py` script. Add the `-warnings-as-errors`
+  argument to treat warnings as errors.
+
 New checks
 ^^^^^^^^^^
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to