[PATCH] D123065: [clang-tidy] support --load in clang-tidy-diff.py/run-clang-tidy.py

Bernhard Manfred Gruber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 4 12:45:32 PDT 2022


bernhardmgruber created this revision.
bernhardmgruber added a reviewer: aaron.ballman.
Herald added subscribers: carlosgalvezp, mgehre, xazax.hun.
Herald added a project: All.
bernhardmgruber requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Support for loading shared objects as plugins into clang-tidy was added in https://reviews.llvm.org/D111100. Unfortunately, the utility scripts `clang-tidy-diff.py` and `run-clang-tidy.py` did not receive corresponding arguments to forward such plugins to clang-tidy. This diff adds a `-load=plugin` option to both scripts.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D123065

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
@@ -91,7 +91,7 @@
 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,
-                        line_filter, use_color):
+                        line_filter, use_color, plugins):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -123,6 +123,8 @@
       start.append('-quiet')
   if config:
       start.append('-config=' + config)
+  for plugin in plugins:
+      start.append('-load=' + plugin)
   start.append(f)
   return start
 
@@ -193,7 +195,7 @@
                                      args.allow_enabling_alpha_checkers,
                                      args.extra_arg, args.extra_arg_before,
                                      args.quiet, args.config, args.line_filter,
-                                     args.use_color)
+                                     args.use_color, args.plugins)
 
     proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     output, err = proc.communicate()
@@ -270,6 +272,9 @@
                       'command line.')
   parser.add_argument('-quiet', action='store_true',
                       help='Run clang-tidy in quiet mode')
+  parser.add_argument('-load', dest='plugins',
+                      action='append', default=[],
+                      help='Make clang-tidy load the specified plugin')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'
@@ -296,7 +301,7 @@
                                      args.allow_enabling_alpha_checkers,
                                      args.extra_arg, args.extra_arg_before,
                                      args.quiet, args.config, args.line_filter,
-                                     args.use_color)
+                                     args.use_color, args.plugins)
     invocation.append('-list-checks')
     invocation.append('-')
     if args.quiet:
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
@@ -160,6 +160,10 @@
                       'command line.')
   parser.add_argument('-quiet', action='store_true', default=False,
                       help='Run clang-tidy in quiet mode')
+  parser.add_argument('-load', dest='plugins',
+                      action='append', default=[],
+                      help='Make clang-tidy load the specified plugin')
+
   clang_tidy_args = []
   argv = sys.argv[1:]
   if '--' in argv:
@@ -233,6 +237,8 @@
     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)
+  for plugin in args.plugins:
+    common_clang_tidy_args.append('-load=%s' % plugin)
 
   for name in lines_by_file:
     line_filter_json = json.dumps(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123065.420275.patch
Type: text/x-patch
Size: 3290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220404/be6710ee/attachment-0001.bin>


More information about the cfe-commits mailing list