Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
[oota-llvm.git] / include / llvm / DebugInfo / PDB / PDBTypes.h
1 //===- PDBTypes.h - Defines enums for various fields contained in PDB ---*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
11 #define LLVM_DEBUGINFO_PDB_PDBTYPES_H
12
13 #include "llvm/Config/llvm-config.h"
14 #include <functional>
15 #include <stdint.h>
16
17 namespace llvm {
18
19 class PDBSymDumper;
20 class PDBSymbol;
21
22 class IPDBDataStream;
23 template <class T> class IPDBEnumChildren;
24 class IPDBLineNumber;
25 class IPDBRawSymbol;
26 class IPDBSession;
27 class IPDBSourceFile;
28
29 typedef IPDBEnumChildren<PDBSymbol> IPDBEnumSymbols;
30 typedef IPDBEnumChildren<IPDBSourceFile> IPDBEnumSourceFiles;
31 typedef IPDBEnumChildren<IPDBDataStream> IPDBEnumDataStreams;
32 typedef IPDBEnumChildren<IPDBLineNumber> IPDBEnumLineNumbers;
33
34 class PDBSymbolExe;
35 class PDBSymbolCompiland;
36 class PDBSymbolCompilandDetails;
37 class PDBSymbolCompilandEnv;
38 class PDBSymbolFunc;
39 class PDBSymbolBlock;
40 class PDBSymbolData;
41 class PDBSymbolAnnotation;
42 class PDBSymbolLabel;
43 class PDBSymbolPublicSymbol;
44 class PDBSymbolTypeUDT;
45 class PDBSymbolTypeEnum;
46 class PDBSymbolTypeFunctionSig;
47 class PDBSymbolTypePointer;
48 class PDBSymbolTypeArray;
49 class PDBSymbolTypeBuiltin;
50 class PDBSymbolTypeTypedef;
51 class PDBSymbolTypeBaseClass;
52 class PDBSymbolTypeFriend;
53 class PDBSymbolTypeFunctionArg;
54 class PDBSymbolFuncDebugStart;
55 class PDBSymbolFuncDebugEnd;
56 class PDBSymbolUsingNamespace;
57 class PDBSymbolTypeVTableShape;
58 class PDBSymbolTypeVTable;
59 class PDBSymbolCustom;
60 class PDBSymbolThunk;
61 class PDBSymbolTypeCustom;
62 class PDBSymbolTypeManaged;
63 class PDBSymbolTypeDimension;
64 class PDBSymbolUnknown;
65
66 /// Specifies which PDB reader implementation is to be used.  Only a value
67 /// of PDB_ReaderType::DIA is supported.
68 enum class PDB_ReaderType {
69   DIA = 0,
70 };
71
72 /// Defines a 128-bit unique identifier.  This maps to a GUID on Windows, but
73 /// is abstracted here for the purposes of non-Windows platforms that don't have
74 /// the GUID structure defined.
75 struct PDB_UniqueId {
76   uint64_t HighPart;
77   uint64_t LowPart;
78 };
79
80 /// An enumeration indicating the type of data contained in this table.
81 enum class PDB_TableType {
82   Symbols,
83   SourceFiles,
84   LineNumbers,
85   SectionContribs,
86   Segments,
87   InjectedSources,
88   FrameData
89 };
90
91 /// Defines flags used for enumerating child symbols.  This corresponds to the
92 /// NameSearchOptions enumeration which is documented here:
93 /// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
94 enum PDB_NameSearchFlags {
95   NS_Default = 0x0,
96   NS_CaseSensitive = 0x1,
97   NS_CaseInsensitive = 0x2,
98   NS_FileNameExtMatch = 0x4,
99   NS_Regex = 0x8,
100   NS_UndecoratedName = 0x10
101 };
102
103 /// Specifies the hash algorithm that a source file from a PDB was hashed with.
104 /// This corresponds to the CV_SourceChksum_t enumeration and are documented
105 /// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
106 enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2 };
107
108 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
109 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
110 enum class PDB_Cpu {
111   Intel8080 = 0x0,
112   Intel8086 = 0x1,
113   Intel80286 = 0x2,
114   Intel80386 = 0x3,
115   Intel80486 = 0x4,
116   Pentium = 0x5,
117   PentiumPro = 0x6,
118   Pentium3 = 0x7,
119   MIPS = 0x10,
120   MIPS16 = 0x11,
121   MIPS32 = 0x12,
122   MIPS64 = 0x13,
123   MIPSI = 0x14,
124   MIPSII = 0x15,
125   MIPSIII = 0x16,
126   MIPSIV = 0x17,
127   MIPSV = 0x18,
128   M68000 = 0x20,
129   M68010 = 0x21,
130   M68020 = 0x22,
131   M68030 = 0x23,
132   M68040 = 0x24,
133   Alpha = 0x30,
134   Alpha21164 = 0x31,
135   Alpha21164A = 0x32,
136   Alpha21264 = 0x33,
137   Alpha21364 = 0x34,
138   PPC601 = 0x40,
139   PPC603 = 0x41,
140   PPC604 = 0x42,
141   PPC620 = 0x43,
142   PPCFP = 0x44,
143   PPCBE = 0x45,
144   SH3 = 0x50,
145   SH3E = 0x51,
146   SH3DSP = 0x52,
147   SH4 = 0x53,
148   SHMedia = 0x54,
149   ARM3 = 0x60,
150   ARM4 = 0x61,
151   ARM4T = 0x62,
152   ARM5 = 0x63,
153   ARM5T = 0x64,
154   ARM6 = 0x65,
155   ARM_XMAC = 0x66,
156   ARM_WMMX = 0x67,
157   ARM7 = 0x68,
158   Omni = 0x70,
159   Ia64 = 0x80,
160   Ia64_2 = 0x81,
161   CEE = 0x90,
162   AM33 = 0xa0,
163   M32R = 0xb0,
164   TriCore = 0xc0,
165   X64 = 0xd0,
166   EBC = 0xe0,
167   Thumb = 0xf0,
168   ARMNT = 0xf4,
169   D3D11_Shader = 0x100,
170 };
171
172 enum class PDB_Machine {
173   Invalid = 0xffff,
174   Unknown = 0x0,
175   Am33 = 0x13,
176   Amd64 = 0x8664,
177   Arm = 0x1C0,
178   ArmNT = 0x1C4,
179   Ebc = 0xEBC,
180   x86 = 0x14C,
181   Ia64 = 0x200,
182   M32R = 0x9041,
183   Mips16 = 0x266,
184   MipsFpu = 0x366,
185   MipsFpu16 = 0x466,
186   PowerPC = 0x1F0,
187   PowerPCFP = 0x1F1,
188   R4000 = 0x166,
189   SH3 = 0x1A2,
190   SH3DSP = 0x1A3,
191   SH4 = 0x1A6,
192   SH5 = 0x1A8,
193   Thumb = 0x1C2,
194   WceMipsV2 = 0x169
195 };
196
197 /// These values correspond to the CV_call_e enumeration, and are documented
198 /// at the following locations:
199 ///   https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
200 ///   https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
201 ///
202 enum class PDB_CallingConv {
203   NearCdecl = 0x00,
204   FarCdecl = 0x01,
205   NearPascal = 0x02,
206   FarPascal = 0x03,
207   NearFastcall = 0x04,
208   FarFastcall = 0x05,
209   Skipped = 0x06,
210   NearStdcall = 0x07,
211   FarStdcall = 0x08,
212   NearSyscall = 0x09,
213   FarSyscall = 0x0a,
214   Thiscall = 0x0b,
215   MipsCall = 0x0c,
216   Generic = 0x0d,
217   Alphacall = 0x0e,
218   Ppccall = 0x0f,
219   SuperHCall = 0x10,
220   Armcall = 0x11,
221   AM33call = 0x12,
222   Tricall = 0x13,
223   Sh5call = 0x14,
224   M32R = 0x15,
225   Clrcall = 0x16,
226   Inline = 0x17,
227   NearVectorcall = 0x18,
228   Reserved = 0x19,
229 };
230
231 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
232 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
233 enum class PDB_Lang {
234   C = 0x00,
235   Cpp = 0x01,
236   Fortran = 0x02,
237   Masm = 0x03,
238   Pascal = 0x04,
239   Basic = 0x05,
240   Cobol = 0x06,
241   Link = 0x07,
242   Cvtres = 0x08,
243   Cvtpgd = 0x09,
244   CSharp = 0x0a,
245   VB = 0x0b,
246   ILAsm = 0x0c,
247   Java = 0x0d,
248   JScript = 0x0e,
249   MSIL = 0x0f,
250   HLSL = 0x10
251 };
252
253 /// These values correspond to the DataKind enumeration, and are documented
254 /// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
255 enum class PDB_DataKind {
256   Unknown,
257   Local,
258   StaticLocal,
259   Param,
260   ObjectPtr,
261   FileStatic,
262   Global,
263   Member,
264   StaticMember,
265   Constant
266 };
267
268 /// These values correspond to the SymTagEnum enumeration, and are documented
269 /// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
270 enum class PDB_SymType {
271   None,
272   Exe,
273   Compiland,
274   CompilandDetails,
275   CompilandEnv,
276   Function,
277   Block,
278   Data,
279   Annotation,
280   Label,
281   PublicSymbol,
282   UDT,
283   Enum,
284   FunctionSig,
285   PointerType,
286   ArrayType,
287   BuiltinType,
288   Typedef,
289   BaseClass,
290   Friend,
291   FunctionArg,
292   FuncDebugStart,
293   FuncDebugEnd,
294   UsingNamespace,
295   VTableShape,
296   VTable,
297   Custom,
298   Thunk,
299   CustomType,
300   ManagedType,
301   Dimension,
302   Max
303 };
304
305 /// These values correspond to the LocationType enumeration, and are documented
306 /// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
307 enum class PDB_LocType {
308   Null,
309   Static,
310   TLS,
311   RegRel,
312   ThisRel,
313   Enregistered,
314   BitField,
315   Slot,
316   IlRel,
317   MetaData,
318   Constant,
319   Max
320 };
321
322 /// These values correspond to the THUNK_ORDINAL enumeration, and are documented
323 /// here: https://msdn.microsoft.com/en-us/library/dh0k8hft.aspx
324 enum class PDB_ThunkOrdinal {
325   Standard,
326   ThisAdjustor,
327   Vcall,
328   Pcode,
329   UnknownLoad,
330   TrampIncremental,
331   BranchIsland
332 };
333
334 /// These values correspond to the UdtKind enumeration, and are documented
335 /// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
336 enum class PDB_UdtType { Struct, Class, Union, Interface };
337
338 /// These values correspond to the StackFrameTypeEnum enumeration, and are
339 /// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
340 enum class PDB_StackFrameType { FPO, KernelTrap, KernelTSS, EBP, FrameData };
341
342 /// These values correspond to the StackFrameTypeEnum enumeration, and are
343 /// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
344 enum class PDB_MemoryType { Code, Data, Stack, HeapCode };
345
346 /// These values correspond to the Basictype enumeration, and are documented
347 /// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
348 enum class PDB_BuiltinType {
349   None = 0,
350   Void = 1,
351   Char = 2,
352   WCharT = 3,
353   Int = 6,
354   UInt = 7,
355   Float = 8,
356   BCD = 9,
357   Bool = 10,
358   Long = 13,
359   ULong = 14,
360   Currency = 25,
361   Date = 26,
362   Variant = 27,
363   Complex = 28,
364   Bitfield = 29,
365   BSTR = 30,
366   HResult = 31
367 };
368
369 enum class PDB_RegisterId {
370   Unknown = 0,
371   VFrame = 30006,
372   AL = 1,
373   CL = 2,
374   DL = 3,
375   BL = 4,
376   AH = 5,
377   CH = 6,
378   DH = 7,
379   BH = 8,
380   AX = 9,
381   CX = 10,
382   DX = 11,
383   BX = 12,
384   SP = 13,
385   BP = 14,
386   SI = 15,
387   DI = 16,
388   EAX = 17,
389   ECX = 18,
390   EDX = 19,
391   EBX = 20,
392   ESP = 21,
393   EBP = 22,
394   ESI = 23,
395   EDI = 24,
396   ES = 25,
397   CS = 26,
398   SS = 27,
399   DS = 28,
400   FS = 29,
401   GS = 30,
402   IP = 31,
403   RAX = 328,
404   RBX = 329,
405   RCX = 330,
406   RDX = 331,
407   RSI = 332,
408   RDI = 333,
409   RBP = 334,
410   RSP = 335,
411   R8 = 336,
412   R9 = 337,
413   R10 = 338,
414   R11 = 339,
415   R12 = 340,
416   R13 = 341,
417   R14 = 342,
418   R15 = 343,
419 };
420
421 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
422
423 enum class PDB_ErrorCode {
424   Success,
425   NoPdbImpl,
426   InvalidPath,
427   InvalidFileFormat,
428   InvalidParameter,
429   AlreadyLoaded,
430   UnknownError,
431   NoMemory,
432   DebugInfoMismatch
433 };
434
435 struct VersionInfo {
436   uint32_t Major;
437   uint32_t Minor;
438   uint32_t Build;
439   uint32_t QFE;
440 };
441
442 enum PDB_VariantType {
443   Empty,
444   Unknown,
445   Int8,
446   Int16,
447   Int32,
448   Int64,
449   Single,
450   Double,
451   UInt8,
452   UInt16,
453   UInt32,
454   UInt64,
455   Bool,
456 };
457
458 struct Variant {
459   Variant()
460     : Type(PDB_VariantType::Empty) {
461   }
462
463   PDB_VariantType Type;
464   union {
465     bool Bool;
466     int8_t Int8;
467     int16_t Int16;
468     int32_t Int32;
469     int64_t Int64;
470     float Single;
471     double Double;
472     uint8_t UInt8;
473     uint16_t UInt16;
474     uint32_t UInt32;
475     uint64_t UInt64;
476   };
477 #define VARIANT_EQUAL_CASE(Enum)                                               \
478   case PDB_VariantType::Enum:                                                  \
479     return Enum == Other.Enum;
480   bool operator==(const Variant &Other) const {
481     if (Type != Other.Type)
482       return false;
483     switch (Type) {
484       VARIANT_EQUAL_CASE(Bool)
485       VARIANT_EQUAL_CASE(Int8)
486       VARIANT_EQUAL_CASE(Int16)
487       VARIANT_EQUAL_CASE(Int32)
488       VARIANT_EQUAL_CASE(Int64)
489       VARIANT_EQUAL_CASE(Single)
490       VARIANT_EQUAL_CASE(Double)
491       VARIANT_EQUAL_CASE(UInt8)
492       VARIANT_EQUAL_CASE(UInt16)
493       VARIANT_EQUAL_CASE(UInt32)
494       VARIANT_EQUAL_CASE(UInt64)
495     default:
496       return true;
497     }
498   }
499 #undef VARIANT_EQUAL_CASE
500   bool operator!=(const Variant &Other) const { return !(*this == Other); }
501 };
502
503 } // namespace llvm
504
505 namespace std {
506 template <> struct hash<llvm::PDB_SymType> {
507   typedef llvm::PDB_SymType argument_type;
508   typedef std::size_t result_type;
509
510   result_type operator()(const argument_type &Arg) const {
511     return std::hash<int>()(static_cast<int>(Arg));
512   }
513 };
514 }
515
516 #endif