1 //===- PrettyTypedefDumper.cpp - PDBSymDumper impl for typedefs -- * C++ *-===//
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
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"
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() << " "
40 void TypedefDumper::dump(const PDBSymbolTypeArray
&Symbol
) {
41 TypeDumper
Dumper(Printer
);
45 void TypedefDumper::dump(const PDBSymbolTypeBuiltin
&Symbol
) {
46 BuiltinDumper
Dumper(Printer
);
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
);
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();