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