This is an archive of the discontinued LLVM Phabricator instance.

clang-tidy: Add `-use-color` for `run-clang-tidy.py` in order to make it sane with `clang-tidy` coloring argument
Needs ReviewPublic

Authored by Abpostelnicu on Dec 18 2020, 7:33 AM.

Details

Summary

Afer this commit landed we always have coloured diagnotic messages. Maybe it's a good idea to have the same default behaviour as clang-tidy has.

Diff Detail

Event Timeline

Abpostelnicu requested review of this revision.Dec 18 2020, 7:33 AM
Abpostelnicu created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2020, 7:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Abpostelnicu added a project: Restricted Project.Dec 18 2020, 7:34 AM
Abpostelnicu added a reviewer: aaron.ballman.
Abpostelnicu edited reviewers, added: njames93; removed: sylvestre.ledru.Dec 18 2020, 11:26 AM

Would it be wise to use os.isatty(sys.stdout.fileno()) as the value if left unspecified.
As we capture stdout from clang-tidy, clang-tidy assumes we aren't connected to a terminal and thus disables colours, unless explicitly enabled.
Therefore if our python script is known to be running from a terminal and we haven't specified to use colours. We should enable --use-color.

Based off this, I think the argument should be a carbon copy of the --use-color option from clang-tidy.

Add -use-color argument to make it sane with clang-tidy --use-color argument.

Abpostelnicu retitled this revision from clang-tidy: Leave the possibility of opting out having coloured diagnostic messages. to clang-tidy: Add `-use-color` for `run-clang-tidy.py` in order to make it sane with `clang-tidy` coloring argument.Apr 12 2021, 4:05 AM
Abpostelnicu edited the summary of this revision. (Show Details)

I think this would be a useful change. In the current state, one needs to modify the script to run this in a context where coloring is not supported.