llvm-pdbdump: If we don't change the color, don't reset the color.
authorAdrian McCarthy <amccarth@google.com>
Wed, 29 Mar 2017 17:11:27 +0000 (17:11 +0000)
committerAdrian McCarthy <amccarth@google.com>
Wed, 29 Mar 2017 17:11:27 +0000 (17:11 +0000)
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
llvm/tools/llvm-pdbdump/LinePrinter.h

index 14f8c78..d376810 100644 (file)
@@ -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) {
index 29933e4..87c51e3 100644 (file)
@@ -89,6 +89,7 @@ public:
 private:
   void applyColor(PDB_ColorItem C);
   raw_ostream &OS;
+  bool UseColor;
 };
 }
 }