[llvm] r251873 - llvm-pdbdump: Simplify. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 17:04:44 PST 2015


Author: ruiu
Date: Mon Nov  2 19:04:44 2015
New Revision: 251873

URL: http://llvm.org/viewvc/llvm-project?rev=251873&view=rev
Log:
llvm-pdbdump: Simplify. NFC.

Modified:
    llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
    llvm/trunk/tools/llvm-pdbdump/LinePrinter.h

Modified: llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp?rev=251873&r1=251872&r2=251873&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp Mon Nov  2 19:04:44 2015
@@ -84,54 +84,40 @@ bool LinePrinter::IsCompilandExcluded(ll
 }
 
 WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) {
-  if (C == PDB_ColorItem::None)
-    OS.resetColor();
-  else {
-    raw_ostream::Colors Color;
-    bool Bold;
-    translateColor(C, Color, Bold);
-    OS.changeColor(Color, Bold);
-  }
+  applyColor(C);
 }
 
 WithColor::~WithColor() { OS.resetColor(); }
 
-void WithColor::translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
-                               bool &Bold) const {
+void WithColor::applyColor(PDB_ColorItem C) {
   switch (C) {
+  case PDB_ColorItem::None:
+    OS.resetColor();
+    return;
   case PDB_ColorItem::Address:
-    Color = raw_ostream::YELLOW;
-    Bold = true;
+    OS.changeColor(raw_ostream::YELLOW, /*bold=*/true);
     return;
   case PDB_ColorItem::Keyword:
-    Color = raw_ostream::MAGENTA;
-    Bold = true;
+    OS.changeColor(raw_ostream::MAGENTA, true);
     return;
   case PDB_ColorItem::Register:
   case PDB_ColorItem::Offset:
-    Color = raw_ostream::YELLOW;
-    Bold = false;
+    OS.changeColor(raw_ostream::YELLOW, false);
     return;
   case PDB_ColorItem::Type:
-    Color = raw_ostream::CYAN;
-    Bold = true;
+    OS.changeColor(raw_ostream::CYAN, true);
     return;
   case PDB_ColorItem::Identifier:
-    Color = raw_ostream::CYAN;
-    Bold = false;
+    OS.changeColor(raw_ostream::CYAN, false);
     return;
   case PDB_ColorItem::Path:
-    Color = raw_ostream::CYAN;
-    Bold = false;
+    OS.changeColor(raw_ostream::CYAN, false);
     return;
   case PDB_ColorItem::SectionHeader:
-    Color = raw_ostream::RED;
-    Bold = true;
+    OS.changeColor(raw_ostream::RED, true);
     return;
   case PDB_ColorItem::LiteralValue:
-    Color = raw_ostream::GREEN;
-    Bold = true;
-  default:
+    OS.changeColor(raw_ostream::GREEN, true);
     return;
   }
 }

Modified: llvm/trunk/tools/llvm-pdbdump/LinePrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LinePrinter.h?rev=251873&r1=251872&r2=251873&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/LinePrinter.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/LinePrinter.h Mon Nov  2 19:04:44 2015
@@ -84,8 +84,7 @@ public:
   raw_ostream &get() { return OS; }
 
 private:
-  void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
-                      bool &Bold) const;
+  void applyColor(PDB_ColorItem C);
   raw_ostream &OS;
 };
 }




More information about the llvm-commits mailing list