1 //===- PrettyBuiltinDumper.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 "PrettyBuiltinDumper.h" 11 #include "LinePrinter.h" 12 13 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" 14 15 using namespace llvm; 16 using namespace llvm::pdb; 17 BuiltinDumper(LinePrinter & P)18BuiltinDumper::BuiltinDumper(LinePrinter &P) 19 : PDBSymDumper(false), Printer(P) {} 20 start(const PDBSymbolTypeBuiltin & Symbol)21void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) { 22 if (Symbol.isConstType()) 23 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; 24 if (Symbol.isVolatileType()) 25 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; 26 WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol); 27 } 28 getTypeName(const PDBSymbolTypeBuiltin & Symbol)29StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) { 30 PDB_BuiltinType Type = Symbol.getBuiltinType(); 31 switch (Type) { 32 case PDB_BuiltinType::Float: 33 if (Symbol.getLength() == 4) 34 return "float"; 35 return "double"; 36 case PDB_BuiltinType::UInt: 37 switch (Symbol.getLength()) { 38 case 8: 39 return "unsigned __int64"; 40 case 4: 41 return "unsigned int"; 42 case 2: 43 return "unsigned short"; 44 case 1: 45 return "unsigned char"; 46 default: 47 return "unsigned"; 48 } 49 case PDB_BuiltinType::Int: 50 switch (Symbol.getLength()) { 51 case 8: 52 return "__int64"; 53 case 4: 54 return "int"; 55 case 2: 56 return "short"; 57 case 1: 58 return "char"; 59 default: 60 return "int"; 61 } 62 case PDB_BuiltinType::Char: 63 return "char"; 64 case PDB_BuiltinType::WCharT: 65 return "wchar_t"; 66 case PDB_BuiltinType::Void: 67 return "void"; 68 case PDB_BuiltinType::Long: 69 return "long"; 70 case PDB_BuiltinType::ULong: 71 return "unsigned long"; 72 case PDB_BuiltinType::Bool: 73 return "bool"; 74 case PDB_BuiltinType::Currency: 75 return "CURRENCY"; 76 case PDB_BuiltinType::Date: 77 return "DATE"; 78 case PDB_BuiltinType::Variant: 79 return "VARIANT"; 80 case PDB_BuiltinType::Complex: 81 return "complex"; 82 case PDB_BuiltinType::Bitfield: 83 return "bitfield"; 84 case PDB_BuiltinType::BSTR: 85 return "BSTR"; 86 case PDB_BuiltinType::HResult: 87 return "HRESULT"; 88 case PDB_BuiltinType::BCD: 89 return "HRESULT"; 90 case PDB_BuiltinType::Char16: 91 return "char16_t"; 92 case PDB_BuiltinType::Char32: 93 return "char32_t"; 94 case PDB_BuiltinType::None: 95 return "..."; 96 } 97 llvm_unreachable("Unknown PDB_BuiltinType"); 98 } 99