Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / include / llvm / DebugInfo / PDB / PDBTypes.h
blob6d26b64ddf7264a53db6f170fa834e9827332039
1 //===- PDBTypes.h - Defines enums for various fields contained in PDB ----====//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
10 #define LLVM_DEBUGINFO_PDB_PDBTYPES_H
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
15 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
16 #include <cctype>
17 #include <cstddef>
18 #include <cstdint>
19 #include <cstring>
20 #include <functional>
22 namespace llvm {
23 namespace pdb {
25 typedef uint32_t SymIndexId;
27 class IPDBDataStream;
28 class IPDBInjectedSource;
29 class IPDBLineNumber;
30 class IPDBSectionContrib;
31 class IPDBSourceFile;
32 class IPDBTable;
33 class PDBSymDumper;
34 class PDBSymbol;
35 class PDBSymbolExe;
36 class PDBSymbolCompiland;
37 class PDBSymbolCompilandDetails;
38 class PDBSymbolCompilandEnv;
39 class PDBSymbolFunc;
40 class PDBSymbolBlock;
41 class PDBSymbolData;
42 class PDBSymbolAnnotation;
43 class PDBSymbolLabel;
44 class PDBSymbolPublicSymbol;
45 class PDBSymbolTypeUDT;
46 class PDBSymbolTypeEnum;
47 class PDBSymbolTypeFunctionSig;
48 class PDBSymbolTypePointer;
49 class PDBSymbolTypeArray;
50 class PDBSymbolTypeBuiltin;
51 class PDBSymbolTypeTypedef;
52 class PDBSymbolTypeBaseClass;
53 class PDBSymbolTypeFriend;
54 class PDBSymbolTypeFunctionArg;
55 class PDBSymbolFuncDebugStart;
56 class PDBSymbolFuncDebugEnd;
57 class PDBSymbolUsingNamespace;
58 class PDBSymbolTypeVTableShape;
59 class PDBSymbolTypeVTable;
60 class PDBSymbolCustom;
61 class PDBSymbolThunk;
62 class PDBSymbolTypeCustom;
63 class PDBSymbolTypeManaged;
64 class PDBSymbolTypeDimension;
65 class PDBSymbolUnknown;
67 using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>;
68 using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
69 using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
70 using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
71 using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
72 using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>;
73 using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>;
74 using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>;
76 /// Specifies which PDB reader implementation is to be used. Only a value
77 /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
78 enum class PDB_ReaderType {
79 DIA = 0,
80 Native = 1,
83 /// An enumeration indicating the type of data contained in this table.
84 enum class PDB_TableType {
85 TableInvalid = 0,
86 Symbols,
87 SourceFiles,
88 LineNumbers,
89 SectionContribs,
90 Segments,
91 InjectedSources,
92 FrameData,
93 InputAssemblyFiles,
94 Dbg
97 /// Defines flags used for enumerating child symbols. This corresponds to the
98 /// NameSearchOptions enumeration which is documented here:
99 /// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
100 enum PDB_NameSearchFlags {
101 NS_Default = 0x0,
102 NS_CaseSensitive = 0x1,
103 NS_CaseInsensitive = 0x2,
104 NS_FileNameExtMatch = 0x4,
105 NS_Regex = 0x8,
106 NS_UndecoratedName = 0x10,
108 // For backward compatibility.
109 NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch,
110 NS_CaseRegex = NS_Regex | NS_CaseSensitive,
111 NS_CaseInRex = NS_Regex | NS_CaseInsensitive
114 /// Specifies the hash algorithm that a source file from a PDB was hashed with.
115 /// This corresponds to the CV_SourceChksum_t enumeration and are documented
116 /// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
117 enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 };
119 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
120 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
121 using PDB_Cpu = codeview::CPUType;
123 enum class PDB_Machine {
124 Invalid = 0xffff,
125 Unknown = 0x0,
126 Am33 = 0x13,
127 Amd64 = 0x8664,
128 Arm = 0x1C0,
129 ArmNT = 0x1C4,
130 Ebc = 0xEBC,
131 x86 = 0x14C,
132 Ia64 = 0x200,
133 M32R = 0x9041,
134 Mips16 = 0x266,
135 MipsFpu = 0x366,
136 MipsFpu16 = 0x466,
137 PowerPC = 0x1F0,
138 PowerPCFP = 0x1F1,
139 R4000 = 0x166,
140 SH3 = 0x1A2,
141 SH3DSP = 0x1A3,
142 SH4 = 0x1A6,
143 SH5 = 0x1A8,
144 Thumb = 0x1C2,
145 WceMipsV2 = 0x169
148 enum class PDB_SourceCompression {
149 None,
150 RunLengthEncoded,
151 Huffman,
155 /// These values correspond to the CV_call_e enumeration, and are documented
156 /// at the following locations:
157 /// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
158 /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
159 using PDB_CallingConv = codeview::CallingConvention;
161 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
162 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
163 using PDB_Lang = codeview::SourceLanguage;
165 /// These values correspond to the DataKind enumeration, and are documented
166 /// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
167 enum class PDB_DataKind {
168 Unknown,
169 Local,
170 StaticLocal,
171 Param,
172 ObjectPtr,
173 FileStatic,
174 Global,
175 Member,
176 StaticMember,
177 Constant
180 /// These values correspond to the SymTagEnum enumeration, and are documented
181 /// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
182 enum class PDB_SymType {
183 None,
184 Exe,
185 Compiland,
186 CompilandDetails,
187 CompilandEnv,
188 Function,
189 Block,
190 Data,
191 Annotation,
192 Label,
193 PublicSymbol,
194 UDT,
195 Enum,
196 FunctionSig,
197 PointerType,
198 ArrayType,
199 BuiltinType,
200 Typedef,
201 BaseClass,
202 Friend,
203 FunctionArg,
204 FuncDebugStart,
205 FuncDebugEnd,
206 UsingNamespace,
207 VTableShape,
208 VTable,
209 Custom,
210 Thunk,
211 CustomType,
212 ManagedType,
213 Dimension,
214 CallSite,
215 InlineSite,
216 BaseInterface,
217 VectorType,
218 MatrixType,
219 HLSLType,
220 Caller,
221 Callee,
222 Export,
223 HeapAllocationSite,
224 CoffGroup,
225 Inlinee,
229 /// These values correspond to the LocationType enumeration, and are documented
230 /// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
231 enum class PDB_LocType {
232 Null,
233 Static,
234 TLS,
235 RegRel,
236 ThisRel,
237 Enregistered,
238 BitField,
239 Slot,
240 IlRel,
241 MetaData,
242 Constant,
243 RegRelAliasIndir,
247 /// These values correspond to the UdtKind enumeration, and are documented
248 /// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
249 enum class PDB_UdtType { Struct, Class, Union, Interface };
251 /// These values correspond to the StackFrameTypeEnum enumeration, and are
252 /// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
253 enum class PDB_StackFrameType : uint16_t {
254 FPO,
255 KernelTrap,
256 KernelTSS,
257 EBP,
258 FrameData,
259 Unknown = 0xffff
262 /// These values correspond to the MemoryTypeEnum enumeration, and are
263 /// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
264 enum class PDB_MemoryType : uint16_t {
265 Code,
266 Data,
267 Stack,
268 HeapCode,
269 Any = 0xffff
272 /// These values correspond to the Basictype enumeration, and are documented
273 /// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
274 enum class PDB_BuiltinType {
275 None = 0,
276 Void = 1,
277 Char = 2,
278 WCharT = 3,
279 Int = 6,
280 UInt = 7,
281 Float = 8,
282 BCD = 9,
283 Bool = 10,
284 Long = 13,
285 ULong = 14,
286 Currency = 25,
287 Date = 26,
288 Variant = 27,
289 Complex = 28,
290 Bitfield = 29,
291 BSTR = 30,
292 HResult = 31,
293 Char16 = 32,
294 Char32 = 33
297 /// These values correspond to the flags that can be combined to control the
298 /// return of an undecorated name for a C++ decorated name, and are documented
299 /// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
300 enum PDB_UndnameFlags : uint32_t {
301 Undname_Complete = 0x0,
302 Undname_NoLeadingUnderscores = 0x1,
303 Undname_NoMsKeywords = 0x2,
304 Undname_NoFuncReturns = 0x4,
305 Undname_NoAllocModel = 0x8,
306 Undname_NoAllocLang = 0x10,
307 Undname_Reserved1 = 0x20,
308 Undname_Reserved2 = 0x40,
309 Undname_NoThisType = 0x60,
310 Undname_NoAccessSpec = 0x80,
311 Undname_NoThrowSig = 0x100,
312 Undname_NoMemberType = 0x200,
313 Undname_NoReturnUDTModel = 0x400,
314 Undname_32BitDecode = 0x800,
315 Undname_NameOnly = 0x1000,
316 Undname_TypeOnly = 0x2000,
317 Undname_HaveParams = 0x4000,
318 Undname_NoECSU = 0x8000,
319 Undname_NoIdentCharCheck = 0x10000,
320 Undname_NoPTR64 = 0x20000
323 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
325 struct VersionInfo {
326 uint32_t Major;
327 uint32_t Minor;
328 uint32_t Build;
329 uint32_t QFE;
332 enum PDB_VariantType {
333 Empty,
334 Unknown,
335 Int8,
336 Int16,
337 Int32,
338 Int64,
339 Single,
340 Double,
341 UInt8,
342 UInt16,
343 UInt32,
344 UInt64,
345 Bool,
346 String
349 struct Variant {
350 Variant() = default;
352 explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
353 explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
354 explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
355 Value.Int16 = V;
357 explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
358 Value.Int32 = V;
360 explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
361 Value.Int64 = V;
363 explicit Variant(float V) : Type(PDB_VariantType::Single) {
364 Value.Single = V;
366 explicit Variant(double V) : Type(PDB_VariantType::Double) {
367 Value.Double = V;
369 explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
370 Value.UInt8 = V;
372 explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) {
373 Value.UInt16 = V;
375 explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) {
376 Value.UInt32 = V;
378 explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) {
379 Value.UInt64 = V;
382 Variant(const Variant &Other) {
383 *this = Other;
386 ~Variant() {
387 if (Type == PDB_VariantType::String)
388 delete[] Value.String;
391 PDB_VariantType Type = PDB_VariantType::Empty;
392 union {
393 bool Bool;
394 int8_t Int8;
395 int16_t Int16;
396 int32_t Int32;
397 int64_t Int64;
398 float Single;
399 double Double;
400 uint8_t UInt8;
401 uint16_t UInt16;
402 uint32_t UInt32;
403 uint64_t UInt64;
404 char *String;
405 } Value;
407 #define VARIANT_EQUAL_CASE(Enum) \
408 case PDB_VariantType::Enum: \
409 return Value.Enum == Other.Value.Enum;
411 bool operator==(const Variant &Other) const {
412 if (Type != Other.Type)
413 return false;
414 switch (Type) {
415 VARIANT_EQUAL_CASE(Bool)
416 VARIANT_EQUAL_CASE(Int8)
417 VARIANT_EQUAL_CASE(Int16)
418 VARIANT_EQUAL_CASE(Int32)
419 VARIANT_EQUAL_CASE(Int64)
420 VARIANT_EQUAL_CASE(Single)
421 VARIANT_EQUAL_CASE(Double)
422 VARIANT_EQUAL_CASE(UInt8)
423 VARIANT_EQUAL_CASE(UInt16)
424 VARIANT_EQUAL_CASE(UInt32)
425 VARIANT_EQUAL_CASE(UInt64)
426 VARIANT_EQUAL_CASE(String)
427 default:
428 return true;
432 #undef VARIANT_EQUAL_CASE
434 bool operator!=(const Variant &Other) const { return !(*this == Other); }
435 Variant &operator=(const Variant &Other) {
436 if (this == &Other)
437 return *this;
438 if (Type == PDB_VariantType::String)
439 delete[] Value.String;
440 Type = Other.Type;
441 Value = Other.Value;
442 if (Other.Type == PDB_VariantType::String &&
443 Other.Value.String != nullptr) {
444 Value.String = new char[strlen(Other.Value.String) + 1];
445 ::strcpy(Value.String, Other.Value.String);
447 return *this;
451 } // end namespace pdb
452 } // end namespace llvm
454 namespace std {
456 template <> struct hash<llvm::pdb::PDB_SymType> {
457 using argument_type = llvm::pdb::PDB_SymType;
458 using result_type = std::size_t;
460 result_type operator()(const argument_type &Arg) const {
461 return std::hash<int>()(static_cast<int>(Arg));
465 } // end namespace std
467 #endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H