[lit] Remove LitTestCase
[llvm-complete.git] / tools / llvm-pdbutil / PrettyTypedefDumper.cpp
blobef73a8cdf9c48e5ab39ee35cb67149e6e90b83c7
1 //===- PrettyTypedefDumper.cpp - PDBSymDumper impl for typedefs -- * 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 //===----------------------------------------------------------------------===//
9 #include "PrettyTypedefDumper.h"
11 #include "LinePrinter.h"
12 #include "PrettyBuiltinDumper.h"
13 #include "PrettyFunctionDumper.h"
14 #include "PrettyTypeDumper.h"
16 #include "llvm/DebugInfo/PDB/IPDBSession.h"
17 #include "llvm/DebugInfo/PDB/PDBExtras.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
24 using namespace llvm;
25 using namespace llvm::pdb;
27 TypedefDumper::TypedefDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
29 void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol) {
30 WithColor(Printer, PDB_ColorItem::Keyword).get() << "typedef ";
31 uint32_t TargetId = Symbol.getTypeId();
32 if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId))
33 TypeSymbol->dump(*this);
34 WithColor(Printer, PDB_ColorItem::Identifier).get() << " "
35 << Symbol.getName();
38 void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol) {
39 TypeDumper Dumper(Printer);
40 Dumper.dump(Symbol);
43 void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
44 BuiltinDumper Dumper(Printer);
45 Dumper.start(Symbol);
48 void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol) {
49 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
50 WithColor(Printer, PDB_ColorItem::Type).get() << " " << Symbol.getName();
53 void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) {
54 if (Symbol.isConstType())
55 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
56 if (Symbol.isVolatileType())
57 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
58 auto PointeeType = Symbol.getPointeeType();
59 if (auto FuncSig = unique_dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType)) {
60 FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer;
61 if (Symbol.isReference())
62 Pointer = FunctionDumper::PointerType::Reference;
63 FunctionDumper NestedDumper(Printer);
64 NestedDumper.start(*FuncSig, nullptr, Pointer);
65 } else {
66 PointeeType->dump(*this);
67 Printer << ((Symbol.isReference()) ? "&" : "*");
70 if (Symbol.getRawSymbol().isRestrictedType())
71 WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict";
74 void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
75 FunctionDumper Dumper(Printer);
76 Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
79 void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol) {
80 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
81 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();