1 //===- PrettyBuiltinDumper.cpp ---------------------------------- *- C++ *-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "PrettyBuiltinDumper.h"
10 #include "LinePrinter.h"
12 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
15 using namespace llvm::pdb
;
17 BuiltinDumper::BuiltinDumper(LinePrinter
&P
)
18 : PDBSymDumper(false), Printer(P
) {}
20 void BuiltinDumper::start(const PDBSymbolTypeBuiltin
&Symbol
) {
21 if (Symbol
.isConstType())
22 WithColor(Printer
, PDB_ColorItem::Keyword
).get() << "const ";
23 if (Symbol
.isVolatileType())
24 WithColor(Printer
, PDB_ColorItem::Keyword
).get() << "volatile ";
25 WithColor(Printer
, PDB_ColorItem::Type
).get() << getTypeName(Symbol
);
28 StringRef
BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin
&Symbol
) {
29 PDB_BuiltinType Type
= Symbol
.getBuiltinType();
31 case PDB_BuiltinType::Float
:
32 if (Symbol
.getLength() == 4)
35 case PDB_BuiltinType::UInt
:
36 switch (Symbol
.getLength()) {
38 return "unsigned __int64";
40 return "unsigned int";
42 return "unsigned short";
44 return "unsigned char";
48 case PDB_BuiltinType::Int
:
49 switch (Symbol
.getLength()) {
61 case PDB_BuiltinType::Char
:
63 case PDB_BuiltinType::WCharT
:
65 case PDB_BuiltinType::Void
:
67 case PDB_BuiltinType::Long
:
69 case PDB_BuiltinType::ULong
:
70 return "unsigned long";
71 case PDB_BuiltinType::Bool
:
73 case PDB_BuiltinType::Currency
:
75 case PDB_BuiltinType::Date
:
77 case PDB_BuiltinType::Variant
:
79 case PDB_BuiltinType::Complex
:
81 case PDB_BuiltinType::Bitfield
:
83 case PDB_BuiltinType::BSTR
:
85 case PDB_BuiltinType::HResult
:
87 case PDB_BuiltinType::BCD
:
89 case PDB_BuiltinType::Char16
:
91 case PDB_BuiltinType::Char32
:
93 case PDB_BuiltinType::None
:
96 llvm_unreachable("Unknown PDB_BuiltinType");