--- /dev/null
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-windows-msvc < %s > %t.obj
+# RUN: lld-link /DEBUG:FULL /nodefaultlib /entry:main %t.obj /PDB:%t.pdb /OUT:%t.exe
+# RUN: llvm-pdbutil dump -types -globals -symbols -modi=0 %t.pdb | FileCheck %s
+
+# CHECK: Types (TPI Stream)
+# CHECK-NEXT: ============================================================
+# CHECK: 0x1003 | LF_STRUCTURE [size = 44] `Struct`
+# CHECK-NEXT: unique name: `.?AUStruct@@`
+# CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: <no type>
+# CHECK-NEXT: options: forward ref (-> 0x1006) | has unique name, sizeof 0
+# CHECK-NEXT: 0x1004 | LF_POINTER [size = 12]
+# CHECK-NEXT: referent = 0x1003, mode = pointer, opts = None, kind = ptr64
+# CHECK: 0x1006 | LF_STRUCTURE [size = 44] `Struct`
+# CHECK-NEXT: unique name: `.?AUStruct@@`
+# CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: 0x1005
+# CHECK-NEXT: options: has unique name, sizeof 4
+# CHECK: Global Symbols
+# CHECK-NEXT: ============================================================
+# CHECK: {{.*}} | S_UDT [size = 24] `StructTypedef`
+# CHECK: original type = 0x1003
+# CHECK: {{.*}} | S_UDT [size = 16] `Struct`
+# CHECK: original type = 0x1006
+# CHECK: {{.*}} | S_UDT [size = 20] `IntTypedef`
+# CHECK: original type = 0x0074 (int)
+# CHECK: Symbols
+# CHECK-NEXT: ============================================================
+# CHECK: {{.*}} | S_GPROC32 [size = 44] `main`
+# CHECK-NEXT: parent = 0, end = 252, addr = 0001:0000, code size = 52
+# CHECK-NEXT: type = `0x1002 (int (int, char**))`, debug start = 0, debug end = 0, flags = none\r
+# CHECK-NOT: {{.*}} | S_END
+# CHECK: {{.*}} | S_UDT [size = 28] `main::LocalTypedef`
+# CHECK-NEXT: original type = 0x1004
+# CHECK: {{.*}} | S_END [size = 4]\r
+\r
+# source code to re-generate:\r
+# clang-cl /Z7 /GS- /GR- /c foo.cpp\r
+#\r
+# struct Struct {\r
+# int x;\r
+# };\r
+# \r
+# using IntTypedef = int;\r
+# using StructTypedef = Struct;\r
+# Struct S;\r
+# StructTypedef SS;\r
+# IntTypedef I;\r
+# \r
+# int main(int argc, char **argv) {\r
+# using LocalTypedef = Struct*;\r
+# LocalTypedef SPtr;\r
+# return I + S.x + SS.x + SPtr->x;\r
+# }
+
+ .text\r
+ .def @feat.00;\r
+ .scl 3;\r
+ .type 0;\r
+ .endef\r
+ .globl @feat.00\r
+.set @feat.00, 0\r
+ .intel_syntax noprefix\r
+ .def main;\r
+ .scl 2;\r
+ .type 32;\r
+ .endef\r
+ .globl main # -- Begin function main\r
+ .p2align 4, 0x90\r
+main: # @main\r
+.Lfunc_begin0:\r
+ .cv_func_id 0\r
+ .cv_file 1 "D:\\src\\llvmbuild\\cl\\Debug\\x64\\foo.cpp" "2B62298EE3EEF94E1D81FDFE18BD46A6" 1\r
+ .cv_loc 0 1 12 0 # foo.cpp:12:0\r
+.seh_proc main\r
+# %bb.0: # %entry\r
+ sub rsp, 32\r
+ .seh_stackalloc 32\r
+ .seh_endprologue\r
+ mov dword ptr [rsp + 28], 0\r
+ mov qword ptr [rsp + 16], rdx\r
+ mov dword ptr [rsp + 12], ecx\r
+.Ltmp0:\r
+ .cv_loc 0 1 15 0 # foo.cpp:15:0\r
+ mov ecx, dword ptr [rip + "?I@@3HA"]\r
+ add ecx, dword ptr [rip + "?S@@3UStruct@@A"]\r
+ add ecx, dword ptr [rip + "?SS@@3UStruct@@A"]\r
+ mov rdx, qword ptr [rsp]\r
+ add ecx, dword ptr [rdx]\r
+ mov eax, ecx\r
+ add rsp, 32\r
+ ret\r
+.Ltmp1:\r
+.Lfunc_end0:\r
+ .seh_handlerdata\r
+ .text\r
+ .seh_endproc\r
+ # -- End function\r
+ .bss\r
+ .globl "?S@@3UStruct@@A" # @"?S@@3UStruct@@A"\r
+ .p2align 2\r
+"?S@@3UStruct@@A":\r
+ .zero 4\r
+\r
+ .globl "?SS@@3UStruct@@A" # @"?SS@@3UStruct@@A"\r
+ .p2align 2\r
+"?SS@@3UStruct@@A":\r
+ .zero 4\r
+\r
+ .globl "?I@@3HA" # @"?I@@3HA"\r
+ .p2align 2\r
+"?I@@3HA":\r
+ .long 0 # 0x0\r
+\r
+ .section .drectve,"yn"\r
+ .ascii " /DEFAULTLIB:libcmt.lib"\r
+ .ascii " /DEFAULTLIB:oldnames.lib"\r
+ .section .debug$S,"dr"\r
+ .p2align 2\r
+ .long 4 # Debug section magic\r
+ .long 241\r
+ .long .Ltmp3-.Ltmp2 # Subsection size\r
+.Ltmp2:\r
+ .short .Ltmp5-.Ltmp4 # Record length\r
+.Ltmp4:\r
+ .short 4412 # Record kind: S_COMPILE3\r
+ .long 1 # Flags and language\r
+ .short 208 # CPUType\r
+ .short 8 # Frontend version\r
+ .short 0\r
+ .short 0\r
+ .short 0\r
+ .short 8000 # Backend version\r
+ .short 0\r
+ .short 0\r
+ .short 0\r
+ .asciz "clang version 8.0.0 " # Null-terminated compiler version string\r
+.Ltmp5:\r
+.Ltmp3:\r
+ .p2align 2\r
+ .long 241 # Symbol subsection for main\r
+ .long .Ltmp7-.Ltmp6 # Subsection size\r
+.Ltmp6:\r
+ .short .Ltmp9-.Ltmp8 # Record length\r
+.Ltmp8:\r
+ .short 4423 # Record kind: S_GPROC32_ID\r
+ .long 0 # PtrParent\r
+ .long 0 # PtrEnd\r
+ .long 0 # PtrNext\r
+ .long .Lfunc_end0-main # Code size\r
+ .long 0 # Offset after prologue\r
+ .long 0 # Offset before epilogue\r
+ .long 4099 # Function type index\r
+ .secrel32 main # Function section relative address\r
+ .secidx main # Function section index\r
+ .byte 0 # Flags\r
+ .asciz "main" # Function name\r
+.Ltmp9:\r
+ .short .Ltmp11-.Ltmp10 # Record length\r
+.Ltmp10:\r
+ .short 4114 # Record kind: S_FRAMEPROC\r
+ .long 32 # FrameSize\r
+ .long 0 # Padding\r
+ .long 0 # Offset of padding\r
+ .long 0 # Bytes of callee saved registers\r
+ .long 0 # Exception handler offset\r
+ .short 0 # Exception handler section\r
+ .long 81920 # Flags (defines frame register)\r
+.Ltmp11:\r
+ .short .Ltmp13-.Ltmp12 # Record length\r
+.Ltmp12:\r
+ .short 4414 # Record kind: S_LOCAL\r
+ .long 116 # TypeIndex\r
+ .short 1 # Flags\r
+ .asciz "argc"\r
+.Ltmp13:\r
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\f\000\000\000"\r
+ .short .Ltmp15-.Ltmp14 # Record length\r
+.Ltmp14:\r
+ .short 4414 # Record kind: S_LOCAL\r
+ .long 4096 # TypeIndex\r
+ .short 1 # Flags\r
+ .asciz "argv"\r
+.Ltmp15:\r
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\020\000\000\000"\r
+ .short .Ltmp17-.Ltmp16 # Record length\r
+.Ltmp16:\r
+ .short 4414 # Record kind: S_LOCAL\r
+ .long 4101 # TypeIndex\r
+ .short 0 # Flags\r
+ .asciz "SPtr"\r
+.Ltmp17:\r
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\000\000\000\000"\r
+ .short .Ltmp19-.Ltmp18 # Record length\r
+.Ltmp18:\r
+ .short 4360 # Record kind: S_UDT\r
+ .long 4101 # Type\r
+ .asciz "main::LocalTypedef"\r
+.Ltmp19:\r
+ .short 2 # Record length\r
+ .short 4431 # Record kind: S_PROC_ID_END\r
+.Ltmp7:\r
+ .p2align 2\r
+ .cv_linetable 0, main, .Lfunc_end0\r
+ .long 241 # Symbol subsection for globals\r
+ .long .Ltmp21-.Ltmp20 # Subsection size\r
+.Ltmp20:\r
+ .short .Ltmp23-.Ltmp22 # Record length\r
+.Ltmp22:\r
+ .short 4365 # Record kind: S_GDATA32\r
+ .long 4103 # Type\r
+ .secrel32 "?S@@3UStruct@@A" # DataOffset\r
+ .secidx "?S@@3UStruct@@A" # Segment\r
+ .asciz "S" # Name\r
+.Ltmp23:\r
+ .short .Ltmp25-.Ltmp24 # Record length\r
+.Ltmp24:\r
+ .short 4365 # Record kind: S_GDATA32\r
+ .long 4100 # Type\r
+ .secrel32 "?SS@@3UStruct@@A" # DataOffset\r
+ .secidx "?SS@@3UStruct@@A" # Segment\r
+ .asciz "SS" # Name\r
+.Ltmp25:\r
+ .short .Ltmp27-.Ltmp26 # Record length\r
+.Ltmp26:\r
+ .short 4365 # Record kind: S_GDATA32\r
+ .long 116 # Type\r
+ .secrel32 "?I@@3HA" # DataOffset\r
+ .secidx "?I@@3HA" # Segment\r
+ .asciz "I" # Name\r
+.Ltmp27:\r
+.Ltmp21:\r
+ .p2align 2\r
+ .long 241\r
+ .long .Ltmp29-.Ltmp28 # Subsection size\r
+.Ltmp28:\r
+ .short .Ltmp31-.Ltmp30 # Record length\r
+.Ltmp30:\r
+ .short 4360 # Record kind: S_UDT\r
+ .long 4103 # Type\r
+ .asciz "Struct"\r
+.Ltmp31:\r
+ .short .Ltmp33-.Ltmp32 # Record length\r
+.Ltmp32:\r
+ .short 4360 # Record kind: S_UDT\r
+ .long 4100 # Type\r
+ .asciz "StructTypedef"\r
+.Ltmp33:\r
+ .short .Ltmp35-.Ltmp34 # Record length\r
+.Ltmp34:\r
+ .short 4360 # Record kind: S_UDT\r
+ .long 116 # Type\r
+ .asciz "IntTypedef"\r
+.Ltmp35:\r
+.Ltmp29:\r
+ .p2align 2\r
+ .cv_filechecksums # File index to string table offset subsection\r
+ .cv_stringtable # String table\r
+ .long 241\r
+ .long .Ltmp37-.Ltmp36 # Subsection size\r
+.Ltmp36:\r
+ .short 6 # Record length\r
+ .short 4428 # Record kind: S_BUILDINFO\r
+ .long 4108 # LF_BUILDINFO index\r
+.Ltmp37:\r
+ .p2align 2\r
+ .section .debug$T,"dr"\r
+ .p2align 2\r
+ .long 4 # Debug section magic\r
+ # Pointer (0x1000) {\r
+ # TypeLeafKind: LF_POINTER (0x1002)\r
+ # PointeeType: char* (0x670)\r
+ # PtrType: Near64 (0xC)\r
+ # PtrMode: Pointer (0x0)\r
+ # IsFlat: 0\r
+ # IsConst: 0\r
+ # IsVolatile: 0\r
+ # IsUnaligned: 0\r
+ # IsRestrict: 0\r
+ # IsThisPtr&: 0\r
+ # IsThisPtr&&: 0\r
+ # SizeOf: 8\r
+ # }\r
+ .byte 0x0a, 0x00, 0x02, 0x10\r
+ .byte 0x70, 0x06, 0x00, 0x00\r
+ .byte 0x0c, 0x00, 0x01, 0x00\r
+ # ArgList (0x1001) {\r
+ # TypeLeafKind: LF_ARGLIST (0x1201)\r
+ # NumArgs: 2\r
+ # Arguments [\r
+ # ArgType: int (0x74)\r
+ # ArgType: char** (0x1000)\r
+ # ]\r
+ # }\r
+ .byte 0x0e, 0x00, 0x01, 0x12\r
+ .byte 0x02, 0x00, 0x00, 0x00\r
+ .byte 0x74, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x10, 0x00, 0x00\r
+ # Procedure (0x1002) {\r
+ # TypeLeafKind: LF_PROCEDURE (0x1008)\r
+ # ReturnType: int (0x74)\r
+ # CallingConvention: NearC (0x0)\r
+ # FunctionOptions [ (0x0)\r
+ # ]\r
+ # NumParameters: 2\r
+ # ArgListType: (int, char**) (0x1001)\r
+ # }\r
+ .byte 0x0e, 0x00, 0x08, 0x10\r
+ .byte 0x74, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x02, 0x00\r
+ .byte 0x01, 0x10, 0x00, 0x00\r
+ # FuncId (0x1003) {\r
+ # TypeLeafKind: LF_FUNC_ID (0x1601)\r
+ # ParentScope: 0x0\r
+ # FunctionType: int (int, char**) (0x1002)\r
+ # Name: main\r
+ # }\r
+ .byte 0x12, 0x00, 0x01, 0x16\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x02, 0x10, 0x00, 0x00\r
+ .byte 0x6d, 0x61, 0x69, 0x6e\r
+ .byte 0x00, 0xf3, 0xf2, 0xf1\r
+ # Struct (0x1004) {\r
+ # TypeLeafKind: LF_STRUCTURE (0x1505)\r
+ # MemberCount: 0\r
+ # Properties [ (0x280)\r
+ # ForwardReference (0x80)\r
+ # HasUniqueName (0x200)\r
+ # ]\r
+ # FieldList: 0x0\r
+ # DerivedFrom: 0x0\r
+ # VShape: 0x0\r
+ # SizeOf: 0\r
+ # Name: Struct\r
+ # LinkageName: .?AUStruct@@\r
+ # }\r
+ .byte 0x2a, 0x00, 0x05, 0x15\r
+ .byte 0x00, 0x00, 0x80, 0x02\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x53, 0x74\r
+ .byte 0x72, 0x75, 0x63, 0x74\r
+ .byte 0x00, 0x2e, 0x3f, 0x41\r
+ .byte 0x55, 0x53, 0x74, 0x72\r
+ .byte 0x75, 0x63, 0x74, 0x40\r
+ .byte 0x40, 0x00, 0xf2, 0xf1\r
+ # Pointer (0x1005) {\r
+ # TypeLeafKind: LF_POINTER (0x1002)\r
+ # PointeeType: Struct (0x1004)\r
+ # PtrType: Near64 (0xC)\r
+ # PtrMode: Pointer (0x0)\r
+ # IsFlat: 0\r
+ # IsConst: 0\r
+ # IsVolatile: 0\r
+ # IsUnaligned: 0\r
+ # IsRestrict: 0\r
+ # IsThisPtr&: 0\r
+ # IsThisPtr&&: 0\r
+ # SizeOf: 8\r
+ # }\r
+ .byte 0x0a, 0x00, 0x02, 0x10\r
+ .byte 0x04, 0x10, 0x00, 0x00\r
+ .byte 0x0c, 0x00, 0x01, 0x00\r
+ # FieldList (0x1006) {\r
+ # TypeLeafKind: LF_FIELDLIST (0x1203)\r
+ # DataMember {\r
+ # TypeLeafKind: LF_MEMBER (0x150D)\r
+ # AccessSpecifier: Public (0x3)\r
+ # Type: int (0x74)\r
+ # FieldOffset: 0x0\r
+ # Name: x\r
+ # }\r
+ # }\r
+ .byte 0x0e, 0x00, 0x03, 0x12\r
+ .byte 0x0d, 0x15, 0x03, 0x00\r
+ .byte 0x74, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x78, 0x00\r
+ # Struct (0x1007) {\r
+ # TypeLeafKind: LF_STRUCTURE (0x1505)\r
+ # MemberCount: 1\r
+ # Properties [ (0x200)\r
+ # HasUniqueName (0x200)\r
+ # ]\r
+ # FieldList: <field list> (0x1006)\r
+ # DerivedFrom: 0x0\r
+ # VShape: 0x0\r
+ # SizeOf: 4\r
+ # Name: Struct\r
+ # LinkageName: .?AUStruct@@\r
+ # }\r
+ .byte 0x2a, 0x00, 0x05, 0x15\r
+ .byte 0x01, 0x00, 0x00, 0x02\r
+ .byte 0x06, 0x10, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x04, 0x00, 0x53, 0x74\r
+ .byte 0x72, 0x75, 0x63, 0x74\r
+ .byte 0x00, 0x2e, 0x3f, 0x41\r
+ .byte 0x55, 0x53, 0x74, 0x72\r
+ .byte 0x75, 0x63, 0x74, 0x40\r
+ .byte 0x40, 0x00, 0xf2, 0xf1\r
+ # StringId (0x1008) {\r
+ # TypeLeafKind: LF_STRING_ID (0x1605)\r
+ # Id: 0x0\r
+ # StringData: D:\src\llvmbuild\cl\Debug\x64\foo.cpp\r
+ # }\r
+ .byte 0x2e, 0x00, 0x05, 0x16\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x44, 0x3a, 0x5c, 0x73\r
+ .byte 0x72, 0x63, 0x5c, 0x6c\r
+ .byte 0x6c, 0x76, 0x6d, 0x62\r
+ .byte 0x75, 0x69, 0x6c, 0x64\r
+ .byte 0x5c, 0x63, 0x6c, 0x5c\r
+ .byte 0x44, 0x65, 0x62, 0x75\r
+ .byte 0x67, 0x5c, 0x78, 0x36\r
+ .byte 0x34, 0x5c, 0x66, 0x6f\r
+ .byte 0x6f, 0x2e, 0x63, 0x70\r
+ .byte 0x70, 0x00, 0xf2, 0xf1\r
+ # UdtSourceLine (0x1009) {\r
+ # TypeLeafKind: LF_UDT_SRC_LINE (0x1606)\r
+ # UDT: Struct (0x1007)\r
+ # SourceFile: D:\src\llvmbuild\cl\Debug\x64\foo.cpp (0x1008)\r
+ # LineNumber: 1\r
+ # }\r
+ .byte 0x0e, 0x00, 0x06, 0x16\r
+ .byte 0x07, 0x10, 0x00, 0x00\r
+ .byte 0x08, 0x10, 0x00, 0x00\r
+ .byte 0x01, 0x00, 0x00, 0x00\r
+ # StringId (0x100A) {\r
+ # TypeLeafKind: LF_STRING_ID (0x1605)\r
+ # Id: 0x0\r
+ # StringData: D:\\src\\llvmbuild\\cl\\Debug\\x64\r
+ # }\r
+ .byte 0x2a, 0x00, 0x05, 0x16\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x44, 0x3a, 0x5c, 0x5c\r
+ .byte 0x73, 0x72, 0x63, 0x5c\r
+ .byte 0x5c, 0x6c, 0x6c, 0x76\r
+ .byte 0x6d, 0x62, 0x75, 0x69\r
+ .byte 0x6c, 0x64, 0x5c, 0x5c\r
+ .byte 0x63, 0x6c, 0x5c, 0x5c\r
+ .byte 0x44, 0x65, 0x62, 0x75\r
+ .byte 0x67, 0x5c, 0x5c, 0x78\r
+ .byte 0x36, 0x34, 0x00, 0xf1\r
+ # StringId (0x100B) {\r
+ # TypeLeafKind: LF_STRING_ID (0x1605)\r
+ # Id: 0x0\r
+ # StringData: foo.cpp\r
+ # }\r
+ .byte 0x0e, 0x00, 0x05, 0x16\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x66, 0x6f, 0x6f, 0x2e\r
+ .byte 0x63, 0x70, 0x70, 0x00\r
+ # BuildInfo (0x100C) {\r
+ # TypeLeafKind: LF_BUILDINFO (0x1603)\r
+ # NumArgs: 5\r
+ # Arguments [\r
+ # ArgType: D:\\src\\llvmbuild\\cl\\Debug\\x64 (0x100A)\r
+ # ArgType: 0x0\r
+ # ArgType: foo.cpp (0x100B)\r
+ # ArgType: 0x0\r
+ # ArgType: 0x0\r
+ # ]\r
+ # }\r
+ .byte 0x1a, 0x00, 0x03, 0x16\r
+ .byte 0x05, 0x00, 0x0a, 0x10\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x0b, 0x10\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0x00, 0x00\r
+ .byte 0x00, 0x00, 0xf2, 0xf1\r
+\r
+ .addrsig\r
+ .addrsig_sym "?S@@3UStruct@@A"\r
+ .addrsig_sym "?SS@@3UStruct@@A"\r
+ .addrsig_sym "?I@@3HA"\r