LLVM 24.0.0git
NativeTypeUDT.cpp
Go to the documentation of this file.
1//===- NativeTypeUDT.cpp - info about class/struct type ---------*- 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
14
15using namespace llvm;
16using namespace llvm::codeview;
17using namespace llvm::pdb;
18
23
28
34
36
37void NativeTypeUDT::dump(raw_ostream &OS, int Indent,
38 PdbSymbolIdField ShowIdFields,
39 PdbSymbolIdField RecurseIdFields) const {
40
41 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
42
43 dumpSymbolField(OS, "name", getName(), Indent);
44 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
46 RecurseIdFields);
47 if (Modifiers)
48 dumpSymbolIdField(OS, "unmodifiedTypeId", getUnmodifiedTypeId(), Indent,
50 RecurseIdFields);
52 dumpSymbolField(OS, "virtualTableShapeId", getVirtualTableShapeId(),
53 Indent);
54 dumpSymbolField(OS, "length", getLength(), Indent);
55 dumpSymbolField(OS, "udtKind", getUdtKind(), Indent);
56 dumpSymbolField(OS, "constructor", hasConstructor(), Indent);
57 dumpSymbolField(OS, "constType", isConstType(), Indent);
58 dumpSymbolField(OS, "hasAssignmentOperator", hasAssignmentOperator(), Indent);
59 dumpSymbolField(OS, "hasCastOperator", hasCastOperator(), Indent);
60 dumpSymbolField(OS, "hasNestedTypes", hasNestedTypes(), Indent);
61 dumpSymbolField(OS, "overloadedOperator", hasOverloadedOperator(), Indent);
62 dumpSymbolField(OS, "isInterfaceUdt", isInterfaceUdt(), Indent);
63 dumpSymbolField(OS, "intrinsic", isIntrinsic(), Indent);
64 dumpSymbolField(OS, "nested", isNested(), Indent);
65 dumpSymbolField(OS, "packed", isPacked(), Indent);
66 dumpSymbolField(OS, "isRefUdt", isRefUdt(), Indent);
67 dumpSymbolField(OS, "scoped", isScoped(), Indent);
68 dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
69 dumpSymbolField(OS, "isValueUdt", isValueUdt(), Indent);
70 dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
71}
72
73std::string NativeTypeUDT::getName() const {
75 return UnmodifiedType->getName();
76
77 return std::string(Tag->getName());
78}
79
81
84 return UnmodifiedType->getSymIndexId();
85
86 return 0;
87}
88
91 return UnmodifiedType->getVirtualTableShapeId();
92
93 if (Class)
94 return Session.getSymbolCache().findSymbolByTypeIndex(Class->VTableShape);
95
96 return 0;
97}
98
99uint64_t NativeTypeUDT::getLength() const {
100 if (UnmodifiedType)
101 return UnmodifiedType->getLength();
102
103 if (Class)
104 return Class->getSize();
105
106 return Union->getSize();
107}
108
110 if (UnmodifiedType)
111 return UnmodifiedType->getUdtKind();
112
113 switch (Tag->Kind) {
114 case TypeRecordKind::Class:
115 case TypeRecordKind::Class2:
116 return PDB_UdtType::Class;
117 case TypeRecordKind::Union:
118 case TypeRecordKind::Union2:
119 return PDB_UdtType::Union;
120 case TypeRecordKind::Struct:
121 case TypeRecordKind::Struct2:
122 return PDB_UdtType::Struct;
123 case TypeRecordKind::Interface:
124 case TypeRecordKind::Interface2:
126 default:
127 llvm_unreachable("Unexpected udt kind");
128 }
129}
130
132 if (UnmodifiedType)
133 return UnmodifiedType->hasConstructor();
134
135 return (Tag->Options & ClassOptions::HasConstructorOrDestructor) !=
137}
138
140 if (!Modifiers)
141 return false;
142 return (Modifiers->Modifiers & ModifierOptions::Const) !=
144}
145
147 if (UnmodifiedType)
148 return UnmodifiedType->hasAssignmentOperator();
149
152}
153
155 if (UnmodifiedType)
156 return UnmodifiedType->hasCastOperator();
157
158 return (Tag->Options & ClassOptions::HasConversionOperator) !=
160}
161
163 if (UnmodifiedType)
164 return UnmodifiedType->hasNestedTypes();
165
166 return (Tag->Options & ClassOptions::ContainsNestedClass) !=
168}
169
171 if (UnmodifiedType)
172 return UnmodifiedType->hasOverloadedOperator();
173
174 return (Tag->Options & ClassOptions::HasOverloadedOperator) !=
176}
177
178bool NativeTypeUDT::isInterfaceUdt() const { return false; }
179
181 if (UnmodifiedType)
182 return UnmodifiedType->isIntrinsic();
183
184 return (Tag->Options & ClassOptions::Intrinsic) != ClassOptions::None;
185}
186
188 if (UnmodifiedType)
189 return UnmodifiedType->isNested();
190
191 return (Tag->Options & ClassOptions::Nested) != ClassOptions::None;
192}
193
195 if (UnmodifiedType)
196 return UnmodifiedType->isPacked();
197
198 return (Tag->Options & ClassOptions::Packed) != ClassOptions::None;
199}
200
201bool NativeTypeUDT::isRefUdt() const { return false; }
202
204 if (UnmodifiedType)
205 return UnmodifiedType->isScoped();
206
207 return (Tag->Options & ClassOptions::Scoped) != ClassOptions::None;
208}
209
210bool NativeTypeUDT::isValueUdt() const { return false; }
211
213 if (!Modifiers)
214 return false;
215 return (Modifiers->Modifiers & ModifierOptions::Unaligned) !=
217}
218
220 if (!Modifiers)
221 return false;
222 return (Modifiers->Modifiers & ModifierOptions::Volatile) !=
224}
A 32-bit type reference.
Definition TypeIndex.h:97
NativeRawSymbol(NativeSession &PDBSession, PDB_SymType Tag, SymIndexId SymbolId)
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
PDB_UdtType getUdtKind() const override
SymIndexId getVirtualTableShapeId() const override
bool hasNestedTypes() const override
bool isPacked() const override
bool isRefUdt() const override
bool isUnalignedType() const override
uint64_t getLength() const override
bool isVolatileType() const override
bool isValueUdt() const override
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
bool isScoped() const override
NativeTypeUDT * UnmodifiedType
SymIndexId getUnmodifiedTypeId() const override
NativeTypeUDT(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, codeview::ClassRecord Class)
SymIndexId getLexicalParentId() const override
std::optional< codeview::UnionRecord > Union
std::optional< codeview::ClassRecord > Class
bool hasAssignmentOperator() const override
bool hasCastOperator() const override
std::optional< codeview::ModifierRecord > Modifiers
codeview::TagRecord * Tag
bool hasConstructor() const override
std::string getName() const override
codeview::TypeIndex Index
bool isConstType() const override
bool hasOverloadedOperator() const override
bool isNested() const override
bool isIntrinsic() const override
bool isInterfaceUdt() const override
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint32_t SymIndexId
Definition PDBTypes.h:26
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition PDBExtras.h:51
PDB_UdtType
These values correspond to the UdtKind enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:310
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:243
LLVM_ABI void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878