1 //===-- CompactTypeDumpVisitor.cpp - CodeView type info dumper --*- 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 "CompactTypeDumpVisitor.h"
11 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
12 #include "llvm/Support/FormatVariadic.h"
13 #include "llvm/Support/ScopedPrinter.h"
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
19 static const EnumEntry<TypeLeafKind> LeafTypeNames[] = {
20 #define CV_TYPE(enum, val) {#enum, enum},
21 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
24 static StringRef getLeafName(TypeLeafKind K) {
25 for (const auto &E : LeafTypeNames) {
32 CompactTypeDumpVisitor::CompactTypeDumpVisitor(TypeCollection &Types,
34 : CompactTypeDumpVisitor(Types, TypeIndex(TypeIndex::FirstNonSimpleIndex),
37 CompactTypeDumpVisitor::CompactTypeDumpVisitor(TypeCollection &Types,
40 : W(W), TI(FirstTI), Offset(0), Types(Types) {}
42 Error CompactTypeDumpVisitor::visitTypeBegin(CVType &Record) {
43 return Error::success();
46 Error CompactTypeDumpVisitor::visitTypeEnd(CVType &Record) {
47 uint32_t I = TI.getIndex();
48 StringRef Leaf = getLeafName(Record.Type);
49 StringRef Name = Types.getTypeName(TI);
51 llvm::formatv("Index: {0:x} ({1:N} bytes, offset {2:N}) {3} \"{4}\"", I,
52 Record.length(), Offset, Leaf, Name)
55 Offset += Record.length();
56 TI.setIndex(TI.getIndex() + 1);
58 return Error::success();