[PATCH] D119562: Provide fine control of color in run-clang-tidy
Kesavan Yogeswaran via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 11 10:48:10 PST 2022
kesyog updated this revision to Diff 407950.
kesyog added a comment.
Refactor tri-state logic for readability
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119562/new/
https://reviews.llvm.org/D119562
Files:
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
@@ -82,15 +82,20 @@
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):
+ line_filter, use_color):
"""Gets a command line for clang-tidy."""
- start = [clang_tidy_binary, '--use-color']
+ start = [clang_tidy_binary]
if allow_enabling_alpha_checkers:
start.append('-allow-enabling-analyzer-alpha-checkers')
if header_filter is not None:
start.append('-header-filter=' + header_filter)
if line_filter is not None:
start.append('-line-filter=' + line_filter)
+ if use_color is not None:
+ if use_color:
+ start.append('--use-color')
+ else:
+ start.append('--use-color=false')
if checks:
start.append('-checks=' + checks)
if tmpdir is not None:
@@ -168,7 +173,8 @@
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.quiet, args.config, args.line_filter,
+ args.use_color)
proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = proc.communicate()
@@ -231,6 +237,16 @@
'after applying fixes')
parser.add_argument('-style', default='file', help='The style of reformat '
'code after applying fixes')
+ color_group = parser.add_mutually_exclusive_group()
+ color_group.add_argument('-use-color', action='store_true', dest='use_color',
+ help='Use colors in diagnostics, overriding clang-tidy\'s default '
+ 'behavior. This option overrides the \'UseColor\' option in'
+ '.clang-tidy file, if any.')
+ color_group.add_argument('-no-use-color', action='store_false', dest='use_color',
+ help='Do not use colors in diagnostics, overriding clang-tidy\'s default'
+ ' behavior. This option overrides the \'UseColor\' option in'
+ '.clang-tidy file, if any.')
+ parser.set_defaults(use_color=None)
parser.add_argument('-p', dest='build_path',
help='Path used to read a compile command database.')
parser.add_argument('-extra-arg', dest='extra_arg',
@@ -258,7 +274,8 @@
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.quiet, args.config, args.line_filter,
+ args.use_color)
invocation.append('-list-checks')
invocation.append('-')
if args.quiet:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119562.407950.patch
Type: text/x-patch
Size: 3437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220211/cfdbeac4/attachment.bin>
More information about the cfe-commits
mailing list