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