1 ; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
3 ; Check that we keep namespace scopes around the same way MSVC does.
4 ; We do function scopes slightly differently, but everything should be alright.
6 ; C++ source to regenerate:
10 ; struct LocalRecord {
14 ; struct GlobalRecord {
18 ; void GlobalRecord::method() {}
22 ; CHECK-LABEL: FuncId ({{.*}}) {
23 ; CHECK-NEXT: TypeLeafKind: LF_FUNC_ID (0x1601)
24 ; CHECK-NEXT: ParentScope: foo::bar ({{.*}})
25 ; CHECK-NEXT: FunctionType: void () ({{.*}})
26 ; CHECK-NEXT: Name: baz
29 ; CHECK: Struct ({{.*}}) {
30 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
31 ; CHECK: MemberCount: 0
32 ; CHECK: Properties [ (0x180)
33 ; CHECK: ForwardReference (0x80)
34 ; CHECK: Scoped (0x100)
36 ; CHECK: FieldList: 0x0
37 ; CHECK: DerivedFrom: 0x0
40 ; CHECK: Name: foo::bar::baz::LocalRecord
43 ; CHECK: Struct ({{.*}}) {
44 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
45 ; CHECK: MemberCount: 1
46 ; CHECK: Properties [ (0x100)
47 ; CHECK: Scoped (0x100)
49 ; CHECK: Name: foo::bar::baz::LocalRecord
52 ; CHECK: Struct ({{.*}}) {
53 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
54 ; CHECK: MemberCount: 0
55 ; CHECK: Properties [ (0x280)
56 ; CHECK: ForwardReference (0x80)
57 ; CHECK: HasUniqueName (0x200)
59 ; CHECK: FieldList: 0x0
60 ; CHECK: DerivedFrom: 0x0
63 ; CHECK: Name: foo::bar::GlobalRecord
66 ; CHECK-LABEL: MemberFuncId ({{.*}}) {
67 ; CHECK-NEXT: TypeLeafKind: LF_MFUNC_ID (0x1602)
68 ; CHECK-NEXT: ClassType: foo::bar::GlobalRecord ({{.*}})
69 ; CHECK-NEXT: FunctionType: void foo::bar::GlobalRecord::() ({{.*}})
70 ; CHECK-NEXT: Name: method
74 source_filename = "t.cpp"
75 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
76 target triple = "x86_64-pc-windows-msvc19.0.23918"
78 %"struct.foo::bar::GlobalRecord" = type { i32 }
79 %struct.LocalRecord = type { i32 }
81 @"\01?g@bar@foo@@3UGlobalRecord@12@A" = global %"struct.foo::bar::GlobalRecord" zeroinitializer, align 4, !dbg !0
83 ; Function Attrs: nounwind uwtable
84 define void @"\01?baz@bar@foo@@YAXXZ"() #0 !dbg !20 {
86 %l = alloca %struct.LocalRecord, align 4
87 call void @llvm.dbg.declare(metadata %struct.LocalRecord* %l, metadata !23, metadata !27), !dbg !28
91 ; Function Attrs: nounwind readnone
92 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
94 ; Function Attrs: nounwind uwtable
95 define void @"\01?method@GlobalRecord@bar@foo@@QEAAXXZ"(%"struct.foo::bar::GlobalRecord"* %this) #0 align 2 !dbg !30 {
97 %this.addr = alloca %"struct.foo::bar::GlobalRecord"*, align 8
98 store %"struct.foo::bar::GlobalRecord"* %this, %"struct.foo::bar::GlobalRecord"** %this.addr, align 8
99 call void @llvm.dbg.declare(metadata %"struct.foo::bar::GlobalRecord"** %this.addr, metadata !31, metadata !27), !dbg !33
100 %this1 = load %"struct.foo::bar::GlobalRecord"*, %"struct.foo::bar::GlobalRecord"** %this.addr, align 8
104 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
105 attributes #1 = { nounwind readnone }
107 !llvm.dbg.cu = !{!13}
108 !llvm.module.flags = !{!16, !17, !18}
111 !0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
112 !1 = !DIGlobalVariable(name: "g", linkageName: "\01?g@bar@foo@@3UGlobalRecord@12@A", scope: !2, file: !3, line: 12, type: !5, isLocal: false, isDefinition: true)
113 !2 = !DINamespace(name: "bar", scope: !4)
114 !3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
115 !4 = !DINamespace(name: "foo", scope: null)
116 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "GlobalRecord", scope: !2, file: !3, line: 9, size: 32, align: 32, elements: !6, identifier: ".?AUGlobalRecord@bar@foo@@")
118 !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !3, line: 10, baseType: !8, size: 32, align: 32)
119 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
120 !9 = !DISubprogram(name: "method", linkageName: "\01?method@GlobalRecord@bar@foo@@QEAAXXZ", scope: !5, file: !3, line: 11, type: !10, isLocal: false, isDefinition: false, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false)
121 !10 = !DISubroutineType(types: !11)
123 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
124 !13 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !14, globals: !15)
127 !16 = !{i32 2, !"CodeView", i32 1}
128 !17 = !{i32 2, !"Debug Info Version", i32 3}
129 !18 = !{i32 1, !"PIC Level", i32 2}
130 !19 = !{!"clang version 3.9.0 "}
131 !20 = distinct !DISubprogram(name: "baz", linkageName: "\01?baz@bar@foo@@YAXXZ", scope: !2, file: !3, line: 3, type: !21, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !13, retainedNodes: !14)
132 !21 = !DISubroutineType(types: !22)
134 !23 = !DILocalVariable(name: "l", scope: !20, file: !3, line: 6, type: !24)
135 !24 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "LocalRecord", scope: !20, file: !3, line: 4, size: 32, align: 32, elements: !25)
137 !26 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !24, file: !3, line: 5, baseType: !8, size: 32, align: 32)
138 !27 = !DIExpression()
139 !28 = !DILocation(line: 6, column: 5, scope: !20)
140 !29 = !DILocation(line: 7, column: 1, scope: !20)
141 !30 = distinct !DISubprogram(name: "method", linkageName: "\01?method@GlobalRecord@bar@foo@@QEAAXXZ", scope: !5, file: !3, line: 13, type: !10, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !13, declaration: !9, retainedNodes: !14)
142 !31 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !32, flags: DIFlagArtificial | DIFlagObjectPointer)
143 !32 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64)
144 !33 = !DILocation(line: 0, scope: !30)
145 !34 = !DILocation(line: 13, column: 30, scope: !30)