1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-windows-msvc < %s > %t.obj
3# RUN: lld-link /DEBUG:FULL /nodefaultlib /entry:main %t.obj /PDB:%t.pdb /OUT:%t.exe
4# RUN: llvm-pdbutil dump -types -globals -symbols -modi=0 %t.pdb | FileCheck %s
5
6# CHECK:                               Types (TPI Stream)
7# CHECK-NEXT: ============================================================
8# CHECK:      0x1003 | LF_STRUCTURE [size = 44] `Struct`
9# CHECK-NEXT:          unique name: `.?AUStruct@@`
10# CHECK-NEXT:          vtable: <no type>, base list: <no type>, field list: <no type>
11# CHECK-NEXT:          options: forward ref (-> 0x1006) | has unique name, sizeof 0
12# CHECK-NEXT: 0x1004 | LF_POINTER [size = 12]
13# CHECK-NEXT:          referent = 0x1003, mode = pointer, opts = None, kind = ptr64
14# CHECK:      0x1006 | LF_STRUCTURE [size = 44] `Struct`
15# CHECK-NEXT:          unique name: `.?AUStruct@@`
16# CHECK-NEXT:          vtable: <no type>, base list: <no type>, field list: 0x1005
17# CHECK-NEXT:          options: has unique name, sizeof 4
18# CHECK:                               Global Symbols
19# CHECK-NEXT: ============================================================
20# CHECK:      {{.*}} | S_UDT [size = 24] `StructTypedef`
21# CHECK:               original type = 0x1003
22# CHECK:      {{.*}} | S_UDT [size = 16] `Struct`
23# CHECK:               original type = 0x1006
24# CHECK:      {{.*}} | S_UDT [size = 20] `IntTypedef`
25# CHECK:               original type = 0x0074 (int)
26# CHECK:                               Symbols
27# CHECK-NEXT: ============================================================
28# CHECK:      {{.*}} | S_GPROC32 [size = 44] `main`
29# CHECK-NEXT:          parent = 0, end = 252, addr = 0001:0000, code size = 52
30# CHECK-NEXT:          type = `0x1002 (int (int, char**))`, debug start = 0, debug end = 0, flags = none
31# CHECK-NOT:  {{.*}} | S_END
32# CHECK:      {{.*}} | S_UDT [size = 28] `main::LocalTypedef`
33# CHECK-NEXT:          original type = 0x1004
34# CHECK:      {{.*}} | S_END [size = 4]
35
36# source code to re-generate:
37# clang-cl /Z7 /GS- /GR- /c foo.cpp
38#
39# struct Struct {
40#   int x;
41# };
42#
43# using IntTypedef = int;
44# using StructTypedef = Struct;
45# Struct S;
46# StructTypedef SS;
47# IntTypedef I;
48#
49# int main(int argc, char **argv) {
50#   using LocalTypedef = Struct*;
51#   LocalTypedef SPtr;
52#   return I + S.x + SS.x + SPtr->x;
53# }
54
55	.text
56	.def	 @feat.00;
57	.scl	3;
58	.type	0;
59	.endef
60	.globl	@feat.00
61.set @feat.00, 0
62	.intel_syntax noprefix
63	.def	 main;
64	.scl	2;
65	.type	32;
66	.endef
67	.globl	main                    # -- Begin function main
68	.p2align	4, 0x90
69main:                                   # @main
70.Lfunc_begin0:
71	.cv_func_id 0
72	.cv_file	1 "D:\\src\\llvmbuild\\cl\\Debug\\x64\\foo.cpp" "2B62298EE3EEF94E1D81FDFE18BD46A6" 1
73	.cv_loc	0 1 12 0                # foo.cpp:12:0
74.seh_proc main
75# %bb.0:                                # %entry
76	sub	rsp, 32
77	.seh_stackalloc 32
78	.seh_endprologue
79	mov	dword ptr [rsp + 28], 0
80	mov	qword ptr [rsp + 16], rdx
81	mov	dword ptr [rsp + 12], ecx
82.Ltmp0:
83	.cv_loc	0 1 15 0                # foo.cpp:15:0
84	mov	ecx, dword ptr [rip + "?I@@3HA"]
85	add	ecx, dword ptr [rip + "?S@@3UStruct@@A"]
86	add	ecx, dword ptr [rip + "?SS@@3UStruct@@A"]
87	mov	rdx, qword ptr [rsp]
88	add	ecx, dword ptr [rdx]
89	mov	eax, ecx
90	add	rsp, 32
91	ret
92.Ltmp1:
93.Lfunc_end0:
94	.seh_handlerdata
95	.text
96	.seh_endproc
97                                        # -- End function
98	.bss
99	.globl	"?S@@3UStruct@@A"       # @"?S@@3UStruct@@A"
100	.p2align	2
101"?S@@3UStruct@@A":
102	.zero	4
103
104	.globl	"?SS@@3UStruct@@A"      # @"?SS@@3UStruct@@A"
105	.p2align	2
106"?SS@@3UStruct@@A":
107	.zero	4
108
109	.globl	"?I@@3HA"               # @"?I@@3HA"
110	.p2align	2
111"?I@@3HA":
112	.long	0                       # 0x0
113
114	.section	.drectve,"yn"
115	.ascii	" /DEFAULTLIB:libcmt.lib"
116	.ascii	" /DEFAULTLIB:oldnames.lib"
117	.section	.debug$S,"dr"
118	.p2align	2
119	.long	4                       # Debug section magic
120	.long	241
121	.long	.Ltmp3-.Ltmp2           # Subsection size
122.Ltmp2:
123	.short	.Ltmp5-.Ltmp4           # Record length
124.Ltmp4:
125	.short	4412                    # Record kind: S_COMPILE3
126	.long	1                       # Flags and language
127	.short	208                     # CPUType
128	.short	8                       # Frontend version
129	.short	0
130	.short	0
131	.short	0
132	.short	8000                    # Backend version
133	.short	0
134	.short	0
135	.short	0
136	.asciz	"clang version 8.0.0 "  # Null-terminated compiler version string
137.Ltmp5:
138.Ltmp3:
139	.p2align	2
140	.long	241                     # Symbol subsection for main
141	.long	.Ltmp7-.Ltmp6           # Subsection size
142.Ltmp6:
143	.short	.Ltmp9-.Ltmp8           # Record length
144.Ltmp8:
145	.short	4423                    # Record kind: S_GPROC32_ID
146	.long	0                       # PtrParent
147	.long	0                       # PtrEnd
148	.long	0                       # PtrNext
149	.long	.Lfunc_end0-main        # Code size
150	.long	0                       # Offset after prologue
151	.long	0                       # Offset before epilogue
152	.long	4099                    # Function type index
153	.secrel32	main            # Function section relative address
154	.secidx	main                    # Function section index
155	.byte	0                       # Flags
156	.asciz	"main"                  # Function name
157.Ltmp9:
158	.short	.Ltmp11-.Ltmp10         # Record length
159.Ltmp10:
160	.short	4114                    # Record kind: S_FRAMEPROC
161	.long	32                      # FrameSize
162	.long	0                       # Padding
163	.long	0                       # Offset of padding
164	.long	0                       # Bytes of callee saved registers
165	.long	0                       # Exception handler offset
166	.short	0                       # Exception handler section
167	.long	81920                   # Flags (defines frame register)
168.Ltmp11:
169	.short	.Ltmp13-.Ltmp12         # Record length
170.Ltmp12:
171	.short	4414                    # Record kind: S_LOCAL
172	.long	116                     # TypeIndex
173	.short	1                       # Flags
174	.asciz	"argc"
175.Ltmp13:
176	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 12
177	.short	.Ltmp15-.Ltmp14         # Record length
178.Ltmp14:
179	.short	4414                    # Record kind: S_LOCAL
180	.long	4096                    # TypeIndex
181	.short	1                       # Flags
182	.asciz	"argv"
183.Ltmp15:
184	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 16
185	.short	.Ltmp17-.Ltmp16         # Record length
186.Ltmp16:
187	.short	4414                    # Record kind: S_LOCAL
188	.long	4101                    # TypeIndex
189	.short	0                       # Flags
190	.asciz	"SPtr"
191.Ltmp17:
192	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 0
193	.short	.Ltmp19-.Ltmp18         # Record length
194.Ltmp18:
195	.short	4360                    # Record kind: S_UDT
196	.long	4101                    # Type
197	.asciz	"main::LocalTypedef"
198.Ltmp19:
199	.short	2                       # Record length
200	.short	4431                    # Record kind: S_PROC_ID_END
201.Ltmp7:
202	.p2align	2
203	.cv_linetable	0, main, .Lfunc_end0
204	.long	241                     # Symbol subsection for globals
205	.long	.Ltmp21-.Ltmp20         # Subsection size
206.Ltmp20:
207	.short	.Ltmp23-.Ltmp22         # Record length
208.Ltmp22:
209	.short	4365                    # Record kind: S_GDATA32
210	.long	4103                    # Type
211	.secrel32	"?S@@3UStruct@@A" # DataOffset
212	.secidx	"?S@@3UStruct@@A"       # Segment
213	.asciz	"S"                     # Name
214.Ltmp23:
215	.short	.Ltmp25-.Ltmp24         # Record length
216.Ltmp24:
217	.short	4365                    # Record kind: S_GDATA32
218	.long	4100                    # Type
219	.secrel32	"?SS@@3UStruct@@A" # DataOffset
220	.secidx	"?SS@@3UStruct@@A"      # Segment
221	.asciz	"SS"                    # Name
222.Ltmp25:
223	.short	.Ltmp27-.Ltmp26         # Record length
224.Ltmp26:
225	.short	4365                    # Record kind: S_GDATA32
226	.long	116                     # Type
227	.secrel32	"?I@@3HA"       # DataOffset
228	.secidx	"?I@@3HA"               # Segment
229	.asciz	"I"                     # Name
230.Ltmp27:
231.Ltmp21:
232	.p2align	2
233	.long	241
234	.long	.Ltmp29-.Ltmp28         # Subsection size
235.Ltmp28:
236	.short	.Ltmp31-.Ltmp30         # Record length
237.Ltmp30:
238	.short	4360                    # Record kind: S_UDT
239	.long	4103                    # Type
240	.asciz	"Struct"
241.Ltmp31:
242	.short	.Ltmp33-.Ltmp32         # Record length
243.Ltmp32:
244	.short	4360                    # Record kind: S_UDT
245	.long	4100                    # Type
246	.asciz	"StructTypedef"
247.Ltmp33:
248	.short	.Ltmp35-.Ltmp34         # Record length
249.Ltmp34:
250	.short	4360                    # Record kind: S_UDT
251	.long	116                     # Type
252	.asciz	"IntTypedef"
253.Ltmp35:
254.Ltmp29:
255	.p2align	2
256	.cv_filechecksums               # File index to string table offset subsection
257	.cv_stringtable                 # String table
258	.long	241
259	.long	.Ltmp37-.Ltmp36         # Subsection size
260.Ltmp36:
261	.short	6                       # Record length
262	.short	4428                    # Record kind: S_BUILDINFO
263	.long	4108                    # LF_BUILDINFO index
264.Ltmp37:
265	.p2align	2
266	.section	.debug$T,"dr"
267	.p2align	2
268	.long	4                       # Debug section magic
269	# Pointer (0x1000) {
270	#   TypeLeafKind: LF_POINTER (0x1002)
271	#   PointeeType: char* (0x670)
272	#   PtrType: Near64 (0xC)
273	#   PtrMode: Pointer (0x0)
274	#   IsFlat: 0
275	#   IsConst: 0
276	#   IsVolatile: 0
277	#   IsUnaligned: 0
278	#   IsRestrict: 0
279	#   IsThisPtr&: 0
280	#   IsThisPtr&&: 0
281	#   SizeOf: 8
282	# }
283	.byte	0x0a, 0x00, 0x02, 0x10
284	.byte	0x70, 0x06, 0x00, 0x00
285	.byte	0x0c, 0x00, 0x01, 0x00
286	# ArgList (0x1001) {
287	#   TypeLeafKind: LF_ARGLIST (0x1201)
288	#   NumArgs: 2
289	#   Arguments [
290	#     ArgType: int (0x74)
291	#     ArgType: char** (0x1000)
292	#   ]
293	# }
294	.byte	0x0e, 0x00, 0x01, 0x12
295	.byte	0x02, 0x00, 0x00, 0x00
296	.byte	0x74, 0x00, 0x00, 0x00
297	.byte	0x00, 0x10, 0x00, 0x00
298	# Procedure (0x1002) {
299	#   TypeLeafKind: LF_PROCEDURE (0x1008)
300	#   ReturnType: int (0x74)
301	#   CallingConvention: NearC (0x0)
302	#   FunctionOptions [ (0x0)
303	#   ]
304	#   NumParameters: 2
305	#   ArgListType: (int, char**) (0x1001)
306	# }
307	.byte	0x0e, 0x00, 0x08, 0x10
308	.byte	0x74, 0x00, 0x00, 0x00
309	.byte	0x00, 0x00, 0x02, 0x00
310	.byte	0x01, 0x10, 0x00, 0x00
311	# FuncId (0x1003) {
312	#   TypeLeafKind: LF_FUNC_ID (0x1601)
313	#   ParentScope: 0x0
314	#   FunctionType: int (int, char**) (0x1002)
315	#   Name: main
316	# }
317	.byte	0x12, 0x00, 0x01, 0x16
318	.byte	0x00, 0x00, 0x00, 0x00
319	.byte	0x02, 0x10, 0x00, 0x00
320	.byte	0x6d, 0x61, 0x69, 0x6e
321	.byte	0x00, 0xf3, 0xf2, 0xf1
322	# Struct (0x1004) {
323	#   TypeLeafKind: LF_STRUCTURE (0x1505)
324	#   MemberCount: 0
325	#   Properties [ (0x280)
326	#     ForwardReference (0x80)
327	#     HasUniqueName (0x200)
328	#   ]
329	#   FieldList: 0x0
330	#   DerivedFrom: 0x0
331	#   VShape: 0x0
332	#   SizeOf: 0
333	#   Name: Struct
334	#   LinkageName: .?AUStruct@@
335	# }
336	.byte	0x2a, 0x00, 0x05, 0x15
337	.byte	0x00, 0x00, 0x80, 0x02
338	.byte	0x00, 0x00, 0x00, 0x00
339	.byte	0x00, 0x00, 0x00, 0x00
340	.byte	0x00, 0x00, 0x00, 0x00
341	.byte	0x00, 0x00, 0x53, 0x74
342	.byte	0x72, 0x75, 0x63, 0x74
343	.byte	0x00, 0x2e, 0x3f, 0x41
344	.byte	0x55, 0x53, 0x74, 0x72
345	.byte	0x75, 0x63, 0x74, 0x40
346	.byte	0x40, 0x00, 0xf2, 0xf1
347	# Pointer (0x1005) {
348	#   TypeLeafKind: LF_POINTER (0x1002)
349	#   PointeeType: Struct (0x1004)
350	#   PtrType: Near64 (0xC)
351	#   PtrMode: Pointer (0x0)
352	#   IsFlat: 0
353	#   IsConst: 0
354	#   IsVolatile: 0
355	#   IsUnaligned: 0
356	#   IsRestrict: 0
357	#   IsThisPtr&: 0
358	#   IsThisPtr&&: 0
359	#   SizeOf: 8
360	# }
361	.byte	0x0a, 0x00, 0x02, 0x10
362	.byte	0x04, 0x10, 0x00, 0x00
363	.byte	0x0c, 0x00, 0x01, 0x00
364	# FieldList (0x1006) {
365	#   TypeLeafKind: LF_FIELDLIST (0x1203)
366	#   DataMember {
367	#     TypeLeafKind: LF_MEMBER (0x150D)
368	#     AccessSpecifier: Public (0x3)
369	#     Type: int (0x74)
370	#     FieldOffset: 0x0
371	#     Name: x
372	#   }
373	# }
374	.byte	0x0e, 0x00, 0x03, 0x12
375	.byte	0x0d, 0x15, 0x03, 0x00
376	.byte	0x74, 0x00, 0x00, 0x00
377	.byte	0x00, 0x00, 0x78, 0x00
378	# Struct (0x1007) {
379	#   TypeLeafKind: LF_STRUCTURE (0x1505)
380	#   MemberCount: 1
381	#   Properties [ (0x200)
382	#     HasUniqueName (0x200)
383	#   ]
384	#   FieldList: <field list> (0x1006)
385	#   DerivedFrom: 0x0
386	#   VShape: 0x0
387	#   SizeOf: 4
388	#   Name: Struct
389	#   LinkageName: .?AUStruct@@
390	# }
391	.byte	0x2a, 0x00, 0x05, 0x15
392	.byte	0x01, 0x00, 0x00, 0x02
393	.byte	0x06, 0x10, 0x00, 0x00
394	.byte	0x00, 0x00, 0x00, 0x00
395	.byte	0x00, 0x00, 0x00, 0x00
396	.byte	0x04, 0x00, 0x53, 0x74
397	.byte	0x72, 0x75, 0x63, 0x74
398	.byte	0x00, 0x2e, 0x3f, 0x41
399	.byte	0x55, 0x53, 0x74, 0x72
400	.byte	0x75, 0x63, 0x74, 0x40
401	.byte	0x40, 0x00, 0xf2, 0xf1
402	# StringId (0x1008) {
403	#   TypeLeafKind: LF_STRING_ID (0x1605)
404	#   Id: 0x0
405	#   StringData: D:\src\llvmbuild\cl\Debug\x64\foo.cpp
406	# }
407	.byte	0x2e, 0x00, 0x05, 0x16
408	.byte	0x00, 0x00, 0x00, 0x00
409	.byte	0x44, 0x3a, 0x5c, 0x73
410	.byte	0x72, 0x63, 0x5c, 0x6c
411	.byte	0x6c, 0x76, 0x6d, 0x62
412	.byte	0x75, 0x69, 0x6c, 0x64
413	.byte	0x5c, 0x63, 0x6c, 0x5c
414	.byte	0x44, 0x65, 0x62, 0x75
415	.byte	0x67, 0x5c, 0x78, 0x36
416	.byte	0x34, 0x5c, 0x66, 0x6f
417	.byte	0x6f, 0x2e, 0x63, 0x70
418	.byte	0x70, 0x00, 0xf2, 0xf1
419	# UdtSourceLine (0x1009) {
420	#   TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
421	#   UDT: Struct (0x1007)
422	#   SourceFile: D:\src\llvmbuild\cl\Debug\x64\foo.cpp (0x1008)
423	#   LineNumber: 1
424	# }
425	.byte	0x0e, 0x00, 0x06, 0x16
426	.byte	0x07, 0x10, 0x00, 0x00
427	.byte	0x08, 0x10, 0x00, 0x00
428	.byte	0x01, 0x00, 0x00, 0x00
429	# StringId (0x100A) {
430	#   TypeLeafKind: LF_STRING_ID (0x1605)
431	#   Id: 0x0
432	#   StringData: D:\\src\\llvmbuild\\cl\\Debug\\x64
433	# }
434	.byte	0x2a, 0x00, 0x05, 0x16
435	.byte	0x00, 0x00, 0x00, 0x00
436	.byte	0x44, 0x3a, 0x5c, 0x5c
437	.byte	0x73, 0x72, 0x63, 0x5c
438	.byte	0x5c, 0x6c, 0x6c, 0x76
439	.byte	0x6d, 0x62, 0x75, 0x69
440	.byte	0x6c, 0x64, 0x5c, 0x5c
441	.byte	0x63, 0x6c, 0x5c, 0x5c
442	.byte	0x44, 0x65, 0x62, 0x75
443	.byte	0x67, 0x5c, 0x5c, 0x78
444	.byte	0x36, 0x34, 0x00, 0xf1
445	# StringId (0x100B) {
446	#   TypeLeafKind: LF_STRING_ID (0x1605)
447	#   Id: 0x0
448	#   StringData: foo.cpp
449	# }
450	.byte	0x0e, 0x00, 0x05, 0x16
451	.byte	0x00, 0x00, 0x00, 0x00
452	.byte	0x66, 0x6f, 0x6f, 0x2e
453	.byte	0x63, 0x70, 0x70, 0x00
454	# BuildInfo (0x100C) {
455	#   TypeLeafKind: LF_BUILDINFO (0x1603)
456	#   NumArgs: 5
457	#   Arguments [
458	#     ArgType: D:\\src\\llvmbuild\\cl\\Debug\\x64 (0x100A)
459	#     ArgType: 0x0
460	#     ArgType: foo.cpp (0x100B)
461	#     ArgType: 0x0
462	#     ArgType: 0x0
463	#   ]
464	# }
465	.byte	0x1a, 0x00, 0x03, 0x16
466	.byte	0x05, 0x00, 0x0a, 0x10
467	.byte	0x00, 0x00, 0x00, 0x00
468	.byte	0x00, 0x00, 0x0b, 0x10
469	.byte	0x00, 0x00, 0x00, 0x00
470	.byte	0x00, 0x00, 0x00, 0x00
471	.byte	0x00, 0x00, 0xf2, 0xf1
472
473	.addrsig
474	.addrsig_sym "?S@@3UStruct@@A"
475	.addrsig_sym "?SS@@3UStruct@@A"
476	.addrsig_sym "?I@@3HA"
477