Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / llvm / tools / llvm-pdbutil / PrettyTypedefDumper.cpp
blob197aa07299d122a1bc894e6b7d8a8b25afa037ed
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 "PrettyBuiltinDumper.h"
12 #include "PrettyFunctionDumper.h"
13 #include "PrettyTypeDumper.h"
15 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
16 #include "llvm/DebugInfo/PDB/IPDBSession.h"
17 #include "llvm/DebugInfo/PDB/Native/LinePrinter.h"
18 #include "llvm/DebugInfo/PDB/PDBExtras.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
26 using namespace llvm;
27 using namespace llvm::pdb;
29 TypedefDumper::TypedefDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
31 void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol) {
32 WithColor(Printer, PDB_ColorItem::Keyword).get() << "typedef ";
33 uint32_t TargetId = Symbol.getTypeId();
34 if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId))
35 TypeSymbol->dump(*this);
36 WithColor(Printer, PDB_ColorItem::Identifier).get() << " "
37 << Symbol.getName();
40 void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol) {
41 TypeDumper Dumper(Printer);
42 Dumper.dump(Symbol);
45 void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
46 BuiltinDumper Dumper(Printer);
47 Dumper.start(Symbol);
50 void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol) {
51 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
52 WithColor(Printer, PDB_ColorItem::Type).get() << " " << Symbol.getName();
55 void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) {
56 if (Symbol.isConstType())
57 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
58 if (Symbol.isVolatileType())
59 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
60 auto PointeeType = Symbol.getPointeeType();
61 if (auto FuncSig = unique_dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType)) {
62 FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer;
63 if (Symbol.isReference())
64 Pointer = FunctionDumper::PointerType::Reference;
65 FunctionDumper NestedDumper(Printer);
66 NestedDumper.start(*FuncSig, nullptr, Pointer);
67 } else {
68 PointeeType->dump(*this);
69 Printer << ((Symbol.isReference()) ? "&" : "*");
72 if (Symbol.getRawSymbol().isRestrictedType())
73 WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict";
76 void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
77 FunctionDumper Dumper(Printer);
78 Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
81 void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol) {
82 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
83 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();