- 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,
respectively.
So, if you print out "error: " in red, for example, you had to do
something like this:
OS.changeColor(raw_ostream::RED); OS << "error: "; OS.resetColor();
With this patch, you can write the same code as follows:
OS << raw_ostream::RED << "error: " << raw_ostream::RESET;
- 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.
nit: Seems out should be uppercase here.
(I see it was like that before your changes, but seems you touching all the places where it was used, so seems you can fix it).