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

2020-10-31 Thread Christian Schärf via Phabricator via cfe-commits
schaerfo created this revision.
schaerfo added a reviewer: alexfh.
schaerfo added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
schaerfo requested review of this revision.

This patch adds a `-warnings-as-errors` option to run_clang_tidy.py, which is 
forwarded to clang-tidy itself. This is done similar to the `-header-filter` 
option (as well as some others).

The rationale behind this is that previously, promoting warnings to errors when 
using run_clang_tidy was only possible through the .clang-tidy file and the 
`-config` option (which, however, overrides what is specified in .clang-tidy) 
and thus could not be changed without modifying this file. This comes in handy 
e. g. for CI, when you want the run to fail if certain warnings are emitted.


Repository:
  rG LLVM Github Monorepo

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'


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'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-11-01 Thread Christian Schärf via Phabricator via cfe-commits
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'


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'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-11-01 Thread Christian Schärf via Phabricator via cfe-commits
schaerfo added a comment.

In D90535#2366731 , @njames93 wrote:

> Just a general drive by comment, there have been quite a few patches recently 
> that add arguments that just get forwarded straight to clang-tidy, would it 
> not be a whole lot simpler if we could just automatically forward arguments 
> straight to clang-tidy.

That is indeed an idea worth considering, perhaps I can start working on it. It 
would, however, not be backwards compatible.

> Anyway aside from that, please upload diffs with the full context, see 
> https://llvm.org/docs/Phabricator.html#phabricator-request-review-web for 
> more info.

I have updated the revision to show the entire diff.


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

https://reviews.llvm.org/D90535

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