[llvm] r251974 - llmv-pdbdump: Make BuiltinDumper shorter. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 12:16:18 PST 2015


Author: ruiu
Date: Tue Nov  3 14:16:18 2015
New Revision: 251974

URL: http://llvm.org/viewvc/llvm-project?rev=251974&view=rev
Log:
llmv-pdbdump: Make BuiltinDumper shorter. NFC.

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

Modified: llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.cpp?rev=251974&r1=251973&r2=251974&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.cpp Tue Nov  3 14:16:18 2015
@@ -19,69 +19,53 @@ BuiltinDumper::BuiltinDumper(LinePrinter
     : PDBSymDumper(false), Printer(P) {}
 
 void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) {
+  WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol);
+}
+
+StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
   PDB_BuiltinType Type = Symbol.getBuiltinType();
   switch (Type) {
   case PDB_BuiltinType::Float:
     if (Symbol.getLength() == 4)
-      WithColor(Printer, PDB_ColorItem::Type).get() << "float";
-    else
-      WithColor(Printer, PDB_ColorItem::Type).get() << "double";
-    break;
+      return "float";
+    return "double";
   case PDB_BuiltinType::UInt:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "unsigned";
     if (Symbol.getLength() == 8)
-      WithColor(Printer, PDB_ColorItem::Type).get() << " __int64";
-    break;
+      return "unsigned __int64";
+    return "unsigned";
   case PDB_BuiltinType::Int:
     if (Symbol.getLength() == 4)
-      WithColor(Printer, PDB_ColorItem::Type).get() << "int";
-    else
-      WithColor(Printer, PDB_ColorItem::Type).get() << "__int64";
-    break;
+      return "int";
+    return "__int64";
   case PDB_BuiltinType::Char:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "char";
-    break;
+    return "char";
   case PDB_BuiltinType::WCharT:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "wchar_t";
-    break;
+    return "wchar_t";
   case PDB_BuiltinType::Void:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "void";
-    break;
+    return "void";
   case PDB_BuiltinType::Long:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "long";
-    break;
+    return "long";
   case PDB_BuiltinType::ULong:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "unsigned long";
-    break;
+    return "unsigned long";
   case PDB_BuiltinType::Bool:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "bool";
-    break;
+    return "bool";
   case PDB_BuiltinType::Currency:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "CURRENCY";
-    break;
+    return "CURRENCY";
   case PDB_BuiltinType::Date:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "DATE";
-    break;
+    return "DATE";
   case PDB_BuiltinType::Variant:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "VARIANT";
-    break;
+    return "VARIANT";
   case PDB_BuiltinType::Complex:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "complex";
-    break;
+    return "complex";
   case PDB_BuiltinType::Bitfield:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "bitfield";
-    break;
+    return "bitfield";
   case PDB_BuiltinType::BSTR:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "BSTR";
-    break;
+    return "BSTR";
   case PDB_BuiltinType::HResult:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "HRESULT";
-    break;
+    return "HRESULT";
   case PDB_BuiltinType::BCD:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "HRESULT";
-    break;
+    return "HRESULT";
   default:
-    WithColor(Printer, PDB_ColorItem::Type).get() << "void";
-    break;
+    return "void";
   }
 }

Modified: llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.h?rev=251974&r1=251973&r2=251974&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/BuiltinDumper.h Tue Nov  3 14:16:18 2015
@@ -23,6 +23,8 @@ public:
   void start(const PDBSymbolTypeBuiltin &Symbol);
 
 private:
+  StringRef getTypeName(const PDBSymbolTypeBuiltin &Symbol);
+
   LinePrinter &Printer;
 };
 }




More information about the llvm-commits mailing list