[all-commits] [llvm/llvm-project] c57b8c: [clang-tidy] Provide fine control of color in run-...

Kesavan Yogeswaran via All-commits all-commits at lists.llvm.org
Sun Feb 20 14:00:45 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c57b8ca721dd2e88ed96b7df65a518fdab738445
      https://github.com/llvm/llvm-project/commit/c57b8ca721dd2e88ed96b7df65a518fdab738445
  Author: Kesavan Yogeswaran <hikes at google.com>
  Date:   2022-02-20 (Sun, 20 Feb 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

  Log Message:
  -----------
  [clang-tidy] Provide fine control of color in run-clang-tidy

D90110 modified the behavior of `run-clang-tidy` to always pass the
`--use-color` option to clang-tidy, which enabled colored diagnostics
output regardless of TTY status or .clang-tidy settings. This left the
user with no option to disable the colored output.

This presents an issue when trying to parse the output of run-clang-tidy
programmaticall, as the output is polluted with ANSI escape characters.

This PR fixes this issue in two ways:
1. It restores the default behavior of `run-clang-tidy` to let
   `clang-tidy` decide whether to color output. This allows the user to
   configure color via the `UseColor` option in a .clang-tidy file.
2. It adds mutually exclusive, optional `-use-color` and `-no-use-color`
   argument flags that let the user explicitly set the color option via
   the invocation.

After this change the default behavior of `run-clang-tidy` when no
.clang-tidy file is available is now to show no color, presumably
because `clang-tidy` detects that the output is being piped and defaults
to not showing colored output. This seems like an acceptable tradeoff
to respect .clang-tidy configurations, as users can still use the
`-use-color` option to explicitly enable color.

Fixes #49441 (50097 in Bugzilla)

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D119562




More information about the All-commits mailing list