From c3716ca2199ddd9b0871448b0b813deb266c096a Mon Sep 17 00:00:00 2001 From: Julie Hockett Date: Fri, 9 Mar 2018 23:26:56 +0000 Subject: [PATCH] [clang-tidy] Update run-clang-tidy.py with config arg Updating the run-clang-tidy.py script to allow specification of the config argument to the clang-tidy invocation. Differential Revision: https://reviews.llvm.org/D43538 llvm-svn: 327186 --- .../clang-tidy/tool/run-clang-tidy.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py index 379ad713be9d..24303122be0c 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -75,7 +75,8 @@ def make_absolute(f, directory): def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path, - header_filter, extra_arg, extra_arg_before, quiet): + header_filter, extra_arg, extra_arg_before, quiet, + config): """Gets a command line for clang-tidy.""" start = [clang_tidy_binary] if header_filter is not None: @@ -99,6 +100,8 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path, start.append('-p=' + build_path) if quiet: start.append('-quiet') + if config: + start.append('-config=' + config) start.append(f) return start @@ -157,7 +160,7 @@ def run_tidy(args, tmpdir, build_path, queue): invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks, tmpdir, build_path, args.header_filter, args.extra_arg, args.extra_arg_before, - args.quiet) + args.quiet, args.config) sys.stdout.write(' '.join(invocation) + '\n') subprocess.call(invocation) queue.task_done() @@ -177,6 +180,14 @@ def main(): parser.add_argument('-checks', default=None, help='checks filter, when not specified, use clang-tidy ' 'default') + parser.add_argument('-config', default=None, + help='Specifies a configuration in YAML/JSON format: ' + ' -config="{Checks: \'*\', ' + ' CheckOptions: [{key: x, ' + ' value: y}]}" ' + 'When the value is empty, clang-tidy will ' + 'attempt to find a file named .clang-tidy for ' + 'each source file in its parent directories.') parser.add_argument('-header-filter', default=None, help='regular expression matching the names of the ' 'headers to output diagnostics from. Diagnostics from '