[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
Fri Dec 18 07:33:07 PST 2020


Abpostelnicu created this revision.
Abpostelnicu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Afer this <https://github.com/llvm/llvm-project/commit/a07a2c88d96cc48d7d381a0300565090c24b9770> commit landed we always have coloured diagnotic messages. Maybe it's a good idea to leave the user the posibility of opting out of this.


Repository:
  rG LLVM Github Monorepo

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,13 @@
 
 
 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, no_diagnostic_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]
+  if not no_diagnostic_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 +166,7 @@
     name = queue.get()
     invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
                                      tmpdir, build_path, args.header_filter,
+                                     args.no_diagnostic_color,
                                      args.allow_enabling_alpha_checkers,
                                      args.extra_arg, args.extra_arg_before,
                                      args.quiet, args.config)
@@ -204,6 +208,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('-no-diagnostic-color', action='store_true',
+                      help='Disable 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.312792.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201218/1662b023/attachment.bin>


More information about the cfe-commits mailing list