aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-08-02 07:22:34 +0000
committerRui Ueyama <ruiu@google.com>2019-08-02 07:22:34 +0000
commit4d41c332ef57281973e5e73295a56132ae12df77 (patch)
tree2fd94fb54c00a1233ce74978d3148d250bca01cd /llvm/tools/llvm-cov
parent206fe82be410ff8cc7619c89afdff6561275a015 (diff)
downloadllvm-4d41c332ef57281973e5e73295a56132ae12df77.zip
llvm-4d41c332ef57281973e5e73295a56132ae12df77.tar.gz
llvm-4d41c332ef57281973e5e73295a56132ae12df77.tar.bz2
Revert r367649: Improve raw_ostream so that you can "write" colors using operator<<
This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r--llvm/tools/llvm-cov/CoverageReport.cpp2
-rw-r--r--llvm/tools/llvm-cov/CoverageViewOptions.h2
-rw-r--r--llvm/tools/llvm-cov/RenderingSupport.h2
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp2
-rw-r--r--llvm/tools/llvm-cov/llvm-cov.cpp11
5 files changed, 11 insertions, 8 deletions
diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp
index 1750d18..8225954 100644
--- a/llvm/tools/llvm-cov/CoverageReport.cpp
+++ b/llvm/tools/llvm-cov/CoverageReport.cpp
@@ -111,7 +111,7 @@ void renderDivider(ArrayRef<size_t> ColumnWidths, raw_ostream &OS) {
/// Return the color which correponds to the coverage percentage of a
/// certain metric.
template <typename T>
-raw_ostream::Color determineCoveragePercentageColor(const T &Info) {
+raw_ostream::Colors determineCoveragePercentageColor(const T &Info) {
if (Info.isFullyCovered())
return raw_ostream::GREEN;
return Info.getPercentCovered() >= 80.0 ? raw_ostream::YELLOW
diff --git a/llvm/tools/llvm-cov/CoverageViewOptions.h b/llvm/tools/llvm-cov/CoverageViewOptions.h
index 3dbb013..dde0c69 100644
--- a/llvm/tools/llvm-cov/CoverageViewOptions.h
+++ b/llvm/tools/llvm-cov/CoverageViewOptions.h
@@ -46,7 +46,7 @@ struct CoverageViewOptions {
/// Change the output's stream color if the colors are enabled.
ColoredRawOstream colored_ostream(raw_ostream &OS,
- raw_ostream::Color Color) const {
+ raw_ostream::Colors Color) const {
return llvm::colored_ostream(OS, Color, Colors);
}
diff --git a/llvm/tools/llvm-cov/RenderingSupport.h b/llvm/tools/llvm-cov/RenderingSupport.h
index b25792e..0674fba 100644
--- a/llvm/tools/llvm-cov/RenderingSupport.h
+++ b/llvm/tools/llvm-cov/RenderingSupport.h
@@ -47,7 +47,7 @@ inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
/// Change the color of the output stream if the `IsColorUsed` flag
/// is true. Returns an object that resets the color when destroyed.
inline ColoredRawOstream colored_ostream(raw_ostream &OS,
- raw_ostream::Color Color,
+ raw_ostream::Colors Color,
bool IsColorUsed = true,
bool Bold = false, bool BG = false) {
if (IsColorUsed)
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index f73b91a..fcabee2 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<raw_ostream::Color> Highlight;
+ Optional<raw_ostream::Colors> Highlight;
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
// The first segment overlaps from a previous line, so we treat it specially.
diff --git a/llvm/tools/llvm-cov/llvm-cov.cpp b/llvm/tools/llvm-cov/llvm-cov.cpp
index dabb8afe..172ec9f 100644
--- a/llvm/tools/llvm-cov/llvm-cov.cpp
+++ b/llvm/tools/llvm-cov/llvm-cov.cpp
@@ -83,10 +83,13 @@ int main(int argc, const char **argv) {
}
}
- if (argc > 1)
- errs() << raw_ostream::RED << "Unrecognized command: " << argv[1] << ".\n\n"
- << raw_ostream::RESET;
-
+ if (argc > 1) {
+ if (sys::Process::StandardErrHasColors())
+ errs().changeColor(raw_ostream::RED);
+ errs() << "Unrecognized command: " << argv[1] << ".\n\n";
+ if (sys::Process::StandardErrHasColors())
+ errs().resetColor();
+ }
helpMain(argc, argv);
return 1;
}