[PATCH] D93543: clang-tidy: Leave the possibility of opting out having coloured diagnostic messages.
Andi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 12 04:03:44 PDT 2021
Abpostelnicu updated this revision to Diff 336797.
Abpostelnicu added a comment.
Add `-use-color` argument to make it sane with `clang-tidy --use-color` argument.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93543/new/
https://reviews.llvm.org/D93543
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
@@ -80,10 +80,14 @@
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):
+ header_filter, use_color,
+ allow_enabling_alpha_checkers, extra_arg,
+ extra_arg_before, quiet, config):
"""Gets a command line for clang-tidy."""
- start = [clang_tidy_binary, '--use-color']
+ start = [clang_tidy_binary]
+ # Only if we are connected to a tty we can check for enabling color mode
+ if os.isatty(sys.stdout.fileno()) and use_color:
+ start.append('--use-color')
if allow_enabling_alpha_checkers:
start.append('-allow-enabling-analyzer-alpha-checkers')
if header_filter is not None:
@@ -163,6 +167,7 @@
name = queue.get()
invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
tmpdir, build_path, args.header_filter,
+ args.use_color,
args.allow_enabling_alpha_checkers,
args.extra_arg, args.extra_arg_before,
args.quiet, args.config)
@@ -204,6 +209,8 @@
'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('-use-color', action='store_true',
+ help='Enables diagnostic message colors.')
parser.add_argument('-header-filter', default=None,
help='regular expression matching the names of the '
'headers to output diagnostics from. Diagnostics from '
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93543.336797.patch
Type: text/x-patch
Size: 2103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210412/e53ce94f/attachment-0001.bin>
More information about the cfe-commits
mailing list