Skip to content

Commit b1f1688

Browse files
bernhardmgruberwhisperity
authored andcommitted
[clang-tidy] support --load in clang-tidy-diff.py/run-clang-tidy.py
Support for loading shared objects as plugins into clang-tidy was added in http://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. Differential Revision: http://reviews.llvm.org/D12306 Reviewed By: aaron.ballman
1 parent ed8dffe commit b1f1688

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def main():
160160
'command line.')
161161
parser.add_argument('-quiet', action='store_true', default=False,
162162
help='Run clang-tidy in quiet mode')
163+
parser.add_argument('-load', dest='plugins',
164+
action='append', default=[],
165+
help='Load the specified plugin in clang-tidy.')
166+
163167
clang_tidy_args = []
164168
argv = sys.argv[1:]
165169
if '--' in argv:
@@ -233,6 +237,8 @@ def main():
233237
common_clang_tidy_args.append('-extra-arg=%s' % arg)
234238
for arg in args.extra_arg_before:
235239
common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
240+
for plugin in args.plugins:
241+
common_clang_tidy_args.append('-load=%s' % plugin)
236242

237243
for name in lines_by_file:
238244
line_filter_json = json.dumps(

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def make_absolute(f, directory):
9292
def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
9393
header_filter, allow_enabling_alpha_checkers,
9494
extra_arg, extra_arg_before, quiet, config_file_path,
95-
config, line_filter, use_color):
95+
config, line_filter, use_color, plugins):
9696
"""Gets a command line for clang-tidy."""
9797
start = [clang_tidy_binary]
9898
if allow_enabling_alpha_checkers:
@@ -126,6 +126,8 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
126126
start.append('--config-file=' + config_file_path)
127127
elif config:
128128
start.append('-config=' + config)
129+
for plugin in plugins:
130+
start.append('-load=' + plugin)
129131
start.append(f)
130132
return start
131133

@@ -196,7 +198,8 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
196198
args.allow_enabling_alpha_checkers,
197199
args.extra_arg, args.extra_arg_before,
198200
args.quiet, args.config_file, args.config,
199-
args.line_filter, args.use_color)
201+
args.line_filter, args.use_color,
202+
args.plugins)
200203

201204
proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
202205
output, err = proc.communicate()
@@ -280,6 +283,9 @@ def main():
280283
'command line.')
281284
parser.add_argument('-quiet', action='store_true',
282285
help='Run clang-tidy in quiet mode')
286+
parser.add_argument('-load', dest='plugins',
287+
action='append', default=[],
288+
help='Load the specified plugin in clang-tidy.')
283289
args = parser.parse_args()
284290

285291
db_path = 'compile_commands.json'
@@ -306,7 +312,8 @@ def main():
306312
args.allow_enabling_alpha_checkers,
307313
args.extra_arg, args.extra_arg_before,
308314
args.quiet, args.config_file, args.config,
309-
args.line_filter, args.use_color)
315+
args.line_filter, args.use_color,
316+
args.plugins)
310317
invocation.append('-list-checks')
311318
invocation.append('-')
312319
if args.quiet:

0 commit comments

Comments
 (0)