1//===- MinimalTypeDumper.cpp ---------------------------------- *- 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//===----------------------------------------------------------------------===//
8
9#include "MinimalTypeDumper.h"
10
11#include "TypeReferenceTracker.h"
12
13#include "llvm-pdbutil.h"
14#include "llvm/ADT/StringExtras.h"
15#include "llvm/DebugInfo/CodeView/CVRecord.h"
16#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
17#include "llvm/DebugInfo/CodeView/CodeView.h"
18#include "llvm/DebugInfo/CodeView/Formatters.h"
19#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
20#include "llvm/DebugInfo/CodeView/TypeRecord.h"
21#include "llvm/DebugInfo/PDB/Native/FormatUtil.h"
22#include "llvm/DebugInfo/PDB/Native/LinePrinter.h"
23#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
24#include "llvm/DebugInfo/PDB/Native/TpiHashing.h"
25#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
26#include "llvm/Object/COFF.h"
27#include "llvm/Support/FormatVariadic.h"
28#include "llvm/Support/MathExtras.h"
29
30using namespace llvm;
31using namespace llvm::codeview;
32using namespace llvm::pdb;
33
34static std::string formatClassOptions(uint32_t IndentLevel,
35 ClassOptions Options, TpiStream *Stream,
36 TypeIndex CurrentTypeIndex) {
37 std::vector<std::string> Opts;
38
39 if (Stream && Stream->supportsTypeLookup() &&
40 !opts::dump::DontResolveForwardRefs &&
41 ((Options & ClassOptions::ForwardReference) != ClassOptions::None)) {
42 // If we're able to resolve forward references, do that.
43 Expected<TypeIndex> ETI =
44 Stream->findFullDeclForForwardRef(ForwardRefTI: CurrentTypeIndex);
45 if (!ETI) {
46 consumeError(Err: ETI.takeError());
47 PUSH_FLAG(ClassOptions, ForwardReference, Options, "forward ref (??\?)");
48 } else {
49 const char *Direction = (*ETI == CurrentTypeIndex)
50 ? "="
51 : ((*ETI < CurrentTypeIndex) ? "<-" : "->");
52 std::string Formatted =
53 formatv(Fmt: "forward ref ({0} {1})", Vals&: Direction, Vals&: *ETI).str();
54 PUSH_FLAG(ClassOptions, ForwardReference, Options, std::move(Formatted));
55 }
56 } else {
57 PUSH_FLAG(ClassOptions, ForwardReference, Options, "forward ref");
58 }
59
60 PUSH_FLAG(ClassOptions, HasConstructorOrDestructor, Options,
61 "has ctor / dtor");
62 PUSH_FLAG(ClassOptions, ContainsNestedClass, Options,
63 "contains nested class");
64 PUSH_FLAG(ClassOptions, HasConversionOperator, Options,
65 "conversion operator");
66 PUSH_FLAG(ClassOptions, HasUniqueName, Options, "has unique name");
67 PUSH_FLAG(ClassOptions, Intrinsic, Options, "intrin");
68 PUSH_FLAG(ClassOptions, Nested, Options, "is nested");
69 PUSH_FLAG(ClassOptions, HasOverloadedOperator, Options,
70 "overloaded operator");
71 PUSH_FLAG(ClassOptions, HasOverloadedAssignmentOperator, Options,
72 "overloaded operator=");
73 PUSH_FLAG(ClassOptions, Packed, Options, "packed");
74 PUSH_FLAG(ClassOptions, Scoped, Options, "scoped");
75 PUSH_FLAG(ClassOptions, Sealed, Options, "sealed");
76
77 return typesetItemList(Opts, IndentLevel: 4, GroupSize: IndentLevel, Sep: " | ");
78}
79
80static std::string pointerOptions(PointerOptions Options) {
81 std::vector<std::string> Opts;
82 PUSH_FLAG(PointerOptions, Flat32, Options, "flat32");
83 PUSH_FLAG(PointerOptions, Volatile, Options, "volatile");
84 PUSH_FLAG(PointerOptions, Const, Options, "const");
85 PUSH_FLAG(PointerOptions, Unaligned, Options, "unaligned");
86 PUSH_FLAG(PointerOptions, Restrict, Options, "restrict");
87 PUSH_FLAG(PointerOptions, WinRTSmartPointer, Options, "winrt");
88 if (Opts.empty())
89 return "None";
90 return join(R&: Opts, Separator: " | ");
91}
92
93static std::string modifierOptions(ModifierOptions Options) {
94 std::vector<std::string> Opts;
95 PUSH_FLAG(ModifierOptions, Const, Options, "const");
96 PUSH_FLAG(ModifierOptions, Volatile, Options, "volatile");
97 PUSH_FLAG(ModifierOptions, Unaligned, Options, "unaligned");
98 if (Opts.empty())
99 return "None";
100 return join(R&: Opts, Separator: " | ");
101}
102
103static std::string formatCallingConvention(CallingConvention Convention) {
104 switch (Convention) {
105 RETURN_CASE(CallingConvention, AlphaCall, "alphacall");
106 RETURN_CASE(CallingConvention, AM33Call, "am33call");
107 RETURN_CASE(CallingConvention, ArmCall, "armcall");
108 RETURN_CASE(CallingConvention, ClrCall, "clrcall");
109 RETURN_CASE(CallingConvention, FarC, "far cdecl");
110 RETURN_CASE(CallingConvention, FarFast, "far fastcall");
111 RETURN_CASE(CallingConvention, FarPascal, "far pascal");
112 RETURN_CASE(CallingConvention, FarStdCall, "far stdcall");
113 RETURN_CASE(CallingConvention, FarSysCall, "far syscall");
114 RETURN_CASE(CallingConvention, Generic, "generic");
115 RETURN_CASE(CallingConvention, Inline, "inline");
116 RETURN_CASE(CallingConvention, M32RCall, "m32rcall");
117 RETURN_CASE(CallingConvention, MipsCall, "mipscall");
118 RETURN_CASE(CallingConvention, NearC, "cdecl");
119 RETURN_CASE(CallingConvention, NearFast, "fastcall");
120 RETURN_CASE(CallingConvention, NearPascal, "pascal");
121 RETURN_CASE(CallingConvention, NearStdCall, "stdcall");
122 RETURN_CASE(CallingConvention, NearSysCall, "near syscall");
123 RETURN_CASE(CallingConvention, NearVector, "vectorcall");
124 RETURN_CASE(CallingConvention, PpcCall, "ppccall");
125 RETURN_CASE(CallingConvention, SHCall, "shcall");
126 RETURN_CASE(CallingConvention, SH5Call, "sh5call");
127 RETURN_CASE(CallingConvention, Swift, "swift");
128 RETURN_CASE(CallingConvention, ThisCall, "thiscall");
129 RETURN_CASE(CallingConvention, TriCall, "tricall");
130 }
131 return formatUnknownEnum(Value: Convention);
132}
133
134static std::string formatPointerMode(PointerMode Mode) {
135 switch (Mode) {
136 RETURN_CASE(PointerMode, LValueReference, "ref");
137 RETURN_CASE(PointerMode, Pointer, "pointer");
138 RETURN_CASE(PointerMode, PointerToDataMember, "data member pointer");
139 RETURN_CASE(PointerMode, PointerToMemberFunction, "member fn pointer");
140 RETURN_CASE(PointerMode, RValueReference, "rvalue ref");
141 }
142 return formatUnknownEnum(Value: Mode);
143}
144
145static std::string memberAccess(MemberAccess Access) {
146 switch (Access) {
147 RETURN_CASE(MemberAccess, None, "");
148 RETURN_CASE(MemberAccess, Private, "private");
149 RETURN_CASE(MemberAccess, Protected, "protected");
150 RETURN_CASE(MemberAccess, Public, "public");
151 }
152 return formatUnknownEnum(Value: Access);
153}
154
155static std::string methodKind(MethodKind Kind) {
156 switch (Kind) {
157 RETURN_CASE(MethodKind, Vanilla, "");
158 RETURN_CASE(MethodKind, Virtual, "virtual");
159 RETURN_CASE(MethodKind, Static, "static");
160 RETURN_CASE(MethodKind, Friend, "friend");
161 RETURN_CASE(MethodKind, IntroducingVirtual, "intro virtual");
162 RETURN_CASE(MethodKind, PureVirtual, "pure virtual");
163 RETURN_CASE(MethodKind, PureIntroducingVirtual, "pure intro virtual");
164 }
165 return formatUnknownEnum(Value: Kind);
166}
167
168static std::string pointerKind(PointerKind Kind) {
169 switch (Kind) {
170 RETURN_CASE(PointerKind, Near16, "ptr16");
171 RETURN_CASE(PointerKind, Far16, "far ptr16");
172 RETURN_CASE(PointerKind, Huge16, "huge ptr16");
173 RETURN_CASE(PointerKind, BasedOnSegment, "segment based");
174 RETURN_CASE(PointerKind, BasedOnValue, "value based");
175 RETURN_CASE(PointerKind, BasedOnSegmentValue, "segment value based");
176 RETURN_CASE(PointerKind, BasedOnAddress, "address based");
177 RETURN_CASE(PointerKind, BasedOnSegmentAddress, "segment address based");
178 RETURN_CASE(PointerKind, BasedOnType, "type based");
179 RETURN_CASE(PointerKind, BasedOnSelf, "self based");
180 RETURN_CASE(PointerKind, Near32, "ptr32");
181 RETURN_CASE(PointerKind, Far32, "far ptr32");
182 RETURN_CASE(PointerKind, Near64, "ptr64");
183 }
184 return formatUnknownEnum(Value: Kind);
185}
186
187static std::string memberAttributes(const MemberAttributes &Attrs) {
188 std::vector<std::string> Opts;
189 std::string Access = memberAccess(Access: Attrs.getAccess());
190 std::string Kind = methodKind(Kind: Attrs.getMethodKind());
191 if (!Access.empty())
192 Opts.push_back(x: Access);
193 if (!Kind.empty())
194 Opts.push_back(x: Kind);
195 MethodOptions Flags = Attrs.getFlags();
196 PUSH_FLAG(MethodOptions, Pseudo, Flags, "pseudo");
197 PUSH_FLAG(MethodOptions, NoInherit, Flags, "noinherit");
198 PUSH_FLAG(MethodOptions, NoConstruct, Flags, "noconstruct");
199 PUSH_FLAG(MethodOptions, CompilerGenerated, Flags, "compiler-generated");
200 PUSH_FLAG(MethodOptions, Sealed, Flags, "sealed");
201 return join(R&: Opts, Separator: " ");
202}
203
204static std::string formatPointerAttrs(const PointerRecord &Record) {
205 PointerMode Mode = Record.getMode();
206 PointerOptions Opts = Record.getOptions();
207 PointerKind Kind = Record.getPointerKind();
208 return std::string(formatv(Fmt: "mode = {0}, opts = {1}, kind = {2}",
209 Vals: formatPointerMode(Mode), Vals: pointerOptions(Options: Opts),
210 Vals: pointerKind(Kind)));
211}
212
213static std::string formatFunctionOptions(FunctionOptions Options) {
214 std::vector<std::string> Opts;
215
216 PUSH_FLAG(FunctionOptions, CxxReturnUdt, Options, "returns cxx udt");
217 PUSH_FLAG(FunctionOptions, ConstructorWithVirtualBases, Options,
218 "constructor with virtual bases");
219 PUSH_FLAG(FunctionOptions, Constructor, Options, "constructor");
220 if (Opts.empty())
221 return "None";
222 return join(R&: Opts, Separator: " | ");
223}
224
225Error MinimalTypeDumpVisitor::visitTypeBegin(CVType &Record, TypeIndex Index) {
226 CurrentTypeIndex = Index;
227 // formatLine puts the newline at the beginning, so we use formatLine here
228 // to start a new line, and then individual visit methods use format to
229 // append to the existing line.
230 P.formatLine(Fmt: "{0} | {1} [size = {2}",
231 Items: fmt_align(Item&: Index, Where: AlignStyle::Right, Amount: Width),
232 Items: formatTypeLeafKind(K: Record.kind()), Items: Record.length());
233 if (Hashes) {
234 std::string H;
235 if (Index.toArrayIndex() >= HashValues.size()) {
236 H = "(not present)";
237 } else {
238 uint32_t Hash = HashValues[Index.toArrayIndex()];
239 Expected<uint32_t> MaybeHash = hashTypeRecord(Type: Record);
240 if (!MaybeHash)
241 return MaybeHash.takeError();
242 uint32_t OurHash = *MaybeHash;
243 OurHash %= NumHashBuckets;
244 if (Hash == OurHash)
245 H = "0x" + utohexstr(X: Hash);
246 else
247 H = "0x" + utohexstr(X: Hash) + ", our hash = 0x" + utohexstr(X: OurHash);
248 }
249 P.format(Fmt: ", hash = {0}", Items&: H);
250 }
251 if (RefTracker) {
252 if (RefTracker->isTypeReferenced(TI: Index))
253 P.format(Fmt: ", referenced");
254 else
255 P.format(Fmt: ", unreferenced");
256 }
257 P.format(Fmt: "]");
258 P.Indent(Amount: Width + 3);
259 return Error::success();
260}
261
262Error MinimalTypeDumpVisitor::visitTypeEnd(CVType &Record) {
263 if (RecordBytes)
264 P.formatBinary(Label: "bytes", Data: Record.RecordData, StartOffset: 0);
265 P.Unindent(Amount: Width + 3);
266 return Error::success();
267}
268
269Error MinimalTypeDumpVisitor::visitUnknownType(CVType &Record) {
270 if (!RecordBytes)
271 P.formatBinary(Label: "bytes", Data: Record.RecordData, StartOffset: 0);
272 return Error::success();
273}
274
275Error MinimalTypeDumpVisitor::visitMemberBegin(CVMemberRecord &Record) {
276 P.formatLine(Fmt: "- {0}", Items: formatTypeLeafKind(K: Record.Kind));
277 return Error::success();
278}
279
280Error MinimalTypeDumpVisitor::visitMemberEnd(CVMemberRecord &Record) {
281 if (RecordBytes) {
282 AutoIndent Indent(P, 2);
283 P.formatBinary(Label: "bytes", Data: Record.Data, StartOffset: 0);
284 }
285 return Error::success();
286}
287
288Error MinimalTypeDumpVisitor::visitUnknownMember(CVMemberRecord &Record) {
289 if (!RecordBytes) {
290 AutoIndent Indent(P, 2);
291 P.formatBinary(Label: "bytes", Data: Record.Data, StartOffset: 0);
292 }
293 return Error::success();
294}
295
296StringRef MinimalTypeDumpVisitor::getTypeName(TypeIndex TI) const {
297 if (TI.isNoneType())
298 return "";
299 return Types.getTypeName(Index: TI);
300}
301
302Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
303 FieldListRecord &FieldList) {
304 if (auto EC = codeview::visitMemberRecordStream(FieldList: FieldList.Data, Callbacks&: *this))
305 return EC;
306
307 return Error::success();
308}
309
310Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
311 StringIdRecord &String) {
312 P.format(Fmt: " ID: {0}, String: {1}", Items: String.getId(), Items: String.getString());
313 return Error::success();
314}
315
316Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
317 ArgListRecord &Args) {
318 auto Indices = Args.getIndices();
319 if (Indices.empty())
320 return Error::success();
321
322 auto Max = llvm::max_element(Range&: Indices);
323 uint32_t W = NumDigitsBase10(X: Max->getIndex()) + 2;
324
325 for (auto I : Indices)
326 P.formatLine(Fmt: "{0}: `{1}`", Items: fmt_align(Item&: I, Where: AlignStyle::Right, Amount: W),
327 Items: getTypeName(TI: I));
328 return Error::success();
329}
330
331Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
332 StringListRecord &Strings) {
333 auto Indices = Strings.getIndices();
334 if (Indices.empty())
335 return Error::success();
336
337 auto Max = llvm::max_element(Range&: Indices);
338 uint32_t W = NumDigitsBase10(X: Max->getIndex()) + 2;
339
340 for (auto I : Indices)
341 P.formatLine(Fmt: "{0}: `{1}`", Items: fmt_align(Item&: I, Where: AlignStyle::Right, Amount: W),
342 Items: getTypeName(TI: I));
343 return Error::success();
344}
345
346Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
347 ClassRecord &Class) {
348 P.format(Fmt: " `{0}`", Items&: Class.Name);
349 if (Class.hasUniqueName())
350 P.formatLine(Fmt: "unique name: `{0}`", Items&: Class.UniqueName);
351 P.formatLine(Fmt: "vtable: {0}, base list: {1}, field list: {2}",
352 Items&: Class.VTableShape, Items&: Class.DerivationList, Items&: Class.FieldList);
353 P.formatLine(Fmt: "options: {0}, sizeof {1}",
354 Items: formatClassOptions(IndentLevel: P.getIndentLevel(), Options: Class.Options, Stream,
355 CurrentTypeIndex),
356 Items&: Class.Size);
357 return Error::success();
358}
359
360Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
361 UnionRecord &Union) {
362 P.format(Fmt: " `{0}`", Items&: Union.Name);
363 if (Union.hasUniqueName())
364 P.formatLine(Fmt: "unique name: `{0}`", Items&: Union.UniqueName);
365 P.formatLine(Fmt: "field list: {0}", Items&: Union.FieldList);
366 P.formatLine(Fmt: "options: {0}, sizeof {1}",
367 Items: formatClassOptions(IndentLevel: P.getIndentLevel(), Options: Union.Options, Stream,
368 CurrentTypeIndex),
369 Items&: Union.Size);
370 return Error::success();
371}
372
373Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR, EnumRecord &Enum) {
374 P.format(Fmt: " `{0}`", Items&: Enum.Name);
375 if (Enum.hasUniqueName())
376 P.formatLine(Fmt: "unique name: `{0}`", Items&: Enum.UniqueName);
377 P.formatLine(Fmt: "field list: {0}, underlying type: {1}", Items&: Enum.FieldList,
378 Items&: Enum.UnderlyingType);
379 P.formatLine(Fmt: "options: {0}",
380 Items: formatClassOptions(IndentLevel: P.getIndentLevel(), Options: Enum.Options, Stream,
381 CurrentTypeIndex));
382 return Error::success();
383}
384
385Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR, ArrayRecord &AT) {
386 if (AT.Name.empty()) {
387 P.formatLine(Fmt: "size: {0}, index type: {1}, element type: {2}", Items&: AT.Size,
388 Items&: AT.IndexType, Items&: AT.ElementType);
389 } else {
390 P.formatLine(Fmt: "name: {0}, size: {1}, index type: {2}, element type: {3}",
391 Items&: AT.Name, Items&: AT.Size, Items&: AT.IndexType, Items&: AT.ElementType);
392 }
393 return Error::success();
394}
395
396Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
397 VFTableRecord &VFT) {
398 P.formatLine(Fmt: "offset: {0}, complete class: {1}, overridden vftable: {2}",
399 Items&: VFT.VFPtrOffset, Items&: VFT.CompleteClass, Items&: VFT.OverriddenVFTable);
400 P.formatLine(Fmt: "method names: ");
401 if (!VFT.MethodNames.empty()) {
402 std::string Sep =
403 formatv(Fmt: "\n{0}",
404 Vals: fmt_repeat(Item: ' ', Count: P.getIndentLevel() + strlen(s: "method names: ")))
405 .str();
406 P.print(T: join(R&: VFT.MethodNames, Separator: Sep));
407 }
408 return Error::success();
409}
410
411Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
412 MemberFuncIdRecord &Id) {
413 P.formatLine(Fmt: "name = {0}, type = {1}, class type = {2}", Items&: Id.Name,
414 Items&: Id.FunctionType, Items&: Id.ClassType);
415 return Error::success();
416}
417
418Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
419 ProcedureRecord &Proc) {
420 P.formatLine(Fmt: "return type = {0}, # args = {1}, param list = {2}",
421 Items&: Proc.ReturnType, Items&: Proc.ParameterCount, Items&: Proc.ArgumentList);
422 P.formatLine(Fmt: "calling conv = {0}, options = {1}",
423 Items: formatCallingConvention(Convention: Proc.CallConv),
424 Items: formatFunctionOptions(Options: Proc.Options));
425 return Error::success();
426}
427
428Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
429 MemberFunctionRecord &MF) {
430 P.formatLine(Fmt: "return type = {0}, # args = {1}, param list = {2}",
431 Items&: MF.ReturnType, Items&: MF.ParameterCount, Items&: MF.ArgumentList);
432 P.formatLine(Fmt: "class type = {0}, this type = {1}, this adjust = {2}",
433 Items&: MF.ClassType, Items&: MF.ThisType, Items&: MF.ThisPointerAdjustment);
434 P.formatLine(Fmt: "calling conv = {0}, options = {1}",
435 Items: formatCallingConvention(Convention: MF.CallConv),
436 Items: formatFunctionOptions(Options: MF.Options));
437 return Error::success();
438}
439
440Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
441 FuncIdRecord &Func) {
442 P.formatLine(Fmt: "name = {0}, type = {1}, parent scope = {2}", Items&: Func.Name,
443 Items&: Func.FunctionType, Items&: Func.ParentScope);
444 return Error::success();
445}
446
447Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
448 TypeServer2Record &TS) {
449 P.formatLine(Fmt: "name = {0}, age = {1}, guid = {2}", Items&: TS.Name, Items&: TS.Age, Items&: TS.Guid);
450 return Error::success();
451}
452
453Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
454 PointerRecord &Ptr) {
455 P.formatLine(Fmt: "referent = {0}, {1}", Items&: Ptr.ReferentType,
456 Items: formatPointerAttrs(Record: Ptr));
457 return Error::success();
458}
459
460Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
461 ModifierRecord &Mod) {
462 P.formatLine(Fmt: "referent = {0}, modifiers = {1}", Items&: Mod.ModifiedType,
463 Items: modifierOptions(Options: Mod.Modifiers));
464 return Error::success();
465}
466
467Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
468 VFTableShapeRecord &Shape) {
469 return Error::success();
470}
471
472Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
473 UdtModSourceLineRecord &U) {
474 P.formatLine(Fmt: "udt = {0}, mod = {1}, file = {2}, line = {3}", Items&: U.UDT, Items&: U.Module,
475 Items: U.SourceFile.getIndex(), Items&: U.LineNumber);
476 return Error::success();
477}
478
479Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
480 UdtSourceLineRecord &U) {
481 P.formatLine(Fmt: "udt = {0}, file = {1}, line = {2}", Items&: U.UDT,
482 Items: U.SourceFile.getIndex(), Items&: U.LineNumber);
483 return Error::success();
484}
485
486Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
487 BitFieldRecord &BF) {
488 P.formatLine(Fmt: "type = {0}, bit offset = {1}, # bits = {2}", Items&: BF.Type,
489 Items&: BF.BitOffset, Items&: BF.BitSize);
490 return Error::success();
491}
492
493Error MinimalTypeDumpVisitor::visitKnownRecord(
494 CVType &CVR, MethodOverloadListRecord &Overloads) {
495 for (auto &M : Overloads.Methods)
496 P.formatLine(Fmt: "- Method [type = {0}, vftable offset = {1}, attrs = {2}]",
497 Items&: M.Type, Items&: M.VFTableOffset, Items: memberAttributes(Attrs: M.Attrs));
498 return Error::success();
499}
500
501Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
502 BuildInfoRecord &BI) {
503 auto Indices = BI.ArgIndices;
504 if (Indices.empty())
505 return Error::success();
506
507 auto Max = llvm::max_element(Range&: Indices);
508 uint32_t W = NumDigitsBase10(X: Max->getIndex()) + 2;
509
510 for (auto I : Indices)
511 P.formatLine(Fmt: "{0}: `{1}`", Items: fmt_align(Item&: I, Where: AlignStyle::Right, Amount: W),
512 Items: getTypeName(TI: I));
513 return Error::success();
514}
515
516Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR, LabelRecord &R) {
517 std::string Type = (R.Mode == LabelType::Far) ? "far" : "near";
518 P.format(Fmt: " type = {0}", Items&: Type);
519 return Error::success();
520}
521
522Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
523 PrecompRecord &Precomp) {
524 P.format(Fmt: " start index = {0:X+}, types count = {1:X+}, signature = {2:X+},"
525 " precomp path = {3}",
526 Items&: Precomp.StartTypeIndex, Items&: Precomp.TypesCount, Items&: Precomp.Signature,
527 Items&: Precomp.PrecompFilePath);
528 return Error::success();
529}
530
531Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
532 EndPrecompRecord &EP) {
533 P.format(Fmt: " signature = {0:X+}", Items&: EP.Signature);
534 return Error::success();
535}
536
537Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
538 NestedTypeRecord &Nested) {
539 P.format(Fmt: " [name = `{0}`, parent = {1}]", Items&: Nested.Name, Items&: Nested.Type);
540 return Error::success();
541}
542
543Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
544 OneMethodRecord &Method) {
545 P.format(Fmt: " [name = `{0}`]", Items&: Method.Name);
546 AutoIndent Indent(P);
547 P.formatLine(Fmt: "type = {0}, vftable offset = {1}, attrs = {2}", Items&: Method.Type,
548 Items&: Method.VFTableOffset, Items: memberAttributes(Attrs: Method.Attrs));
549 return Error::success();
550}
551
552Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
553 OverloadedMethodRecord &Method) {
554 P.format(Fmt: " [name = `{0}`, # overloads = {1}, overload list = {2}]",
555 Items&: Method.Name, Items&: Method.NumOverloads, Items&: Method.MethodList);
556 return Error::success();
557}
558
559Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
560 DataMemberRecord &Field) {
561 P.format(Fmt: " [name = `{0}`, Type = {1}, offset = {2}, attrs = {3}]", Items&: Field.Name,
562 Items&: Field.Type, Items&: Field.FieldOffset, Items: memberAttributes(Attrs: Field.Attrs));
563 return Error::success();
564}
565
566Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
567 StaticDataMemberRecord &Field) {
568 P.format(Fmt: " [name = `{0}`, type = {1}, attrs = {2}]", Items&: Field.Name, Items&: Field.Type,
569 Items: memberAttributes(Attrs: Field.Attrs));
570 return Error::success();
571}
572
573Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
574 EnumeratorRecord &Enum) {
575 P.format(Fmt: " [{0} = {1}]", Items&: Enum.Name,
576 Items: toString(I: Enum.Value, Radix: 10, Signed: Enum.Value.isSigned()));
577 return Error::success();
578}
579
580Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
581 BaseClassRecord &Base) {
582 AutoIndent Indent(P);
583 P.formatLine(Fmt: "type = {0}, offset = {1}, attrs = {2}", Items&: Base.Type, Items&: Base.Offset,
584 Items: memberAttributes(Attrs: Base.Attrs));
585 return Error::success();
586}
587
588Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
589 VirtualBaseClassRecord &Base) {
590 AutoIndent Indent(P);
591 P.formatLine(
592 Fmt: "base = {0}, vbptr = {1}, vbptr offset = {2}, vtable index = {3}",
593 Items&: Base.BaseType, Items&: Base.VBPtrType, Items&: Base.VBPtrOffset, Items&: Base.VTableIndex);
594 P.formatLine(Fmt: "attrs = {0}", Items: memberAttributes(Attrs: Base.Attrs));
595 return Error::success();
596}
597
598Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
599 ListContinuationRecord &Cont) {
600 P.format(Fmt: " continuation = {0}", Items&: Cont.ContinuationIndex);
601 return Error::success();
602}
603
604Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
605 VFPtrRecord &VFP) {
606 P.format(Fmt: " type = {0}", Items&: VFP.Type);
607 return Error::success();
608}
609