diff options
author | Rui Ueyama <ruiu@google.com> | 2019-08-02 04:48:30 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2019-08-02 04:48:30 +0000 |
commit | a52f982f1cd98ebf94abb5deb5244f460ddad2d1 (patch) | |
tree | 61799d68dd515bda1a6bd6d7b70812e96dbe9ded /clang/lib/Analysis/CFG.cpp | |
parent | 9131e925fd6b5010a9e797342a09141306183ed6 (diff) | |
download | bcm5719-llvm-a52f982f1cd98ebf94abb5deb5244f460ddad2d1.tar.gz bcm5719-llvm-a52f982f1cd98ebf94abb5deb5244f460ddad2d1.zip |
Improve raw_ostream so that you can "write" colors using operator<<
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,
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;
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.
Differential Revision: https://reviews.llvm.org/D65564
llvm-svn: 367649
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 0ed1e988a19..5db15077ce3 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -5509,7 +5509,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg, if (print_edges) { // Print the predecessors of this block. if (!B.pred_empty()) { - const raw_ostream::Colors Color = raw_ostream::BLUE; + const raw_ostream::Color Color = raw_ostream::BLUE; if (ShowColors) OS.changeColor(Color); OS << " Preds " ; @@ -5546,7 +5546,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg, // Print the successors of this block. if (!B.succ_empty()) { - const raw_ostream::Colors Color = raw_ostream::MAGENTA; + const raw_ostream::Color Color = raw_ostream::MAGENTA; if (ShowColors) OS.changeColor(Color); OS << " Succs "; |