1 //===- PrettyTypedefDumper.cpp - PDBSymDumper impl for typedefs -- * C++ *-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "PrettyTypedefDumper.h"
12 #include "LinePrinter.h"
13 #include "PrettyBuiltinDumper.h"
14 #include "PrettyFunctionDumper.h"
15 #include "llvm-pdbdump.h"
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/PDBExtras.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
26 using namespace llvm::pdb;
28 TypedefDumper::TypedefDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
30 void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol) {
31 WithColor(Printer, PDB_ColorItem::Keyword).get() << "typedef ";
32 uint32_t TargetId = Symbol.getTypeId();
33 if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId))
34 TypeSymbol->dump(*this);
35 WithColor(Printer, PDB_ColorItem::Identifier).get() << " "
39 void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol) {}
41 void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
42 BuiltinDumper Dumper(Printer);
46 void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol) {
47 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
48 WithColor(Printer, PDB_ColorItem::Type).get() << " " << Symbol.getName();
51 void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) {
52 if (Symbol.isConstType())
53 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
54 if (Symbol.isVolatileType())
55 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
56 uint32_t PointeeId = Symbol.getTypeId();
57 auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
60 if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
61 FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer;
62 if (Symbol.isReference())
63 Pointer = FunctionDumper::PointerType::Reference;
64 FunctionDumper NestedDumper(Printer);
65 NestedDumper.start(*FuncSig, nullptr, Pointer);
67 PointeeType->dump(*this);
68 Printer << ((Symbol.isReference()) ? "&" : "*");
72 void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
73 FunctionDumper Dumper(Printer);
74 Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
77 void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol) {
78 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
79 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();