[PATCH] D90535: [clang-tidy] Allow -warnings-as-errors to be specified from run_clang_tidy.py

Christian Schärf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 1 09:00:03 PST 2020


schaerfo updated this revision to Diff 302152.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90535/new/

https://reviews.llvm.org/D90535

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===================================================================
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,7 +81,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
                         header_filter, allow_enabling_alpha_checkers,
-                        extra_arg, extra_arg_before, quiet, config):
+                        extra_arg, extra_arg_before, quiet, config,
+                        warnings_as_errors):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -106,6 +107,8 @@
       start.append('-quiet')
   if config:
       start.append('-config=' + config)
+  if warnings_as_errors:
+      start.append('-warnings-as-errors=' + warnings_as_errors)
   start.append(f)
   return start
 
@@ -165,7 +168,7 @@
                                      tmpdir, build_path, args.header_filter,
                                      args.allow_enabling_alpha_checkers,
                                      args.extra_arg, args.extra_arg_before,
-                                     args.quiet, args.config)
+                                     args.quiet, args.config, args.warnings_as_errors)
 
     proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     output, err = proc.communicate()
@@ -234,6 +237,9 @@
                       'command line.')
   parser.add_argument('-quiet', action='store_true',
                       help='Run clang-tidy in quiet mode')
+  parser.add_argument('-warnings-as-errors', default=None,
+                      help='Upgrades warnings to errors. Does not enable '
+                      'any warnings py itself.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90535.302152.patch
Type: text/x-patch
Size: 1894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201101/0b2a310a/attachment.bin>


More information about the cfe-commits mailing list