]> granicus.if.org Git - llvm/commitdiff
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299006 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-pdbdump/LinePrinter.cpp
tools/llvm-pdbdump/LinePrinter.h

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