1The test input (every-type.pdb) is generated from some short and trivial C++ code
2that exercises the entire type system to generate every possible type record that
3we claim to understand.  We then test this in two ways:
4  1) We just dump the output for the purposes of readability.  This tests that we
5     we can dump every possible type record.
6  2) We dump the output to yaml, and then re-generate a PDB with the same type
7     stream, and then run test 1 on the new PDB.  This verifies that the PDB
8     hasn't changed.
9
10
11RUN: llvm-pdbutil dump -type-index=0x101A,0x102C,0x103D,0x104D,0x1098,0x10AA,0x10AC \
12RUN:   -dont-resolve-forward-refs -dependents %p/Inputs/every-type.pdb \
13RUN:   | FileCheck --check-prefix=TYPES %s
14
15RUN: llvm-pdbutil pdb2yaml -tpi-stream -ipi-stream %p/Inputs/every-type.pdb > %t.pdb.yaml
16RUN: llvm-pdbutil yaml2pdb -pdb=%t.yaml.pdb %t.pdb.yaml
17RUN: llvm-pdbutil dump -type-index=0x101A,0x102C,0x103D,0x104D,0x1098,0x10AA,0x10AC \
18RUN:   -dependents -dont-resolve-forward-refs %t.yaml.pdb \
19RUN:   | FileCheck --check-prefix=TYPES %s
20
21TYPES:                           Types (TPI Stream)
22TYPES-NEXT: ============================================================
23TYPES-NEXT:   Showing 7 records and their dependents (72 records total)
24TYPES-NEXT:   0x1007 | LF_MODIFIER [size = 12]
25TYPES-NEXT:            referent = 0x0074 (int), modifiers = const
26TYPES-NEXT:   0x1008 | LF_CLASS [size = 48] `FooClass`
27TYPES-NEXT:            unique name: `.?AVFooClass@@`
28TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: <no type>
29TYPES-NEXT:            options: forward ref | has unique name, sizeof 0
30TYPES-NEXT:   0x1009 | LF_VTSHAPE [size = 8]
31TYPES-NEXT:   0x100A | LF_POINTER [size = 12]
32TYPES-NEXT:            referent = 0x1009, mode = pointer, opts = None, kind = ptr64
33TYPES-NEXT:   0x100B | LF_CLASS [size = 44] `Inherit`
34TYPES-NEXT:            unique name: `.?AVInherit@@`
35TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: <no type>
36TYPES-NEXT:            options: forward ref | has unique name, sizeof 0
37TYPES-NEXT:   0x100C | LF_POINTER [size = 12]
38TYPES-NEXT:            referent = 0x100B, mode = pointer, opts = const, kind = ptr64
39TYPES-NEXT:   0x100D | LF_ARGLIST [size = 8]
40TYPES-NEXT:   0x100E | LF_MFUNCTION [size = 28]
41TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
42TYPES-NEXT:            class type = 0x100B, this type = 0x100C, this adjust = 0
43TYPES-NEXT:            calling conv = cdecl, options = None
44TYPES-NEXT:   0x100F | LF_MODIFIER [size = 12]
45TYPES-NEXT:            referent = 0x100B, modifiers = const
46TYPES-NEXT:   0x1010 | LF_POINTER [size = 12]
47TYPES-NEXT:            referent = 0x100F, mode = ref, opts = None, kind = ptr64
48TYPES-NEXT:   0x1011 | LF_ARGLIST [size = 12]
49TYPES-NEXT:            0x1010: `const Inherit&`
50TYPES-NEXT:   0x1012 | LF_MFUNCTION [size = 28]
51TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x1011
52TYPES-NEXT:            class type = 0x100B, this type = 0x100C, this adjust = 0
53TYPES-NEXT:            calling conv = cdecl, options = constructor
54TYPES-NEXT:   0x1013 | LF_MFUNCTION [size = 28]
55TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
56TYPES-NEXT:            class type = 0x100B, this type = 0x100C, this adjust = 0
57TYPES-NEXT:            calling conv = cdecl, options = constructor
58TYPES-NEXT:   0x1014 | LF_METHODLIST [size = 20]
59TYPES-NEXT:            - Method [type = 0x1012, vftable offset = -1, attrs = public compiler-generated]
60TYPES-NEXT:            - Method [type = 0x1013, vftable offset = -1, attrs = public compiler-generated]
61TYPES-NEXT:   0x1015 | LF_POINTER [size = 12]
62TYPES-NEXT:            referent = 0x100B, mode = ref, opts = None, kind = ptr64
63TYPES-NEXT:   0x1016 | LF_MFUNCTION [size = 28]
64TYPES-NEXT:            return type = 0x1015, # args = 1, param list = 0x1011
65TYPES-NEXT:            class type = 0x100B, this type = 0x100C, this adjust = 0
66TYPES-NEXT:            calling conv = cdecl, options = None
67TYPES-NEXT:   0x1017 | LF_ARGLIST [size = 12]
68TYPES-NEXT:            0x0075 (unsigned): `unsigned`
69TYPES-NEXT:   0x1018 | LF_MFUNCTION [size = 28]
70TYPES-NEXT:            return type = 0x0603 (void*), # args = 1, param list = 0x1017
71TYPES-NEXT:            class type = 0x100B, this type = 0x100C, this adjust = 0
72TYPES-NEXT:            calling conv = cdecl, options = None
73TYPES-NEXT:   0x1019 | LF_FIELDLIST [size = 152]
74TYPES-NEXT:            - LF_BCLASS
75TYPES-NEXT:              type = 0x1008, offset = 8, attrs = public
76TYPES-NEXT:            - LF_VFUNCTAB type = 0x100A
77TYPES-NEXT:            - LF_ONEMETHOD [name = `~Inherit`]
78TYPES-NEXT:              type = 0x100E, vftable offset = 0, attrs = public intro virtual
79TYPES-NEXT:            - LF_METHOD [name = `Inherit`, # overloads = 2, overload list = 0x1014]
80TYPES-NEXT:            - LF_ONEMETHOD [name = `operator=`]
81TYPES-NEXT:              type = 0x1016, vftable offset = -1, attrs = public compiler-generated
82TYPES-NEXT:            - LF_ONEMETHOD [name = `__local_vftable_ctor_closure`]
83TYPES-NEXT:              type = 0x100E, vftable offset = -1, attrs = public compiler-generated
84TYPES-NEXT:            - LF_ONEMETHOD [name = `__vecDelDtor`]
85TYPES-NEXT:              type = 0x1018, vftable offset = 0, attrs = public intro virtual compiler-generated
86TYPES-NEXT:   0x101A | LF_CLASS [size = 44] `Inherit`
87TYPES-NEXT:            unique name: `.?AVInherit@@`
88TYPES-NEXT:            vtable: 0x1009, base list: <no type>, field list: 0x1019
89TYPES-NEXT:            options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 16
90TYPES-NEXT:   0x101B | LF_POINTER [size = 12]
91TYPES-NEXT:            referent = 0x1007, mode = pointer, opts = None, kind = ptr64
92TYPES-NEXT:   0x101C | LF_CLASS [size = 48] `VInherit`
93TYPES-NEXT:            unique name: `.?AVVInherit@@`
94TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: <no type>
95TYPES-NEXT:            options: forward ref | has unique name, sizeof 0
96TYPES-NEXT:   0x101D | LF_POINTER [size = 12]
97TYPES-NEXT:            referent = 0x101C, mode = pointer, opts = const, kind = ptr64
98TYPES-NEXT:   0x101E | LF_POINTER [size = 12]
99TYPES-NEXT:            referent = 0x101C, mode = rvalue ref, opts = None, kind = ptr64
100TYPES-NEXT:   0x101F | LF_ARGLIST [size = 12]
101TYPES-NEXT:            0x101E: `VInherit&&`
102TYPES-NEXT:   0x1020 | LF_MFUNCTION [size = 28]
103TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x101F
104TYPES-NEXT:            class type = 0x101C, this type = 0x101D, this adjust = 0
105TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
106TYPES-NEXT:   0x1021 | LF_MODIFIER [size = 12]
107TYPES-NEXT:            referent = 0x101C, modifiers = const
108TYPES-NEXT:   0x1022 | LF_POINTER [size = 12]
109TYPES-NEXT:            referent = 0x1021, mode = ref, opts = None, kind = ptr64
110TYPES-NEXT:   0x1023 | LF_ARGLIST [size = 12]
111TYPES-NEXT:            0x1022: `const VInherit&`
112TYPES-NEXT:   0x1024 | LF_MFUNCTION [size = 28]
113TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x1023
114TYPES-NEXT:            class type = 0x101C, this type = 0x101D, this adjust = 0
115TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
116TYPES-NEXT:   0x1025 | LF_MFUNCTION [size = 28]
117TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
118TYPES-NEXT:            class type = 0x101C, this type = 0x101D, this adjust = 0
119TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
120TYPES-NEXT:   0x1026 | LF_METHODLIST [size = 28]
121TYPES-NEXT:            - Method [type = 0x1020, vftable offset = -1, attrs = public compiler-generated]
122TYPES-NEXT:            - Method [type = 0x1024, vftable offset = -1, attrs = public compiler-generated]
123TYPES-NEXT:            - Method [type = 0x1025, vftable offset = -1, attrs = public compiler-generated]
124TYPES-NEXT:   0x1027 | LF_POINTER [size = 12]
125TYPES-NEXT:            referent = 0x101C, mode = ref, opts = None, kind = ptr64
126TYPES-NEXT:   0x1028 | LF_MFUNCTION [size = 28]
127TYPES-NEXT:            return type = 0x1027, # args = 1, param list = 0x101F
128TYPES-NEXT:            class type = 0x101C, this type = 0x101D, this adjust = 0
129TYPES-NEXT:            calling conv = cdecl, options = None
130TYPES-NEXT:   0x1029 | LF_MFUNCTION [size = 28]
131TYPES-NEXT:            return type = 0x1027, # args = 1, param list = 0x1023
132TYPES-NEXT:            class type = 0x101C, this type = 0x101D, this adjust = 0
133TYPES-NEXT:            calling conv = cdecl, options = None
134TYPES-NEXT:   0x102A | LF_METHODLIST [size = 20]
135TYPES-NEXT:            - Method [type = 0x1028, vftable offset = -1, attrs = public compiler-generated]
136TYPES-NEXT:            - Method [type = 0x1029, vftable offset = -1, attrs = public compiler-generated]
137TYPES-NEXT:   0x102B | LF_FIELDLIST [size = 60]
138TYPES-NEXT:            - LF_VBCLASS
139TYPES-NEXT:              base = 0x1008, vbptr = 0x101B, vbptr offset = 0, vtable index = 1
140TYPES-NEXT:              attrs = public
141TYPES-NEXT:            - LF_METHOD [name = `VInherit`, # overloads = 3, overload list = 0x1026]
142TYPES-NEXT:            - LF_METHOD [name = `operator=`, # overloads = 2, overload list = 0x102A]
143TYPES-NEXT:   0x102C | LF_CLASS [size = 48] `VInherit`
144TYPES-NEXT:            unique name: `.?AVVInherit@@`
145TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: 0x102B
146TYPES-NEXT:            options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 16
147TYPES-NEXT:   0x102D | LF_CLASS [size = 48] `IVInherit`
148TYPES-NEXT:            unique name: `.?AVIVInherit@@`
149TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: <no type>
150TYPES-NEXT:            options: forward ref | has unique name, sizeof 0
151TYPES-NEXT:   0x102E | LF_POINTER [size = 12]
152TYPES-NEXT:            referent = 0x102D, mode = pointer, opts = const, kind = ptr64
153TYPES-NEXT:   0x102F | LF_POINTER [size = 12]
154TYPES-NEXT:            referent = 0x102D, mode = rvalue ref, opts = None, kind = ptr64
155TYPES-NEXT:   0x1030 | LF_ARGLIST [size = 12]
156TYPES-NEXT:            0x102F: `IVInherit&&`
157TYPES-NEXT:   0x1031 | LF_MFUNCTION [size = 28]
158TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x1030
159TYPES-NEXT:            class type = 0x102D, this type = 0x102E, this adjust = 0
160TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
161TYPES-NEXT:   0x1032 | LF_MODIFIER [size = 12]
162TYPES-NEXT:            referent = 0x102D, modifiers = const
163TYPES-NEXT:   0x1033 | LF_POINTER [size = 12]
164TYPES-NEXT:            referent = 0x1032, mode = ref, opts = None, kind = ptr64
165TYPES-NEXT:   0x1034 | LF_ARGLIST [size = 12]
166TYPES-NEXT:            0x1033: `const IVInherit&`
167TYPES-NEXT:   0x1035 | LF_MFUNCTION [size = 28]
168TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x1034
169TYPES-NEXT:            class type = 0x102D, this type = 0x102E, this adjust = 0
170TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
171TYPES-NEXT:   0x1036 | LF_MFUNCTION [size = 28]
172TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
173TYPES-NEXT:            class type = 0x102D, this type = 0x102E, this adjust = 0
174TYPES-NEXT:            calling conv = cdecl, options = constructor with virtual bases | constructor
175TYPES-NEXT:   0x1037 | LF_METHODLIST [size = 28]
176TYPES-NEXT:            - Method [type = 0x1031, vftable offset = -1, attrs = public compiler-generated]
177TYPES-NEXT:            - Method [type = 0x1035, vftable offset = -1, attrs = public compiler-generated]
178TYPES-NEXT:            - Method [type = 0x1036, vftable offset = -1, attrs = public compiler-generated]
179TYPES-NEXT:   0x1038 | LF_POINTER [size = 12]
180TYPES-NEXT:            referent = 0x102D, mode = ref, opts = None, kind = ptr64
181TYPES-NEXT:   0x1039 | LF_MFUNCTION [size = 28]
182TYPES-NEXT:            return type = 0x1038, # args = 1, param list = 0x1030
183TYPES-NEXT:            class type = 0x102D, this type = 0x102E, this adjust = 0
184TYPES-NEXT:            calling conv = cdecl, options = None
185TYPES-NEXT:   0x103A | LF_MFUNCTION [size = 28]
186TYPES-NEXT:            return type = 0x1038, # args = 1, param list = 0x1034
187TYPES-NEXT:            class type = 0x102D, this type = 0x102E, this adjust = 0
188TYPES-NEXT:            calling conv = cdecl, options = None
189TYPES-NEXT:   0x103B | LF_METHODLIST [size = 20]
190TYPES-NEXT:            - Method [type = 0x1039, vftable offset = -1, attrs = public compiler-generated]
191TYPES-NEXT:            - Method [type = 0x103A, vftable offset = -1, attrs = public compiler-generated]
192TYPES-NEXT:   0x103C | LF_FIELDLIST [size = 72]
193TYPES-NEXT:            - LF_BCLASS
194TYPES-NEXT:              type = 0x101C, offset = 0, attrs = public
195TYPES-NEXT:            - LF_IVBCLASS
196TYPES-NEXT:              base = 0x1008, vbptr = 0x101B, vbptr offset = 0, vtable index = 1
197TYPES-NEXT:              attrs = public
198TYPES-NEXT:            - LF_METHOD [name = `IVInherit`, # overloads = 3, overload list = 0x1037]
199TYPES-NEXT:            - LF_METHOD [name = `operator=`, # overloads = 2, overload list = 0x103B]
200TYPES-NEXT:   0x103D | LF_CLASS [size = 48] `IVInherit`
201TYPES-NEXT:            unique name: `.?AVIVInherit@@`
202TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: 0x103C
203TYPES-NEXT:            options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 16
204TYPES-NEXT:   0x1041 | LF_FIELDLIST [size = 28]
205TYPES-NEXT:            - LF_ENUMERATE [A = 0]
206TYPES-NEXT:            - LF_ENUMERATE [B = 1]
207TYPES-NEXT:            - LF_ENUMERATE [C = 2]
208TYPES-NEXT:   0x1042 | LF_ENUM [size = 64] `FooClass::NestedEnum`
209TYPES-NEXT:            unique name: `.?AW4NestedEnum@FooClass@@`
210TYPES-NEXT:            field list: 0x1041, underlying type: 0x0074 (int)
211TYPES-NEXT:            options: has unique name | is nested
212TYPES-NEXT:   0x1043 | LF_POINTER [size = 12]
213TYPES-NEXT:            referent = 0x1008, mode = pointer, opts = const, kind = ptr64
214TYPES-NEXT:   0x1044 | LF_MFUNCTION [size = 28]
215TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
216TYPES-NEXT:            class type = 0x1008, this type = 0x1043, this adjust = 0
217TYPES-NEXT:            calling conv = cdecl, options = None
218TYPES-NEXT:   0x1045 | LF_ARGLIST [size = 16]
219TYPES-NEXT:            0x0074 (int): `int`
220TYPES-NEXT:            0x0074 (int): `int`
221TYPES-NEXT:   0x1046 | LF_MFUNCTION [size = 28]
222TYPES-NEXT:            return type = 0x0003 (void), # args = 2, param list = 0x1045
223TYPES-NEXT:            class type = 0x1008, this type = 0x1043, this adjust = 0
224TYPES-NEXT:            calling conv = cdecl, options = None
225TYPES-NEXT:   0x1047 | LF_ARGLIST [size = 12]
226TYPES-NEXT:            0x0074 (int): `int`
227TYPES-NEXT:   0x1048 | LF_MFUNCTION [size = 28]
228TYPES-NEXT:            return type = 0x0003 (void), # args = 1, param list = 0x1047
229TYPES-NEXT:            class type = 0x1008, this type = 0x1043, this adjust = 0
230TYPES-NEXT:            calling conv = cdecl, options = None
231TYPES-NEXT:   0x1049 | LF_METHODLIST [size = 20]
232TYPES-NEXT:            - Method [type = 0x1046, vftable offset = -1, attrs = public]
233TYPES-NEXT:            - Method [type = 0x1048, vftable offset = -1, attrs = public]
234TYPES-NEXT:   0x104A | LF_BITFIELD [size = 12]
235TYPES-NEXT:            type = 0x0074 (int), bit offset = 0, # bits = 4
236TYPES-NEXT:   0x104B | LF_BITFIELD [size = 12]
237TYPES-NEXT:            type = 0x0074 (int), bit offset = 4, # bits = 4
238TYPES-NEXT:   0x104C | LF_FIELDLIST [size = 164]
239TYPES-NEXT:            - LF_NESTTYPE [name = `NestedEnum`, parent = 0x1042]
240TYPES-NEXT:            - LF_ONEMETHOD [name = `RegularMethod`]
241TYPES-NEXT:              type = 0x1044, vftable offset = -1, attrs = public
242TYPES-NEXT:            - LF_METHOD [name = `OverloadedMethod`, # overloads = 2, overload list = 0x1049]
243TYPES-NEXT:            - LF_MEMBER [name = `HiNibble`, Type = 0x104A, offset = 0, attrs = public]
244TYPES-NEXT:            - LF_MEMBER [name = `LoNibble`, Type = 0x104B, offset = 0, attrs = public]
245TYPES-NEXT:            - LF_MEMBER [name = `EnumVariable`, Type = 0x1042, offset = 4, attrs = public]
246TYPES-NEXT:            - LF_STMEMBER [name = `StaticMember`, type = 0x0603 (void*), attrs = public]
247TYPES-NEXT:   0x104D | LF_CLASS [size = 48] `FooClass`
248TYPES-NEXT:            unique name: `.?AVFooClass@@`
249TYPES-NEXT:            vtable: <no type>, base list: <no type>, field list: 0x104C
250TYPES-NEXT:            options: contains nested class | has unique name, sizeof 8
251TYPES-NEXT:   0x1098 | LF_UNION [size = 40] `TheUnion`
252TYPES-NEXT:            unique name: `.?ATTheUnion@@`
253TYPES-NEXT:            field list: <no type>
254TYPES-NEXT:            options: forward ref | has unique name, sizeof 0
255TYPES-NEXT:   0x10AA | LF_PROCEDURE [size = 16]
256TYPES-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100D
257TYPES-NEXT:            calling conv = cdecl, options = None
258TYPES-NEXT:   0x10AB | LF_POINTER [size = 12]
259TYPES-NEXT:            referent = 0x10AA, mode = pointer, opts = const, kind = ptr64
260TYPES-NEXT:   0x10AC | LF_ARRAY [size = 16]
261TYPES-NEXT:            size: 8, index type: 0x0023 (unsigned __int64), element type: 0x10AB
262