[clang-tools-extra] 9e1f4f1 - [clang-tidy][run-clang-tidy.py] Add --config-file=<string> option
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 17 04:30:39 PDT 2022
Author: Shreyas Atre
Date: 2022-03-17T07:30:28-04:00
New Revision: 9e1f4f13984186984ba37513372c1b7e0c4ba4fd
URL: https://github.com/llvm/llvm-project/commit/9e1f4f13984186984ba37513372c1b7e0c4ba4fd
DIFF: https://github.com/llvm/llvm-project/commit/9e1f4f13984186984ba37513372c1b7e0c4ba4fd.diff
LOG: [clang-tidy][run-clang-tidy.py] Add --config-file=<string> option
Link to the GitHub Issue: https://github.com/llvm/llvm-project/issues/53745
Added config_path variable within the python script which makes the
required call to the clang-tidy binary with --config-file option.
If the config_path is None then config will be used. No error is raised
if both are given but silently chooses config_path over config
Added:
Modified:
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
Removed:
################################################################################
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 73edef494ab1f..ec1fd6679e2ab 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -90,8 +90,8 @@ def make_absolute(f, directory):
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):
+ extra_arg, extra_arg_before, quiet, config_path,
+ config, line_filter, use_color):
"""Gets a command line for clang-tidy."""
start = [clang_tidy_binary]
if allow_enabling_alpha_checkers:
@@ -121,7 +121,9 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
start.append('-p=' + build_path)
if quiet:
start.append('-quiet')
- if config:
+ if config_path:
+ start.append('--config-file=' + config_path)
+ elif config:
start.append('-config=' + config)
start.append(f)
return start
@@ -192,8 +194,8 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
tmpdir, build_path, args.header_filter,
args.allow_enabling_alpha_checkers,
args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = proc.communicate()
@@ -225,7 +227,8 @@ def main():
parser.add_argument('-checks', default=None,
help='checks filter, when not specified, use clang-tidy '
'default')
- parser.add_argument('-config', default=None,
+ config_group = parser.add_mutually_exclusive_group()
+ config_group.add_argument('-config', default=None,
help='Specifies a configuration in YAML/JSON format: '
' -config="{Checks: \'*\', '
' CheckOptions: [{key: x, '
@@ -233,6 +236,12 @@ def main():
'When the value is empty, clang-tidy will '
'attempt to find a file named .clang-tidy for '
'each source file in its parent directories.')
+ config_group.add_argument('-config-file', default=None,
+ help='Specify the path of .clang-tidy or custom config '
+ 'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+ 'This option internally works exactly the same way as '
+ '-config option after reading specified config file. '
+ 'Use either -config-file or -config, not both.')
parser.add_argument('-header-filter', default=None,
help='regular expression matching the names of the '
'headers to output diagnostics from. Diagnostics from '
@@ -295,8 +304,8 @@ def main():
None, build_path, args.header_filter,
args.allow_enabling_alpha_checkers,
args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
invocation.append('-list-checks')
invocation.append('-')
if args.quiet:
More information about the cfe-commits
mailing list