1 //===- BuiltinDumper.cpp ---------------------------------------- *- C++ *-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "BuiltinDumper.h"
11 #include "LinePrinter.h"
12 #include "llvm-pdbdump.h"
13 
14 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
15 
16 using namespace llvm;
17 
BuiltinDumper(LinePrinter & P)18 BuiltinDumper::BuiltinDumper(LinePrinter &P)
19     : PDBSymDumper(false), Printer(P) {}
20 
start(const PDBSymbolTypeBuiltin & Symbol)21 void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) {
22   WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol);
23 }
24 
getTypeName(const PDBSymbolTypeBuiltin & Symbol)25 StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
26   PDB_BuiltinType Type = Symbol.getBuiltinType();
27   switch (Type) {
28   case PDB_BuiltinType::Float:
29     if (Symbol.getLength() == 4)
30       return "float";
31     return "double";
32   case PDB_BuiltinType::UInt:
33     if (Symbol.getLength() == 8)
34       return "unsigned __int64";
35     return "unsigned";
36   case PDB_BuiltinType::Int:
37     if (Symbol.getLength() == 4)
38       return "int";
39     return "__int64";
40   case PDB_BuiltinType::Char:
41     return "char";
42   case PDB_BuiltinType::WCharT:
43     return "wchar_t";
44   case PDB_BuiltinType::Void:
45     return "void";
46   case PDB_BuiltinType::Long:
47     return "long";
48   case PDB_BuiltinType::ULong:
49     return "unsigned long";
50   case PDB_BuiltinType::Bool:
51     return "bool";
52   case PDB_BuiltinType::Currency:
53     return "CURRENCY";
54   case PDB_BuiltinType::Date:
55     return "DATE";
56   case PDB_BuiltinType::Variant:
57     return "VARIANT";
58   case PDB_BuiltinType::Complex:
59     return "complex";
60   case PDB_BuiltinType::Bitfield:
61     return "bitfield";
62   case PDB_BuiltinType::BSTR:
63     return "BSTR";
64   case PDB_BuiltinType::HResult:
65     return "HRESULT";
66   case PDB_BuiltinType::BCD:
67     return "HRESULT";
68   default:
69     return "void";
70   }
71 }
72