From 5fcfc2c0257d442d6cf8610afa71f20c7067fc8d Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Wed, 29 Mar 2017 17:11:27 +0000 Subject: [PATCH] llvm-pdbdump: If we don't change the color, don't reset the color. The -output-color option was successful at suppressing color changes, but was still allowing color resets. Differential Revision: https://reviews.llvm.org/D31468 llvm-svn: 299006 --- llvm/tools/llvm-pdbdump/LinePrinter.cpp | 10 +++++++--- llvm/tools/llvm-pdbdump/LinePrinter.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/llvm/tools/llvm-pdbdump/LinePrinter.cpp b/llvm/tools/llvm-pdbdump/LinePrinter.cpp index 14f8c78..d376810 100644 --- a/llvm/tools/llvm-pdbdump/LinePrinter.cpp +++ b/llvm/tools/llvm-pdbdump/LinePrinter.cpp @@ -83,12 +83,16 @@ bool LinePrinter::IsCompilandExcluded(llvm::StringRef CompilandName) { ExcludeCompilandFilters); } -WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) { - if (P.hasColor()) +WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) + : OS(P.OS), UseColor(P.hasColor()) { + if (UseColor) applyColor(C); } -WithColor::~WithColor() { OS.resetColor(); } +WithColor::~WithColor() { + if (UseColor) + OS.resetColor(); +} void WithColor::applyColor(PDB_ColorItem C) { switch (C) { diff --git a/llvm/tools/llvm-pdbdump/LinePrinter.h b/llvm/tools/llvm-pdbdump/LinePrinter.h index 29933e4..87c51e3 100644 --- a/llvm/tools/llvm-pdbdump/LinePrinter.h +++ b/llvm/tools/llvm-pdbdump/LinePrinter.h @@ -89,6 +89,7 @@ public: private: void applyColor(PDB_ColorItem C); raw_ostream &OS; + bool UseColor; }; } } -- 2.7.4