From a52f982f1cd98ebf94abb5deb5244f460ddad2d1 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 2 Aug 2019 04:48:30 +0000 Subject: 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 --- llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/tools/llvm-cov/SourceCoverageViewText.cpp') diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index fcabee2..f73b91a 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -101,7 +101,7 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L, auto *WrappedSegment = LCS.getWrappedSegment(); CoverageSegmentArray Segments = LCS.getLineSegments(); - Optional Highlight; + Optional Highlight; SmallVector, 2> HighlightedRanges; // The first segment overlaps from a previous line, so we treat it specially. -- cgit v1.1