[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

Xavier Roche via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 08:51:40 PDT 2021


Xavier created this revision.
Xavier added a reviewer: alexfh.
Xavier added a project: clang-tools-extra.
Xavier requested review of this revision.
Herald added a subscriber: cfe-commits.

This small patch adds a new `-extra-arg-clang-tidy` option to clang-tidy-diff and run-clang-tidy scripts. This is especially handy in addition to the `-checks` option, to tune the executed checks.

//Example//:

  clang-tidy-diff.py -checks='-*,clang-analyzer-*' -extra-arg-clang-tidy='-warnings-as-errors=-*,clang-analyzer-*'


https://reviews.llvm.org/D112008

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  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
@@ -104,6 +104,7 @@
       start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
       start.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
       start.append('-quiet')
@@ -241,6 +242,9 @@
                       action='append', default=[],
                       help='Additional argument to prepend to the compiler '
                       'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+                      action='append', default=[],
+                      help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
                       help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===================================================================
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
                       action='append', default=[],
                       help='Additional argument to prepend to the compiler '
                       'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+                      action='append', default=[],
+                      help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
                       help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
     common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
     common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
     line_filter_json = json.dumps(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112008.380424.patch
Type: text/x-patch
Size: 2148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211018/a6370347/attachment-0001.bin>


More information about the cfe-commits mailing list