llvm.org GIT mirror llvm / 0c5ced8
[PDB] Better support for enumerating pointer types. There were several issues with the previous implementation. 1) There were no tests. 2) We didn't support creating PDBSymbolTypePointer records for builtin types since those aren't described by LF_POINTER records. 3) We didn't support a wide enough variety of builtin types even ignoring pointers. This patch fixes all of these issues. In order to add tests, it's helpful to be able to ignore the symbol index id hierarchy because it makes the golden output from the DIA version not match our output, so I've extended the dumper to disable dumping of id fields. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342493 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 11 months ago
25 changed file(s) with 723 addition(s) and 121 deletion(s). Raw diff Collapse all Expand all
133133 return static_cast(Index & SimpleModeMask);
134134 }
135135
136 TypeIndex makeDirect() const { return TypeIndex{getSimpleKind()}; }
137
136138 static TypeIndex None() { return TypeIndex(SimpleTypeKind::None); }
137139 static TypeIndex Void() { return TypeIndex(SimpleTypeKind::Void); }
138140 static TypeIndex VoidPointer32() {
1919 public:
2020 DIARawSymbol(const DIASession &PDBSession, CComPtr DiaSymbol);
2121
22 void dump(raw_ostream &OS, int Indent) const override;
22 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
23 PdbSymbolIdField RecurseIdFields) const override;
2324
2425 CComPtr getDiaSymbol() const { return Symbol; }
2526
1010 #define LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H
1111
1212 #include "PDBTypes.h"
13 #include "llvm/ADT/BitmaskEnum.h"
1314 #include "llvm/ADT/SmallVector.h"
1415 #include "llvm/ADT/StringRef.h"
1516 #include "llvm/DebugInfo/CodeView/CodeView.h"
2021
2122 namespace pdb {
2223
24 class IPDBSession;
2325 class PDBSymbolTypeVTable;
2426 class PDBSymbolTypeVTableShape;
27
28 enum class PdbSymbolIdField : uint32_t {
29 None = 0,
30 SymIndexId = 1 << 0,
31 LexicalParent = 1 << 1,
32 ClassParent = 1 << 2,
33 Type = 1 << 3,
34 UnmodifiedType = 1 << 4,
35 All = 0xFFFFFFFF,
36 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All)
37 };
2538
2639 template
2740 void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent) {
2942 OS.indent(Indent);
3043 OS << Name << ": " << Value;
3144 }
45
46 void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value,
47 int Indent, const IPDBSession &Session,
48 PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags,
49 PdbSymbolIdField RecurseFlags);
3250
3351 /// IPDBRawSymbol defines an interface used to represent an arbitrary symbol.
3452 /// It exposes a monolithic interface consisting of accessors for the union of
3957 public:
4058 virtual ~IPDBRawSymbol();
4159
42 virtual void dump(raw_ostream &OS, int Indent) const = 0;
60 virtual void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
61 PdbSymbolIdField RecurseIdFields) const = 0;
4362
4463 virtual std::unique_ptr
4564 findChildren(PDB_SymType Type) const = 0;
243262 virtual std::string getUnused() const = 0;
244263 };
245264
265 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
266
246267 } // namespace pdb
247268 } // namespace llvm
248269
2020 NativeCompilandSymbol(NativeSession &Session, SymIndexId SymbolId,
2121 DbiModuleDescriptor MI);
2222
23 void dump(raw_ostream &OS, int Indent) const override;
23 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
24 PdbSymbolIdField RecurseIdFields) const override;
2425
2526 PDB_SymType getSymTag() const override;
2627 bool isEditAndContinueEnabled() const override;
2323 NativeRawSymbol(NativeSession &PDBSession, PDB_SymType Tag,
2424 SymIndexId SymbolId);
2525
26 void dump(raw_ostream &OS, int Indent) const override;
26 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
27 PdbSymbolIdField RecurseIdFields) const override;
2728
2829 std::unique_ptr
2930 findChildren(PDB_SymType Type) const override;
2525
2626 ~NativeSymbolEnumerator() override;
2727
28 void dump(raw_ostream &OS, int Indent) const override;
28 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
29 PdbSymbolIdField RecurseIdFields) const override;
2930
3031 SymIndexId getClassParentId() const override;
3132 SymIndexId getLexicalParentId() const override;
2525 uint64_t L);
2626 ~NativeTypeBuiltin() override;
2727
28 void dump(raw_ostream &OS, int Indent) const override;
28 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
29 PdbSymbolIdField RecurseIdFields) const override;
2930
3031 PDB_SymType getSymTag() const override;
3132
3030 codeview::EnumRecord EnumRecord);
3131 ~NativeTypeEnum() override;
3232
33 void dump(raw_ostream &OS, int Indent) const override;
33 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
34 PdbSymbolIdField RecurseIdFields) const override;
3435
3536 std::unique_ptr
3637 findChildren(PDB_SymType Type) const override;
1010 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H
1111 #define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H
1212
13 #include "llvm/ADT/Optional.h"
1314 #include "llvm/DebugInfo/CodeView/CodeView.h"
1415 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
1516 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
2021
2122 class NativeTypePointer : public NativeRawSymbol {
2223 public:
24 // Create a pointer record for a simple type.
25 NativeTypePointer(NativeSession &Session, SymIndexId Id,
26 codeview::TypeIndex TI);
27
28 // Create a pointer record for a non-simple type.
2329 NativeTypePointer(NativeSession &Session, SymIndexId Id,
2430 codeview::TypeIndex TI, codeview::PointerRecord PR);
2531 ~NativeTypePointer() override;
2632
27 void dump(raw_ostream &OS, int Indent) const override;
33 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
34 PdbSymbolIdField RecurseIdFields) const override;
2835
2936 bool isConstType() const override;
3037 uint64_t getLength() const override;
3946
4047 protected:
4148 codeview::TypeIndex TI;
42 codeview::PointerRecord Record;
49 Optional Record;
4350 };
4451
4552 } // namespace pdb
111111 /// normally goes on the right side of the symbol.
112112 virtual void dumpRight(PDBSymDumper &Dumper) const {}
113113
114 void defaultDump(raw_ostream &OS, int Indent) const;
114 void defaultDump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowFlags,
115 PdbSymbolIdField RecurseFlags) const;
115116 void dumpProperties() const;
116117 void dumpChildStats() const;
117118
149149 dumpSymbolField(OS, Name, static_cast(Value), Indent);
150150 }
151151
152 void DumpDIAIdValue(llvm::raw_ostream &OS, int Indent, StringRef Name,
153 IDiaSymbol *Symbol,
154 HRESULT (__stdcall IDiaSymbol::*Method)(DWORD *),
155 const IPDBSession &Session, PdbSymbolIdField FieldId,
156 PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags) {
157 DWORD Value;
158 if (S_OK == (Symbol->*Method)(&Value))
159 dumpSymbolIdField(OS, Name, Value, Indent, Session, FieldId, ShowFlags,
160 RecurseFlags);
161 }
162
152163 template
153164 void DumpDIAValue(llvm::raw_ostream &OS, int Indent, StringRef Name,
154165 IDiaSymbol *Symbol,
198209 CComPtr DiaSymbol)
199210 : Session(PDBSession), Symbol(DiaSymbol) {}
200211
212 #define RAW_ID_METHOD_DUMP(Stream, Method, Session, FieldId, ShowFlags, \
213 RecurseFlags) \
214 DumpDIAIdValue(Stream, Indent, StringRef{#Method}, Symbol, \
215 &IDiaSymbol::get_##Method, Session, FieldId, ShowFlags, \
216 RecurseFlags);
217
201218 #define RAW_METHOD_DUMP(Stream, Method) \
202219 DumpDIAValue(Stream, Indent, StringRef{#Method}, Symbol, \
203220 &IDiaSymbol::get_##Method);
206223 DumpDIAValueAs(Stream, Indent, StringRef{#Method}, Symbol, \
207224 &IDiaSymbol::get_##Method);
208225
209 void DIARawSymbol::dump(raw_ostream &OS, int Indent) const {
210 RAW_METHOD_DUMP(OS, symIndexId);
211 RAW_METHOD_DUMP(OS, symTag);
226 void DIARawSymbol::dump(raw_ostream &OS, int Indent,
227 PdbSymbolIdField ShowIdFields,
228 PdbSymbolIdField RecurseIdFields) const {
229 RAW_ID_METHOD_DUMP(OS, symIndexId, Session, PdbSymbolIdField::SymIndexId,
230 ShowIdFields, RecurseIdFields);
231 RAW_METHOD_DUMP_AS(OS, symTag, PDB_SymType);
212232
213233 RAW_METHOD_DUMP(OS, access);
214234 RAW_METHOD_DUMP(OS, addressOffset);
225245 RAW_METHOD_DUMP(OS, baseType);
226246 RAW_METHOD_DUMP(OS, bitPosition);
227247 RAW_METHOD_DUMP(OS, callingConvention);
228 RAW_METHOD_DUMP(OS, classParentId);
248 RAW_ID_METHOD_DUMP(OS, classParentId, Session, PdbSymbolIdField::ClassParent,
249 ShowIdFields, RecurseIdFields);
229250 RAW_METHOD_DUMP(OS, compilerName);
230251 RAW_METHOD_DUMP(OS, count);
231252 RAW_METHOD_DUMP(OS, countLiveRanges);
233254 RAW_METHOD_DUMP(OS, frontEndMinor);
234255 RAW_METHOD_DUMP(OS, frontEndBuild);
235256 RAW_METHOD_DUMP(OS, frontEndQFE);
236 RAW_METHOD_DUMP(OS, lexicalParentId);
257 RAW_ID_METHOD_DUMP(OS, lexicalParentId, Session,
258 PdbSymbolIdField::LexicalParent, ShowIdFields,
259 RecurseIdFields);
237260 RAW_METHOD_DUMP(OS, libraryName);
238261 RAW_METHOD_DUMP(OS, liveRangeStartAddressOffset);
239262 RAW_METHOD_DUMP(OS, liveRangeStartAddressSection);
271294 RAW_METHOD_DUMP(OS, textureSlot);
272295 RAW_METHOD_DUMP(OS, timeStamp);
273296 RAW_METHOD_DUMP(OS, token);
274 RAW_METHOD_DUMP(OS, typeId);
297 RAW_ID_METHOD_DUMP(OS, typeId, Session, PdbSymbolIdField::Type, ShowIdFields,
298 RecurseIdFields);
275299 RAW_METHOD_DUMP(OS, uavSlot);
276300 RAW_METHOD_DUMP(OS, undecoratedName);
277 RAW_METHOD_DUMP(OS, unmodifiedTypeId);
301 RAW_ID_METHOD_DUMP(OS, unmodifiedTypeId, Session,
302 PdbSymbolIdField::UnmodifiedType, ShowIdFields,
303 RecurseIdFields);
278304 RAW_METHOD_DUMP(OS, upperBoundId);
279305 RAW_METHOD_DUMP(OS, virtualBaseDispIndex);
280306 RAW_METHOD_DUMP(OS, virtualBaseOffset);
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
10 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
1011
1112 #include "llvm/ADT/STLExtras.h"
1213
2223 return PDB_SymType::Compiland;
2324 }
2425
25 void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent) const {
26 NativeRawSymbol::dump(OS, Indent);
26 void NativeCompilandSymbol::dump(raw_ostream &OS, int Indent,
27 PdbSymbolIdField ShowIdFields,
28 PdbSymbolIdField RecurseIdFields) const {
29 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
2730
28 dumpSymbolField(OS, "lexicalParentId", 0, Indent);
31 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
32 PdbSymbolIdField::LexicalParent, ShowIdFields,
33 RecurseIdFields);
2934 dumpSymbolField(OS, "libraryName", getLibraryName(), Indent);
3035 dumpSymbolField(OS, "name", getName(), Indent);
3136 dumpSymbolField(OS, "editAndContinueEnabled", isEditAndContinueEnabled(),
88
99 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
1010 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
11 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
1112 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
1213 #include "llvm/Support/FormatVariadic.h"
1314
1819 SymIndexId SymbolId)
1920 : Session(PDBSession), Tag(Tag), SymbolId(SymbolId) {}
2021
21 void NativeRawSymbol::dump(raw_ostream &OS, int Indent) const {
22 dumpSymbolField(OS, "symIndexId", SymbolId, Indent);
23 dumpSymbolField(OS, "symTag", static_cast(Tag), Indent);
22 void NativeRawSymbol::dump(raw_ostream &OS, int Indent,
23 PdbSymbolIdField ShowIdFields,
24 PdbSymbolIdField RecurseIdFields) const {
25 dumpSymbolIdField(OS, "symIndexId", SymbolId, Indent, Session,
26 PdbSymbolIdField::SymIndexId, ShowIdFields,
27 RecurseIdFields);
28 dumpSymbolField(OS, "symTag", Tag, Indent);
2429 }
2530
2631 std::unique_ptr
2424
2525 NativeSymbolEnumerator::~NativeSymbolEnumerator() {}
2626
27 void NativeSymbolEnumerator::dump(raw_ostream &OS, int Indent) const {
28 NativeRawSymbol::dump(OS, Indent);
29 dumpSymbolField(OS, "classParentId", getClassParentId(), Indent);
30 dumpSymbolField(OS, "lexicalParentId", getLexicalParentId(), Indent);
27 void NativeSymbolEnumerator::dump(raw_ostream &OS, int Indent,
28 PdbSymbolIdField ShowIdFields,
29 PdbSymbolIdField RecurseIdFields) const {
30 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
31 dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
32 PdbSymbolIdField::ClassParent, ShowIdFields,
33 RecurseIdFields);
34 dumpSymbolIdField(OS, "lexicalParentId", getLexicalParentId(), Indent,
35 Session, PdbSymbolIdField::LexicalParent, ShowIdFields,
36 RecurseIdFields);
3137 dumpSymbolField(OS, "name", getName(), Indent);
32 dumpSymbolField(OS, "typeId", getTypeId(), Indent);
38 dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
39 PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
3340 dumpSymbolField(OS, "dataKind", getDataKind(), Indent);
3441 dumpSymbolField(OS, "locationType", getLocationType(), Indent);
3542 dumpSymbolField(OS, "constType", isConstType(), Indent);
2020
2121 NativeTypeBuiltin::~NativeTypeBuiltin() {}
2222
23 void NativeTypeBuiltin::dump(raw_ostream &OS, int Indent) const {
24 }
23 void NativeTypeBuiltin::dump(raw_ostream &OS, int Indent,
24 PdbSymbolIdField ShowIdFields,
25 PdbSymbolIdField RecurseIdFields) const {}
2526
2627 PDB_SymType NativeTypeBuiltin::getSymTag() const {
2728 return PDB_SymType::BuiltinType;
129129
130130 NativeTypeEnum::~NativeTypeEnum() {}
131131
132 void NativeTypeEnum::dump(raw_ostream &OS, int Indent) const {
133 NativeRawSymbol::dump(OS, Indent);
132 void NativeTypeEnum::dump(raw_ostream &OS, int Indent,
133 PdbSymbolIdField ShowIdFields,
134 PdbSymbolIdField RecurseIdFields) const {
135 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
134136
135137 dumpSymbolField(OS, "baseType", static_cast(getBuiltinType()),
136138 Indent);
137 dumpSymbolField(OS, "lexicalParentId", 0, Indent);
139 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
140 PdbSymbolIdField::LexicalParent, ShowIdFields,
141 RecurseIdFields);
138142 dumpSymbolField(OS, "name", getName(), Indent);
139 dumpSymbolField(OS, "typeId", getTypeId(), Indent);
143 dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
144 PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
140145 if (Modifiers.hasValue())
141 dumpSymbolField(OS, "unmodifiedTypeId", getUnmodifiedTypeId(), Indent);
146 dumpSymbolIdField(OS, "unmodifiedTypeId", getUnmodifiedTypeId(), Indent,
147 Session, PdbSymbolIdField::UnmodifiedType, ShowIdFields,
148 RecurseIdFields);
142149 dumpSymbolField(OS, "length", getLength(), Indent);
143150 dumpSymbolField(OS, "constructor", hasConstructor(), Indent);
144151 dumpSymbolField(OS, "constType", isConstType(), Indent);
1717 using namespace llvm::pdb;
1818
1919 NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
20 codeview::TypeIndex TI)
21 : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI) {
22 assert(TI.isSimple());
23 assert(TI.getSimpleMode() != SimpleTypeMode::Direct);
24 }
25
26 NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
2027 codeview::TypeIndex TI,
2128 codeview::PointerRecord Record)
2229 : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI),
2431
2532 NativeTypePointer::~NativeTypePointer() {}
2633
27 void NativeTypePointer::dump(raw_ostream &OS, int Indent) const {
28 NativeRawSymbol::dump(OS, Indent);
34 void NativeTypePointer::dump(raw_ostream &OS, int Indent,
35 PdbSymbolIdField ShowIdFields,
36 PdbSymbolIdField RecurseIdFields) const {
37 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
2938
30 dumpSymbolField(OS, "lexicalParentId", 0, Indent);
31 dumpSymbolField(OS, "typeId", getTypeId(), Indent);
39 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
40 PdbSymbolIdField::LexicalParent, ShowIdFields,
41 RecurseIdFields);
42 dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
43 PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
3244 dumpSymbolField(OS, "length", getLength(), Indent);
3345 dumpSymbolField(OS, "constType", isConstType(), Indent);
3446 dumpSymbolField(OS, "isPointerToDataMember", isPointerToDataMember(), Indent);
4153 dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
4254 }
4355
44 uint64_t NativeTypePointer::getLength() const { return Record.getSize(); }
56 uint64_t NativeTypePointer::getLength() const {
57 if (Record)
58 return Record->getSize();
59
60 switch (TI.getSimpleMode()) {
61 case SimpleTypeMode::NearPointer:
62 case SimpleTypeMode::FarPointer:
63 case SimpleTypeMode::HugePointer:
64 return 2;
65 case SimpleTypeMode::NearPointer32:
66 case SimpleTypeMode::FarPointer32:
67 return 4;
68 case SimpleTypeMode::NearPointer64:
69 return 8;
70 case SimpleTypeMode::NearPointer128:
71 return 16;
72 default:
73 assert(false && "invalid simple type mode!");
74 }
75 return 0;
76 }
4577
4678 SymIndexId NativeTypePointer::getTypeId() const {
4779 // This is the pointee SymIndexId.
48 return Session.getSymbolCache().findSymbolByTypeIndex(Record.ReferentType);
80 TypeIndex Referent = Record ? Record->ReferentType : TI.makeDirect();
81
82 return Session.getSymbolCache().findSymbolByTypeIndex(Referent);
4983 }
5084
5185 bool NativeTypePointer::isReference() const {
52 return Record.getMode() == PointerMode::LValueReference ||
53 isRValueReference();
86 if (!Record)
87 return false;
88 return Record->getMode() == PointerMode::LValueReference;
5489 }
5590
5691 bool NativeTypePointer::isRValueReference() const {
57 return Record.getMode() == PointerMode::RValueReference;
92 if (!Record)
93 return false;
94 return Record->getMode() == PointerMode::RValueReference;
5895 }
5996
6097 bool NativeTypePointer::isPointerToDataMember() const {
61 return Record.getMode() == PointerMode::PointerToDataMember;
98 if (!Record)
99 return false;
100 return Record->getMode() == PointerMode::PointerToDataMember;
62101 }
63102
64103 bool NativeTypePointer::isPointerToMemberFunction() const {
65 return Record.getMode() == PointerMode::PointerToMemberFunction;
104 if (!Record)
105 return false;
106 return Record->getMode() == PointerMode::PointerToMemberFunction;
66107 }
67108
68109 bool NativeTypePointer::isConstType() const {
69 return (Record.getOptions() & PointerOptions::Const) != PointerOptions::None;
110 if (!Record)
111 return false;
112 return (Record->getOptions() & PointerOptions::Const) != PointerOptions::None;
70113 }
71114
72115 bool NativeTypePointer::isRestrictedType() const {
73 return (Record.getOptions() & PointerOptions::Restrict) !=
116 if (!Record)
117 return false;
118 return (Record->getOptions() & PointerOptions::Restrict) !=
74119 PointerOptions::None;
75120 }
76121
77122 bool NativeTypePointer::isVolatileType() const {
78 return (Record.getOptions() & PointerOptions::Volatile) !=
123 if (!Record)
124 return false;
125 return (Record->getOptions() & PointerOptions::Volatile) !=
79126 PointerOptions::None;
80127 }
81128
82129 bool NativeTypePointer::isUnalignedType() const {
83 return (Record.getOptions() & PointerOptions::Unaligned) !=
130 if (!Record)
131 return false;
132 return (Record->getOptions() & PointerOptions::Unaligned) !=
84133 PointerOptions::None;
85134 }
6464
6565 SymIndexId SymbolCache::createSimpleType(TypeIndex Index,
6666 ModifierOptions Mods) {
67 // FIXME: We will eventually need to handle pointers to other simple types,
68 // which are still simple types in the world of CodeView TypeIndexes.
69 if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct)
70 return 0;
71
67 if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct) {
68 SymIndexId Id = Cache.size();
69 Cache.emplace_back(
70 llvm::make_unique(Session, Id, Index));
71 return Id;
72 }
73
74 SymIndexId Id = Cache.size();
7275 const auto Kind = Index.getSimpleKind();
7376 const auto It = std::find_if(
7477 std::begin(BuiltinTypes), std::end(BuiltinTypes),
7578 [Kind](const BuiltinTypeEntry &Builtin) { return Builtin.Kind == Kind; });
7679 if (It == std::end(BuiltinTypes))
7780 return 0;
78 SymIndexId Id = Cache.size();
7981 Cache.emplace_back(llvm::make_unique(Session, Id, Mods,
8082 It->Type, It->Size));
8183 TypeIndexToSymbolId[Index] = Id;
174176 assert(SymbolId < Cache.size());
175177
176178 // Id 0 is reserved.
177 if (SymbolId == 0)
178 return nullptr;
179
180 // If the caller has a SymbolId, it'd better be in our SymbolCache.
181 return SymbolId < Cache.size() ? PDBSymbol::create(Session, *Cache[SymbolId])
182 : nullptr;
179 if (SymbolId == 0 || SymbolId >= Cache.size())
180 return nullptr;
181
182 // Make sure to handle the case where we've inserted a placeholder symbol
183 // for types we don't yet suppport.
184 NativeRawSymbol *NRS = Cache[SymbolId].get();
185 if (!NRS)
186 return nullptr;
187
188 return PDBSymbol::create(Session, *NRS);
183189 }
184190
185191 NativeRawSymbol &SymbolCache::getNativeSymbolById(SymIndexId SymbolId) const {
114114 return SymbolPtr;
115115 }
116116
117 void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const {
118 RawSymbol->dump(OS, Indent);
117 void PDBSymbol::defaultDump(raw_ostream &OS, int Indent,
118 PdbSymbolIdField ShowFlags,
119 PdbSymbolIdField RecurseFlags) const {
120 RawSymbol->dump(OS, Indent, ShowFlags, RecurseFlags);
119121 }
120122
121123 void PDBSymbol::dumpProperties() const {
122124 outs() << "\n";
123 defaultDump(outs(), 0);
125 defaultDump(outs(), 0, PdbSymbolIdField::All, PdbSymbolIdField::None);
124126 outs().flush();
125127 }
126128
179181 std::unique_ptr PDBSymbol::getSymbolByIdHelper(uint32_t Id) const {
180182 return Session.getSymbolById(Id);
181183 }
184
185 void llvm::pdb::dumpSymbolIdField(raw_ostream &OS, StringRef Name,
186 SymIndexId Value, int Indent,
187 const IPDBSession &Session,
188 PdbSymbolIdField FieldId,
189 PdbSymbolIdField ShowFlags,
190 PdbSymbolIdField RecurseFlags) {
191 if ((FieldId & ShowFlags) == PdbSymbolIdField::None)
192 return;
193
194 OS << "\n";
195 OS.indent(Indent);
196 OS << Name << ": " << Value;
197 // Don't recurse unless the user requested it.
198 if ((FieldId & RecurseFlags) == PdbSymbolIdField::None)
199 return;
200 // And obviously don't recurse on the symbol itself.
201 if (FieldId == PdbSymbolIdField::SymIndexId)
202 return;
203
204 auto Child = Session.getSymbolById(Value);
205
206 // It could have been a placeholder symbol for a type we don't yet support,
207 // so just exit in that case.
208 if (!Child)
209 return;
210
211 // Don't recurse more than once, so pass PdbSymbolIdField::None) for the
212 // recurse flags.
213 Child->defaultDump(OS, Indent + 2, ShowFlags, PdbSymbolIdField::None);
214 }
0 // Build with "cl.exe /Zi /GR- /GX- every-pointer.cpp /link /debug /nodefaultlib /incremental:no /entry:main"
1
2 #include
3
4 // clang-format off
5 void *__purecall = 0;
6
7 void __cdecl operator delete(void *,unsigned int) {}
8 void __cdecl operator delete(void *,unsigned __int64) {}
9
10
11 struct Foo {
12 int X = 0;
13 int func() { return 42; }
14 };
15
16 int *IntP = nullptr;
17 Foo *FooP = nullptr;
18
19 Foo F;
20
21 Foo __unaligned *UFooP = &F;
22 Foo * __restrict RFooP = &F;
23
24 const Foo * CFooP = &F;
25 volatile Foo * VFooP = &F;
26 const volatile Foo * CVFooP = &F;
27
28 template void f(T t) {}
29
30 int main(int argc, char **argv) {
31 f(IntP);
32 f(FooP);
33
34 f(UFooP);
35 f(RFooP);
36
37 f(CFooP);
38 f(VFooP);
39 f(CVFooP);
40
41 f(F);
42 f(static_cast(F));
43
44 f(&Foo::X);
45 f(&Foo::func);
46 return 0;
47 }
6767
6868 DUMP: {
6969 DUMP-NEXT: symIndexId: 2
70 DUMP-NEXT: symTag: 2
71 DUMP-NEXT: lexicalParentId: 0
70 DUMP-NEXT: symTag: Compiland
7271 DUMP-NEXT: libraryName: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
7372 DUMP-NEXT: name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
7473 DUMP-NEXT: editAndContinueEnabled: 0
7574 DUMP-NEXT: }
7675 DUMP-NEXT: {
7776 DUMP-NEXT: symIndexId: 3
78 DUMP-NEXT: symTag: 2
79 DUMP-NEXT: lexicalParentId: 0
77 DUMP-NEXT: symTag: Compiland
8078 DUMP-NEXT: libraryName:
8179 DUMP-NEXT: name: * Linker *
8280 DUMP-NEXT: editAndContinueEnabled: 0
99
1010 ; RUN: llvm-pdbutil pretty -native -enums %p/../Inputs/every-enum.pdb \
1111 ; RUN: | FileCheck -check-prefix=ENUMS %s
12 ; RUN: llvm-pdbutil diadump -native -enums %p/../Inputs/every-enum.pdb \
12 ; RUN: llvm-pdbutil diadump -hierarchy -native -enums %p/../Inputs/every-enum.pdb \
1313 ; RUN: | FileCheck -check-prefix=DUMP %s
1414
1515
8080
8181 DUMP: {
8282 DUMP: symIndexId: 2
83 DUMP: symTag: 12
83 DUMP: symTag: Enum
8484 DUMP: baseType: 2
8585 DUMP: lexicalParentId: 0
8686 DUMP: name: I8
103103 DUMP: volatileType: 0
104104 DUMP: {
105105 DUMP: symIndexId: 4
106 DUMP: symTag: 7
106 DUMP: symTag: Data
107107 DUMP: classParentId: 2
108108 DUMP: lexicalParentId: 0
109109 DUMP: name: I8A
117117 DUMP: }
118118 DUMP: {
119119 DUMP: symIndexId: 5
120 DUMP: symTag: 7
120 DUMP: symTag: Data
121121 DUMP: classParentId: 2
122122 DUMP: lexicalParentId: 0
123123 DUMP: name: I8B
131131 DUMP: }
132132 DUMP: {
133133 DUMP: symIndexId: 6
134 DUMP: symTag: 7
134 DUMP: symTag: Data
135135 DUMP: classParentId: 2
136136 DUMP: lexicalParentId: 0
137137 DUMP: name: I8C
146146 DUMP: }
147147 DUMP: {
148148 DUMP: symIndexId: 7
149 DUMP: symTag: 12
149 DUMP: symTag: Enum
150150 DUMP: baseType: 6
151151 DUMP: lexicalParentId: 0
152152 DUMP: name: I16
169169 DUMP: volatileType: 0
170170 DUMP: {
171171 DUMP: symIndexId: 9
172 DUMP: symTag: 7
172 DUMP: symTag: Data
173173 DUMP: classParentId: 7
174174 DUMP: lexicalParentId: 0
175175 DUMP: name: I16A
183183 DUMP: }
184184 DUMP: {
185185 DUMP: symIndexId: 10
186 DUMP: symTag: 7
186 DUMP: symTag: Data
187187 DUMP: classParentId: 7
188188 DUMP: lexicalParentId: 0
189189 DUMP: name: I16B
197197 DUMP: }
198198 DUMP: {
199199 DUMP: symIndexId: 11
200 DUMP: symTag: 7
200 DUMP: symTag: Data
201201 DUMP: classParentId: 7
202202 DUMP: lexicalParentId: 0
203203 DUMP: name: I16C
212212 DUMP: }
213213 DUMP: {
214214 DUMP: symIndexId: 12
215 DUMP: symTag: 12
215 DUMP: symTag: Enum
216216 DUMP: baseType: 6
217217 DUMP: lexicalParentId: 0
218218 DUMP: name: I32
235235 DUMP: volatileType: 0
236236 DUMP: {
237237 DUMP: symIndexId: 14
238 DUMP: symTag: 7
238 DUMP: symTag: Data
239239 DUMP: classParentId: 12
240240 DUMP: lexicalParentId: 0
241241 DUMP: name: I32A
249249 DUMP: }
250250 DUMP: {
251251 DUMP: symIndexId: 15
252 DUMP: symTag: 7
252 DUMP: symTag: Data
253253 DUMP: classParentId: 12
254254 DUMP: lexicalParentId: 0
255255 DUMP: name: I32B
263263 DUMP: }
264264 DUMP: {
265265 DUMP: symIndexId: 16
266 DUMP: symTag: 7
266 DUMP: symTag: Data
267267 DUMP: classParentId: 12
268268 DUMP: lexicalParentId: 0
269269 DUMP: name: I32C
278278 DUMP: }
279279 DUMP: {
280280 DUMP: symIndexId: 17
281 DUMP: symTag: 12
281 DUMP: symTag: Enum
282282 DUMP: baseType: 6
283283 DUMP: lexicalParentId: 0
284284 DUMP: name: I64
301301 DUMP: volatileType: 0
302302 DUMP: {
303303 DUMP: symIndexId: 19
304 DUMP: symTag: 7
304 DUMP: symTag: Data
305305 DUMP: classParentId: 17
306306 DUMP: lexicalParentId: 0
307307 DUMP: name: I64A
315315 DUMP: }
316316 DUMP: {
317317 DUMP: symIndexId: 20
318 DUMP: symTag: 7
318 DUMP: symTag: Data
319319 DUMP: classParentId: 17
320320 DUMP: lexicalParentId: 0
321321 DUMP: name: I64B
329329 DUMP: }
330330 DUMP: {
331331 DUMP: symIndexId: 21
332 DUMP: symTag: 7
332 DUMP: symTag: Data
333333 DUMP: classParentId: 17
334334 DUMP: lexicalParentId: 0
335335 DUMP: name: I64C
344344 DUMP: }
345345 DUMP: {
346346 DUMP: symIndexId: 22
347 DUMP: symTag: 12
347 DUMP: symTag: Enum
348348 DUMP: baseType: 2
349349 DUMP: lexicalParentId: 0
350350 DUMP: name: U8
367367 DUMP: volatileType: 0
368368 DUMP: {
369369 DUMP: symIndexId: 24
370 DUMP: symTag: 7
370 DUMP: symTag: Data
371371 DUMP: classParentId: 22
372372 DUMP: lexicalParentId: 0
373373 DUMP: name: U8A
381381 DUMP: }
382382 DUMP: {
383383 DUMP: symIndexId: 25
384 DUMP: symTag: 7
384 DUMP: symTag: Data
385385 DUMP: classParentId: 22
386386 DUMP: lexicalParentId: 0
387387 DUMP: name: U8B
396396 DUMP: }
397397 DUMP: {
398398 DUMP: symIndexId: 26
399 DUMP: symTag: 12
399 DUMP: symTag: Enum
400400 DUMP: baseType: 7
401401 DUMP: lexicalParentId: 0
402402 DUMP: name: U16
419419 DUMP: volatileType: 0
420420 DUMP: {
421421 DUMP: symIndexId: 28
422 DUMP: symTag: 7
422 DUMP: symTag: Data
423423 DUMP: classParentId: 26
424424 DUMP: lexicalParentId: 0
425425 DUMP: name: U16A
433433 DUMP: }
434434 DUMP: {
435435 DUMP: symIndexId: 29
436 DUMP: symTag: 7
436 DUMP: symTag: Data
437437 DUMP: classParentId: 26
438438 DUMP: lexicalParentId: 0
439439 DUMP: name: U16B
448448 DUMP: }
449449 DUMP: {
450450 DUMP: symIndexId: 30
451 DUMP: symTag: 12
451 DUMP: symTag: Enum
452452 DUMP: baseType: 7
453453 DUMP: lexicalParentId: 0
454454 DUMP: name: U32
471471 DUMP: volatileType: 0
472472 DUMP: {
473473 DUMP: symIndexId: 32
474 DUMP: symTag: 7
474 DUMP: symTag: Data
475475 DUMP: classParentId: 30
476476 DUMP: lexicalParentId: 0
477477 DUMP: name: U32A
485485 DUMP: }
486486 DUMP: {
487487 DUMP: symIndexId: 33
488 DUMP: symTag: 7
488 DUMP: symTag: Data
489489 DUMP: classParentId: 30
490490 DUMP: lexicalParentId: 0
491491 DUMP: name: U32B
500500 DUMP: }
501501 DUMP: {
502502 DUMP: symIndexId: 34
503 DUMP: symTag: 12
503 DUMP: symTag: Enum
504504 DUMP: baseType: 7
505505 DUMP: lexicalParentId: 0
506506 DUMP: name: U64
523523 DUMP: volatileType: 0
524524 DUMP: {
525525 DUMP: symIndexId: 36
526 DUMP: symTag: 7
526 DUMP: symTag: Data
527527 DUMP: classParentId: 34
528528 DUMP: lexicalParentId: 0
529529 DUMP: name: U64A
537537 DUMP: }
538538 DUMP: {
539539 DUMP: symIndexId: 37
540 DUMP: symTag: 7
540 DUMP: symTag: Data
541541 DUMP: classParentId: 34
542542 DUMP: lexicalParentId: 0
543543 DUMP: name: U64B
552552 DUMP: }
553553 DUMP: {
554554 DUMP: symIndexId: 38
555 DUMP: symTag: 12
555 DUMP: symTag: Enum
556556 DUMP: baseType: 7
557557 DUMP: lexicalParentId: 0
558558 DUMP: name: Char16
575575 DUMP: volatileType: 0
576576 DUMP: {
577577 DUMP: symIndexId: 39
578 DUMP: symTag: 7
578 DUMP: symTag: Data
579579 DUMP: classParentId: 38
580580 DUMP: lexicalParentId: 0
581581 DUMP: name: C16A
589589 DUMP: }
590590 DUMP: {
591591 DUMP: symIndexId: 40
592 DUMP: symTag: 7
592 DUMP: symTag: Data
593593 DUMP: classParentId: 38
594594 DUMP: lexicalParentId: 0
595595 DUMP: name: C16B
604604 DUMP: }
605605 DUMP: {
606606 DUMP: symIndexId: 41
607 DUMP: symTag: 12
607 DUMP: symTag: Enum
608608 DUMP: baseType: 7
609609 DUMP: lexicalParentId: 0
610610 DUMP: name: Char32
627627 DUMP: volatileType: 0
628628 DUMP: {
629629 DUMP: symIndexId: 43
630 DUMP: symTag: 7
630 DUMP: symTag: Data
631631 DUMP: classParentId: 41
632632 DUMP: lexicalParentId: 0
633633 DUMP: name: C32A
641641 DUMP: }
642642 DUMP: {
643643 DUMP: symIndexId: 44
644 DUMP: symTag: 7
644 DUMP: symTag: Data
645645 DUMP: classParentId: 41
646646 DUMP: lexicalParentId: 0
647647 DUMP: name: C32B
656656 DUMP: }
657657 DUMP: {
658658 DUMP: symIndexId: 45
659 DUMP: symTag: 12
659 DUMP: symTag: Enum
660660 DUMP: baseType: 7
661661 DUMP: lexicalParentId: 0
662662 DUMP: name: WChar
679679 DUMP: volatileType: 0
680680 DUMP: {
681681 DUMP: symIndexId: 46
682 DUMP: symTag: 7
682 DUMP: symTag: Data
683683 DUMP: classParentId: 45
684684 DUMP: lexicalParentId: 0
685685 DUMP: name: WCA
693693 DUMP: }
694694 DUMP: {
695695 DUMP: symIndexId: 47
696 DUMP: symTag: 7
696 DUMP: symTag: Data
697697 DUMP: classParentId: 45
698698 DUMP: lexicalParentId: 0
699699 DUMP: name: WCB
708708 DUMP: }
709709 DUMP: {
710710 DUMP: symIndexId: 48
711 DUMP: symTag: 12
711 DUMP: symTag: Enum
712712 DUMP: baseType: 10
713713 DUMP: lexicalParentId: 0
714714 DUMP: name: Bool
731731 DUMP: volatileType: 0
732732 DUMP: {
733733 DUMP: symIndexId: 50
734 DUMP: symTag: 7
734 DUMP: symTag: Data
735735 DUMP: classParentId: 48
736736 DUMP: lexicalParentId: 0
737737 DUMP: name: BA
745745 DUMP: }
746746 DUMP: {
747747 DUMP: symIndexId: 51
748 DUMP: symTag: 7
748 DUMP: symTag: Data
749749 DUMP: classParentId: 48
750750 DUMP: lexicalParentId: 0
751751 DUMP: name: BB
759759 DUMP: }
760760 DUMP: {
761761 DUMP: symIndexId: 113
762 DUMP: symTag: 12
762 DUMP: symTag: Enum
763763 DUMP: baseType: 6
764764 DUMP: lexicalParentId: 0
765765 DUMP: name: EC
782782 DUMP: volatileType: 0
783783 DUMP: {
784784 DUMP: symIndexId: 114
785 DUMP: symTag: 7
785 DUMP: symTag: Data
786786 DUMP: classParentId: 113
787787 DUMP: lexicalParentId: 0
788788 DUMP: name: A
796796 DUMP: }
797797 DUMP: {
798798 DUMP: symIndexId: 115
799 DUMP: symTag: 7
799 DUMP: symTag: Data
800800 DUMP: classParentId: 113
801801 DUMP: lexicalParentId: 0
802802 DUMP: name: B
811811 DUMP: }
812812 DUMP: {
813813 DUMP: symIndexId: 116
814 DUMP: symTag: 12
814 DUMP: symTag: Enum
815815 DUMP: baseType: 6
816816 DUMP: lexicalParentId: 0
817817 DUMP: name: Struct::Nested
834834 DUMP: volatileType: 0
835835 DUMP: {
836836 DUMP: symIndexId: 114
837 DUMP: symTag: 7
837 DUMP: symTag: Data
838838 DUMP: classParentId: 113
839839 DUMP: lexicalParentId: 0
840840 DUMP: name: A
848848 DUMP: }
849849 DUMP: {
850850 DUMP: symIndexId: 115
851 DUMP: symTag: 7
851 DUMP: symTag: Data
852852 DUMP: classParentId: 113
853853 DUMP: lexicalParentId: 0
854854 DUMP: name: B
863863 DUMP: }
864864 DUMP: {
865865 DUMP: symIndexId: 117
866 DUMP: symTag: 12
866 DUMP: symTag: Enum
867867 DUMP: baseType: 6
868868 DUMP: lexicalParentId: 0
869869 DUMP: name: EC
886886 DUMP: isValueUdt: 0
887887 DUMP: volatileType: 1 {
888888 DUMP: symIndexId: 114
889 DUMP: symTag: 7
889 DUMP: symTag: Data
890890 DUMP: classParentId: 113
891891 DUMP: lexicalParentId: 0
892892 DUMP: name: A
900900 DUMP: }
901901 DUMP: {
902902 DUMP: symIndexId: 115
903 DUMP: symTag: 7
903 DUMP: symTag: Data
904904 DUMP: classParentId: 113
905905 DUMP: lexicalParentId: 0
906906 DUMP: name: B
0 ; Test that the native PDB reader can enumerate pointer types. The output
1 ; being checked against is golden output generated by llvm-pdbutil without
2 ; the -native flag. Then we check that we generate the same output.
3
4 ; RUN: llvm-pdbutil diadump -no-ids -native -pointers \
5 ; RUN: %p/../Inputs/every-pointer.pdb | FileCheck %s
6
7 ; CHECK: {
8 ; CHECK-NEXT: symTag: PointerType
9 ; CHECK-NEXT: length: 8
10 ; CHECK-NEXT: constType: 0
11 ; CHECK-NEXT: isPointerToDataMember: 0
12 ; CHECK-NEXT: isPointerToMemberFunction: 0
13 ; CHECK-NEXT: RValueReference: 0
14 ; CHECK-NEXT: reference: 0
15 ; CHECK-NEXT: restrictedType: 0
16 ; CHECK-NEXT: unalignedType: 0
17 ; CHECK-NEXT: volatileType: 0
18 ; CHECK-NEXT: }
19 ; CHECK-NEXT: {
20 ; CHECK-NEXT: symTag: PointerType
21 ; CHECK-NEXT: length: 8
22 ; CHECK-NEXT: constType: 0
23 ; CHECK-NEXT: isPointerToDataMember: 0
24 ; CHECK-NEXT: isPointerToMemberFunction: 0
25 ; CHECK-NEXT: RValueReference: 0
26 ; CHECK-NEXT: reference: 0
27 ; CHECK-NEXT: restrictedType: 0
28 ; CHECK-NEXT: unalignedType: 0
29 ; CHECK-NEXT: volatileType: 0
30 ; CHECK-NEXT: }
31 ; CHECK-NEXT: {
32 ; CHECK-NEXT: symTag: PointerType
33 ; CHECK-NEXT: length: 8
34 ; CHECK-NEXT: constType: 0
35 ; CHECK-NEXT: isPointerToDataMember: 0
36 ; CHECK-NEXT: isPointerToMemberFunction: 0
37 ; CHECK-NEXT: RValueReference: 0
38 ; CHECK-NEXT: reference: 1
39 ; CHECK-NEXT: restrictedType: 0
40 ; CHECK-NEXT: unalignedType: 0
41 ; CHECK-NEXT: volatileType: 0
42 ; CHECK-NEXT: }
43 ; CHECK-NEXT: {
44 ; CHECK-NEXT: symTag: PointerType
45 ; CHECK-NEXT: length: 8
46 ; CHECK-NEXT: constType: 0
47 ; CHECK-NEXT: isPointerToDataMember: 0
48 ; CHECK-NEXT: isPointerToMemberFunction: 0
49 ; CHECK-NEXT: RValueReference: 0
50 ; CHECK-NEXT: reference: 0
51 ; CHECK-NEXT: restrictedType: 0
52 ; CHECK-NEXT: unalignedType: 0
53 ; CHECK-NEXT: volatileType: 0
54 ; CHECK-NEXT: }
55 ; CHECK-NEXT: {
56 ; CHECK-NEXT: symTag: PointerType
57 ; CHECK-NEXT: length: 8
58 ; CHECK-NEXT: constType: 0
59 ; CHECK-NEXT: isPointerToDataMember: 0
60 ; CHECK-NEXT: isPointerToMemberFunction: 0
61 ; CHECK-NEXT: RValueReference: 0
62 ; CHECK-NEXT: reference: 0
63 ; CHECK-NEXT: restrictedType: 0
64 ; CHECK-NEXT: unalignedType: 0
65 ; CHECK-NEXT: volatileType: 0
66 ; CHECK-NEXT: }
67 ; CHECK-NEXT: {
68 ; CHECK-NEXT: symTag: PointerType
69 ; CHECK-NEXT: length: 8
70 ; CHECK-NEXT: constType: 0
71 ; CHECK-NEXT: isPointerToDataMember: 0
72 ; CHECK-NEXT: isPointerToMemberFunction: 0
73 ; CHECK-NEXT: RValueReference: 0
74 ; CHECK-NEXT: reference: 0
75 ; CHECK-NEXT: restrictedType: 0
76 ; CHECK-NEXT: unalignedType: 0
77 ; CHECK-NEXT: volatileType: 0
78 ; CHECK-NEXT: }
79 ; CHECK-NEXT: {
80 ; CHECK-NEXT: symTag: PointerType
81 ; CHECK-NEXT: length: 8
82 ; CHECK-NEXT: constType: 0
83 ; CHECK-NEXT: isPointerToDataMember: 0
84 ; CHECK-NEXT: isPointerToMemberFunction: 0
85 ; CHECK-NEXT: RValueReference: 0
86 ; CHECK-NEXT: reference: 0
87 ; CHECK-NEXT: restrictedType: 0
88 ; CHECK-NEXT: unalignedType: 0
89 ; CHECK-NEXT: volatileType: 0
90 ; CHECK-NEXT: }
91 ; CHECK-NEXT: {
92 ; CHECK-NEXT: symTag: PointerType
93 ; CHECK-NEXT: length: 8
94 ; CHECK-NEXT: constType: 0
95 ; CHECK-NEXT: isPointerToDataMember: 0
96 ; CHECK-NEXT: isPointerToMemberFunction: 0
97 ; CHECK-NEXT: RValueReference: 0
98 ; CHECK-NEXT: reference: 0
99 ; CHECK-NEXT: restrictedType: 1
100 ; CHECK-NEXT: unalignedType: 0
101 ; CHECK-NEXT: volatileType: 0
102 ; CHECK-NEXT: }
103 ; CHECK-NEXT: {
104 ; CHECK-NEXT: symTag: PointerType
105 ; CHECK-NEXT: length: 8
106 ; CHECK-NEXT: constType: 1
107 ; CHECK-NEXT: isPointerToDataMember: 0
108 ; CHECK-NEXT: isPointerToMemberFunction: 0
109 ; CHECK-NEXT: RValueReference: 0
110 ; CHECK-NEXT: reference: 0
111 ; CHECK-NEXT: restrictedType: 0
112 ; CHECK-NEXT: unalignedType: 0
113 ; CHECK-NEXT: volatileType: 0
114 ; CHECK-NEXT: }
115 ; CHECK-NEXT: {
116 ; CHECK-NEXT: symTag: PointerType
117 ; CHECK-NEXT: length: 8
118 ; CHECK-NEXT: constType: 1
119 ; CHECK-NEXT: isPointerToDataMember: 0
120 ; CHECK-NEXT: isPointerToMemberFunction: 0
121 ; CHECK-NEXT: RValueReference: 0
122 ; CHECK-NEXT: reference: 0
123 ; CHECK-NEXT: restrictedType: 0
124 ; CHECK-NEXT: unalignedType: 0
125 ; CHECK-NEXT: volatileType: 0
126 ; CHECK-NEXT: }
127 ; CHECK-NEXT: {
128 ; CHECK-NEXT: symTag: PointerType
129 ; CHECK-NEXT: length: 8
130 ; CHECK-NEXT: constType: 1
131 ; CHECK-NEXT: isPointerToDataMember: 0
132 ; CHECK-NEXT: isPointerToMemberFunction: 0
133 ; CHECK-NEXT: RValueReference: 0
134 ; CHECK-NEXT: reference: 0
135 ; CHECK-NEXT: restrictedType: 0
136 ; CHECK-NEXT: unalignedType: 0
137 ; CHECK-NEXT: volatileType: 0
138 ; CHECK-NEXT: }
139 ; CHECK-NEXT: {
140 ; CHECK-NEXT: symTag: PointerType
141 ; CHECK-NEXT: length: 8
142 ; CHECK-NEXT: constType: 1
143 ; CHECK-NEXT: isPointerToDataMember: 0
144 ; CHECK-NEXT: isPointerToMemberFunction: 0
145 ; CHECK-NEXT: RValueReference: 0
146 ; CHECK-NEXT: reference: 0
147 ; CHECK-NEXT: restrictedType: 0
148 ; CHECK-NEXT: unalignedType: 0
149 ; CHECK-NEXT: volatileType: 0
150 ; CHECK-NEXT: }
151 ; CHECK-NEXT: {
152 ; CHECK-NEXT: symTag: PointerType
153 ; CHECK-NEXT: length: 8
154 ; CHECK-NEXT: constType: 1
155 ; CHECK-NEXT: isPointerToDataMember: 0
156 ; CHECK-NEXT: isPointerToMemberFunction: 0
157 ; CHECK-NEXT: RValueReference: 0
158 ; CHECK-NEXT: reference: 0
159 ; CHECK-NEXT: restrictedType: 0
160 ; CHECK-NEXT: unalignedType: 0
161 ; CHECK-NEXT: volatileType: 0
162 ; CHECK-NEXT: }
163 ; CHECK-NEXT: {
164 ; CHECK-NEXT: symTag: PointerType
165 ; CHECK-NEXT: length: 8
166 ; CHECK-NEXT: constType: 1
167 ; CHECK-NEXT: isPointerToDataMember: 0
168 ; CHECK-NEXT: isPointerToMemberFunction: 0
169 ; CHECK-NEXT: RValueReference: 0
170 ; CHECK-NEXT: reference: 0
171 ; CHECK-NEXT: restrictedType: 0
172 ; CHECK-NEXT: unalignedType: 0
173 ; CHECK-NEXT: volatileType: 0
174 ; CHECK-NEXT: }
175 ; CHECK-NEXT: {
176 ; CHECK-NEXT: symTag: PointerType
177 ; CHECK-NEXT: length: 8
178 ; CHECK-NEXT: constType: 1
179 ; CHECK-NEXT: isPointerToDataMember: 0
180 ; CHECK-NEXT: isPointerToMemberFunction: 0
181 ; CHECK-NEXT: RValueReference: 0
182 ; CHECK-NEXT: reference: 0
183 ; CHECK-NEXT: restrictedType: 0
184 ; CHECK-NEXT: unalignedType: 0
185 ; CHECK-NEXT: volatileType: 0
186 ; CHECK-NEXT: }
187 ; CHECK-NEXT: {
188 ; CHECK-NEXT: symTag: PointerType
189 ; CHECK-NEXT: length: 8
190 ; CHECK-NEXT: constType: 0
191 ; CHECK-NEXT: isPointerToDataMember: 0
192 ; CHECK-NEXT: isPointerToMemberFunction: 0
193 ; CHECK-NEXT: RValueReference: 0
194 ; CHECK-NEXT: reference: 0
195 ; CHECK-NEXT: restrictedType: 0
196 ; CHECK-NEXT: unalignedType: 0
197 ; CHECK-NEXT: volatileType: 0
198 ; CHECK-NEXT: }
199 ; CHECK-NEXT: {
200 ; CHECK-NEXT: symTag: PointerType
201 ; CHECK-NEXT: length: 8
202 ; CHECK-NEXT: constType: 0
203 ; CHECK-NEXT: isPointerToDataMember: 0
204 ; CHECK-NEXT: isPointerToMemberFunction: 0
205 ; CHECK-NEXT: RValueReference: 1
206 ; CHECK-NEXT: reference: 0
207 ; CHECK-NEXT: restrictedType: 0
208 ; CHECK-NEXT: unalignedType: 0
209 ; CHECK-NEXT: volatileType: 0
210 ; CHECK-NEXT: }
211 ; CHECK-NEXT: {
212 ; CHECK-NEXT: symTag: PointerType
213 ; CHECK-NEXT: length: 8
214 ; CHECK-NEXT: constType: 1
215 ; CHECK-NEXT: isPointerToDataMember: 0
216 ; CHECK-NEXT: isPointerToMemberFunction: 0
217 ; CHECK-NEXT: RValueReference: 0
218 ; CHECK-NEXT: reference: 0
219 ; CHECK-NEXT: restrictedType: 0
220 ; CHECK-NEXT: unalignedType: 0
221 ; CHECK-NEXT: volatileType: 0
222 ; CHECK-NEXT: }
223 ; CHECK-NEXT: {
224 ; CHECK-NEXT: symTag: PointerType
225 ; CHECK-NEXT: length: 8
226 ; CHECK-NEXT: constType: 0
227 ; CHECK-NEXT: isPointerToDataMember: 0
228 ; CHECK-NEXT: isPointerToMemberFunction: 1
229 ; FIXME: isSingleInheritance: 1 # DIA has this property for member pointers
230 ; CHECK-NEXT: RValueReference: 0
231 ; CHECK-NEXT: reference: 0
232 ; CHECK-NEXT: restrictedType: 0
233 ; CHECK-NEXT: unalignedType: 0
234 ; CHECK-NEXT: volatileType: 0
235 ; CHECK-NEXT: }
236 ; CHECK-NEXT: {
237 ; CHECK-NEXT: symTag: PointerType
238 ; CHECK-NEXT: length: 4
239 ; CHECK-NEXT: constType: 0
240 ; CHECK-NEXT: isPointerToDataMember: 1
241 ; CHECK-NEXT: isPointerToMemberFunction: 0
242 ; CHECK-NEXT: RValueReference: 0
243 ; CHECK-NEXT: reference: 0
244 ; CHECK-NEXT: restrictedType: 0
245 ; FIXME: isSingleInheritance: 1 # DIA has this property for member pointers
246 ; CHECK-NEXT: unalignedType: 0
247 ; CHECK-NEXT: volatileType: 0
248 ; CHECK-NEXT: }
249 ; CHECK-NEXT: {
250 ; CHECK-NEXT: symTag: PointerType
251 ; CHECK-NEXT: length: 8
252 ; CHECK-NEXT: constType: 0
253 ; CHECK-NEXT: isPointerToDataMember: 0
254 ; CHECK-NEXT: isPointerToMemberFunction: 1
255 ; CHECK-NEXT: RValueReference: 0
256 ; CHECK-NEXT: reference: 0
257 ; CHECK-NEXT: restrictedType: 0
258 ; FIXME: isSingleInheritance: 1 # DIA has this property for member pointers
259 ; CHECK-NEXT: unalignedType: 0
260 ; CHECK-NEXT: volatileType: 0
261 ; CHECK-NEXT: }
262 ; CHECK-NEXT: {
263 ; CHECK-NEXT: symTag: PointerType
264 ; CHECK-NEXT: length: 8
265 ; CHECK-NEXT: constType: 0
266 ; CHECK-NEXT: isPointerToDataMember: 0
267 ; CHECK-NEXT: isPointerToMemberFunction: 0
268 ; CHECK-NEXT: RValueReference: 0
269 ; CHECK-NEXT: reference: 0
270 ; CHECK-NEXT: restrictedType: 0
271 ; CHECK-NEXT: unalignedType: 0
272 ; CHECK-NEXT: volatileType: 0
273 ; CHECK-NEXT: }
274 ; CHECK-NEXT: {
275 ; CHECK-NEXT: symTag: PointerType
276 ; CHECK-NEXT: length: 8
277 ; CHECK-NEXT: constType: 0
278 ; CHECK-NEXT: isPointerToDataMember: 0
279 ; CHECK-NEXT: isPointerToMemberFunction: 0
280 ; CHECK-NEXT: RValueReference: 0
281 ; CHECK-NEXT: reference: 0
282 ; CHECK-NEXT: restrictedType: 0
283 ; CHECK-NEXT: unalignedType: 0
284 ; CHECK-NEXT: volatileType: 0
285 ; CHECK-NEXT: }
286 ; CHECK-NEXT: {
287 ; CHECK-NEXT: symTag: PointerType
288 ; CHECK-NEXT: length: 8
289 ; CHECK-NEXT: constType: 0
290 ; CHECK-NEXT: isPointerToDataMember: 0
291 ; CHECK-NEXT: isPointerToMemberFunction: 0
292 ; CHECK-NEXT: RValueReference: 0
293 ; CHECK-NEXT: reference: 0
294 ; CHECK-NEXT: restrictedType: 1
295 ; CHECK-NEXT: unalignedType: 0
296 ; CHECK-NEXT: volatileType: 0
297 ; CHECK-NEXT: }
298 ; CHECK-NEXT: {
299 ; CHECK-NEXT: symTag: PointerType
300 ; CHECK-NEXT: length: 8
301 ; CHECK-NEXT: constType: 0
302 ; CHECK-NEXT: isPointerToDataMember: 0
303 ; CHECK-NEXT: isPointerToMemberFunction: 0
304 ; CHECK-NEXT: RValueReference: 0
305 ; CHECK-NEXT: reference: 0
306 ; CHECK-NEXT: restrictedType: 0
307 ; CHECK-NEXT: unalignedType: 0
308 ; CHECK-NEXT: volatileType: 0
309 ; CHECK-NEXT: }
310 ; CHECK-NEXT: {
311 ; CHECK-NEXT: symTag: PointerType
312 ; CHECK-NEXT: length: 8
313 ; CHECK-NEXT: constType: 0
314 ; CHECK-NEXT: isPointerToDataMember: 0
315 ; CHECK-NEXT: isPointerToMemberFunction: 0
316 ; CHECK-NEXT: RValueReference: 0
317 ; CHECK-NEXT: reference: 0
318 ; CHECK-NEXT: restrictedType: 0
319 ; CHECK-NEXT: unalignedType: 0
320 ; CHECK-NEXT: volatileType: 0
321 ; CHECK-NEXT: }
322 ; CHECK-NEXT: {
323 ; CHECK-NEXT: symTag: PointerType
324 ; CHECK-NEXT: length: 8
325 ; CHECK-NEXT: constType: 0
326 ; CHECK-NEXT: isPointerToDataMember: 0
327 ; CHECK-NEXT: isPointerToMemberFunction: 0
328 ; CHECK-NEXT: RValueReference: 0
329 ; CHECK-NEXT: reference: 0
330 ; CHECK-NEXT: restrictedType: 0
331 ; CHECK-NEXT: unalignedType: 0
332 ; CHECK-NEXT: volatileType: 0
333 ; CHECK-NEXT: }
334 ; CHECK-NEXT: {
335 ; CHECK-NEXT: symTag: PointerType
336 ; CHECK-NEXT: length: 8
337 ; CHECK-NEXT: constType: 0
338 ; CHECK-NEXT: isPointerToDataMember: 0
339 ; CHECK-NEXT: isPointerToMemberFunction: 0
340 ; CHECK-NEXT: RValueReference: 1
341 ; CHECK-NEXT: reference: 0
342 ; CHECK-NEXT: restrictedType: 0
343 ; CHECK-NEXT: unalignedType: 0
344 ; CHECK-NEXT: volatileType: 0
345 ; CHECK-NEXT: }
346 ; CHECK-NEXT: {
347 ; CHECK-NEXT: symTag: PointerType
348 ; CHECK-NEXT: length: 8
349 ; CHECK-NEXT: constType: 0
350 ; CHECK-NEXT: isPointerToDataMember: 0
351 ; CHECK-NEXT: isPointerToMemberFunction: 0
352 ; CHECK-NEXT: RValueReference: 0
353 ; CHECK-NEXT: reference: 1
354 ; CHECK-NEXT: restrictedType: 0
355 ; CHECK-NEXT: unalignedType: 0
356 ; CHECK-NEXT: volatileType: 0
357 ; CHECK-NEXT: }
164164 cl::opt Native("native", cl::desc("Use native PDB reader instead of DIA"),
165165 cl::sub(DiaDumpSubcommand));
166166
167 static cl::opt
168 ShowClassHierarchy("hierarchy", cl::desc("Show lexical and class parents"),
169 cl::sub(DiaDumpSubcommand));
170 static cl::opt NoSymIndexIds(
171 "no-ids",
172 cl::desc("Don't show any SymIndexId fields (overrides -hierarchy)"),
173 cl::sub(DiaDumpSubcommand));
174
175 static cl::opt
176 Recurse("recurse",
177 cl::desc("When dumping a SymIndexId, dump the full details of the "
178 "corresponding record"),
179 cl::sub(DiaDumpSubcommand));
180
167181 static cl::opt Enums("enums", cl::desc("Dump enum types"),
168182 cl::sub(DiaDumpSubcommand));
169183 static cl::opt Pointers("pointers", cl::desc("Dump enum types"),
964978 if (opts::diadump::Pointers)
965979 SymTypes.push_back(PDB_SymType::PointerType);
966980
981 PdbSymbolIdField Ids = opts::diadump::NoSymIndexIds ? PdbSymbolIdField::None
982 : PdbSymbolIdField::All;
983 PdbSymbolIdField Recurse = PdbSymbolIdField::None;
984 if (opts::diadump::Recurse)
985 Recurse = PdbSymbolIdField::All;
986 if (!opts::diadump::ShowClassHierarchy)
987 Ids &= ~(PdbSymbolIdField::ClassParent | PdbSymbolIdField::LexicalParent);
988
967989 for (PDB_SymType ST : SymTypes) {
968990 auto Children = GlobalScope->findAllChildren(ST);
969991 while (auto Child = Children->getNext()) {
970992 outs() << "{";
971 Child->defaultDump(outs(), 2);
993 Child->defaultDump(outs(), 2, Ids, Recurse);
972994 if (auto Enum = dyn_cast(Child.get())) {
973995 auto Enumerators = Enum->findAllChildren();
974996 while (auto Enumerator = Enumerators->getNext()) {
975997 outs() << " {";
976 Enumerator->defaultDump(outs(), 4);
998 Enumerator->defaultDump(outs(), 4, Ids, Recurse);
977999 outs() << "\n }\n";
9781000 }
9791001 }