10b57cec5SDimitry Andric //===- PrettyBuiltinDumper.cpp ---------------------------------- *- C++ *-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "PrettyBuiltinDumper.h" 100b57cec5SDimitry Andric 11*81ad6265SDimitry Andric #include "llvm/DebugInfo/PDB/Native/LinePrinter.h" 120b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric using namespace llvm; 150b57cec5SDimitry Andric using namespace llvm::pdb; 160b57cec5SDimitry Andric BuiltinDumper(LinePrinter & P)170b57cec5SDimitry AndricBuiltinDumper::BuiltinDumper(LinePrinter &P) 180b57cec5SDimitry Andric : PDBSymDumper(false), Printer(P) {} 190b57cec5SDimitry Andric start(const PDBSymbolTypeBuiltin & Symbol)200b57cec5SDimitry Andricvoid BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) { 210b57cec5SDimitry Andric if (Symbol.isConstType()) 220b57cec5SDimitry Andric WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; 230b57cec5SDimitry Andric if (Symbol.isVolatileType()) 240b57cec5SDimitry Andric WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; 250b57cec5SDimitry Andric WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol); 260b57cec5SDimitry Andric } 270b57cec5SDimitry Andric getTypeName(const PDBSymbolTypeBuiltin & Symbol)280b57cec5SDimitry AndricStringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) { 290b57cec5SDimitry Andric PDB_BuiltinType Type = Symbol.getBuiltinType(); 300b57cec5SDimitry Andric switch (Type) { 310b57cec5SDimitry Andric case PDB_BuiltinType::Float: 320b57cec5SDimitry Andric if (Symbol.getLength() == 4) 330b57cec5SDimitry Andric return "float"; 340b57cec5SDimitry Andric return "double"; 350b57cec5SDimitry Andric case PDB_BuiltinType::UInt: 360b57cec5SDimitry Andric switch (Symbol.getLength()) { 370b57cec5SDimitry Andric case 8: 380b57cec5SDimitry Andric return "unsigned __int64"; 390b57cec5SDimitry Andric case 4: 400b57cec5SDimitry Andric return "unsigned int"; 410b57cec5SDimitry Andric case 2: 420b57cec5SDimitry Andric return "unsigned short"; 430b57cec5SDimitry Andric case 1: 440b57cec5SDimitry Andric return "unsigned char"; 450b57cec5SDimitry Andric default: 460b57cec5SDimitry Andric return "unsigned"; 470b57cec5SDimitry Andric } 480b57cec5SDimitry Andric case PDB_BuiltinType::Int: 490b57cec5SDimitry Andric switch (Symbol.getLength()) { 500b57cec5SDimitry Andric case 8: 510b57cec5SDimitry Andric return "__int64"; 520b57cec5SDimitry Andric case 4: 530b57cec5SDimitry Andric return "int"; 540b57cec5SDimitry Andric case 2: 550b57cec5SDimitry Andric return "short"; 560b57cec5SDimitry Andric case 1: 570b57cec5SDimitry Andric return "char"; 580b57cec5SDimitry Andric default: 590b57cec5SDimitry Andric return "int"; 600b57cec5SDimitry Andric } 610b57cec5SDimitry Andric case PDB_BuiltinType::Char: 620b57cec5SDimitry Andric return "char"; 630b57cec5SDimitry Andric case PDB_BuiltinType::WCharT: 640b57cec5SDimitry Andric return "wchar_t"; 650b57cec5SDimitry Andric case PDB_BuiltinType::Void: 660b57cec5SDimitry Andric return "void"; 670b57cec5SDimitry Andric case PDB_BuiltinType::Long: 680b57cec5SDimitry Andric return "long"; 690b57cec5SDimitry Andric case PDB_BuiltinType::ULong: 700b57cec5SDimitry Andric return "unsigned long"; 710b57cec5SDimitry Andric case PDB_BuiltinType::Bool: 720b57cec5SDimitry Andric return "bool"; 730b57cec5SDimitry Andric case PDB_BuiltinType::Currency: 740b57cec5SDimitry Andric return "CURRENCY"; 750b57cec5SDimitry Andric case PDB_BuiltinType::Date: 760b57cec5SDimitry Andric return "DATE"; 770b57cec5SDimitry Andric case PDB_BuiltinType::Variant: 780b57cec5SDimitry Andric return "VARIANT"; 790b57cec5SDimitry Andric case PDB_BuiltinType::Complex: 800b57cec5SDimitry Andric return "complex"; 810b57cec5SDimitry Andric case PDB_BuiltinType::Bitfield: 820b57cec5SDimitry Andric return "bitfield"; 830b57cec5SDimitry Andric case PDB_BuiltinType::BSTR: 840b57cec5SDimitry Andric return "BSTR"; 850b57cec5SDimitry Andric case PDB_BuiltinType::HResult: 860b57cec5SDimitry Andric return "HRESULT"; 870b57cec5SDimitry Andric case PDB_BuiltinType::BCD: 880b57cec5SDimitry Andric return "HRESULT"; 890b57cec5SDimitry Andric case PDB_BuiltinType::Char16: 900b57cec5SDimitry Andric return "char16_t"; 910b57cec5SDimitry Andric case PDB_BuiltinType::Char32: 920b57cec5SDimitry Andric return "char32_t"; 93*81ad6265SDimitry Andric case PDB_BuiltinType::Char8: 94*81ad6265SDimitry Andric return "char8_t"; 950b57cec5SDimitry Andric case PDB_BuiltinType::None: 960b57cec5SDimitry Andric return "..."; 970b57cec5SDimitry Andric } 980b57cec5SDimitry Andric llvm_unreachable("Unknown PDB_BuiltinType"); 990b57cec5SDimitry Andric } 100