[PATCH] D65564: Improve raw_ostream so that you can "write" colors using operator<<
Rui Ueyama via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 1 02:21:18 PDT 2019
ruiu created this revision.
ruiu added reviewers: MaskRay, grimar.
Herald added subscribers: cfe-commits, thopre, gbedwell, aheejin, hiraditya, arichardson, sbc100, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: andreadb.
Herald added projects: clang, LLVM.
1. raw_ostream supports ANSI colors so that you can write messages
to the termina with colors. Previously, in order to change and reset
color, you had to call `changeColor` and `resetColor` functions,
So, if you print out "error: " in red, for example, you had to do
something like this:
OS << "error: ";
With this patch, you can write the same code as follows:
OS << raw_ostream::RED << "error: " << raw_ostream::RESET;
2. Add a boolean flag to raw_ostream so that you can disable colored
output. If you disable colors, changeColor, operator<<(Color), resetColor
and other color-related functions have no effect.
Most LLVM tools automatically prints out messages using colors, and
you can disable it by passing a flag such as `--disable-colors`.
This new flag makes it easy to write code that works that way.
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 28907 bytes
Desc: not available
More information about the cfe-commits