This is an archive of the discontinued LLVM Phabricator instance.

[diagtool] Use `operator<<(Colors)` to print out colored output.
ClosedPublic

Authored by ruiu on Aug 7 2019, 2:36 AM.

Details

Summary

r368131 introduced this new API to print out messages in colors.
If the colored output is disabled, operator<<(Colors) becomes nop.
No functionality change intended.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Aug 7 2019, 2:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2019, 2:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay added a subscriber: MaskRay.Aug 7 2019, 3:02 AM
MaskRay added inline comments.
clang/tools/diagtool/TreeView.cpp
167 ↗(On Diff #213825)

out.enable_colors(out.has_colors());

It looks the function hasColors is overengineered. out in these files can only be llvm::outs(). It doesn't have to check if llvm::errs() is connected to a terminal.

JDevlieghere accepted this revision.Aug 7 2019, 10:55 AM

LGTM with Fangrui's comment addressed.

This revision is now accepted and ready to land.Aug 7 2019, 10:55 AM
ruiu marked an inline comment as done.Aug 7 2019, 11:57 PM
ruiu added inline comments.
clang/tools/diagtool/TreeView.cpp
167 ↗(On Diff #213825)

Done. Thanks.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2019, 12:04 AM