1; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
2; RUN: llc < %s | llvm-mc -filetype=obj --triple=i686-windows | llvm-readobj - --codeview | FileCheck %s
3
4; C++ source to regenerate:
5; $ cat t.cpp
6; struct A {
7;   void f_default_public();
8; private:
9;   void f_private();
10; protected:
11;   void f_protected();
12; public:
13;   void f_public();
14; };
15;
16; class B {
17;  void f_default_private();
18; public:
19;   void f(float);
20;   void f(int);
21; };
22;
23; void foo() {
24;   A a;
25;   B b;
26; }
27
28
29; CHECK: CodeViewTypes [
30; CHECK:   Section: .debug$T (5)
31; CHECK:   Magic: 0x4
32; CHECK:   ArgList (0x1000) {
33; CHECK:     TypeLeafKind: LF_ARGLIST (0x1201)
34; CHECK:     NumArgs: 0
35; CHECK:     Arguments [
36; CHECK:     ]
37; CHECK:   }
38; CHECK:   Procedure (0x1001) {
39; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
40; CHECK:     ReturnType: void (0x3)
41; CHECK:     CallingConvention: NearC (0x0)
42; CHECK:     FunctionOptions [ (0x0)
43; CHECK:     ]
44; CHECK:     NumParameters: 0
45; CHECK:     ArgListType: () (0x1000)
46; CHECK:   }
47; CHECK:   FuncId (0x1002) {
48; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
49; CHECK:     ParentScope: 0x0
50; CHECK:     FunctionType: void () (0x1001)
51; CHECK:     Name: foo
52; CHECK:   }
53; CHECK:   Struct (0x1003) {
54; CHECK:     TypeLeafKind: LF_STRUCTURE (0x1505)
55; CHECK:     MemberCount: 0
56; CHECK:     Properties [ (0x80)
57; CHECK:       ForwardReference (0x80)
58; CHECK:     ]
59; CHECK:     FieldList: 0x0
60; CHECK:     DerivedFrom: 0x0
61; CHECK:     VShape: 0x0
62; CHECK:     SizeOf: 0
63; CHECK:     Name: A
64; CHECK:   }
65; CHECK:   Pointer (0x1004) {
66; CHECK:     TypeLeafKind: LF_POINTER (0x1002)
67; CHECK:     PointeeType: A (0x1003)
68; CHECK:     PtrType: Near32 (0xA)
69; CHECK:     PtrMode: Pointer (0x0)
70; CHECK:     IsFlat: 0
71; CHECK:     IsConst: 1
72; CHECK:     IsVolatile: 0
73; CHECK:     IsUnaligned: 0
74; CHECK:   }
75; CHECK:   MemberFunction (0x1005) {
76; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
77; CHECK:     ReturnType: void (0x3)
78; CHECK:     ClassType: A (0x1003)
79; CHECK:     ThisType: A* const (0x1004)
80; CHECK:     CallingConvention: ThisCall (0xB)
81; CHECK:     FunctionOptions [ (0x0)
82; CHECK:     ]
83; CHECK:     NumParameters: 0
84; CHECK:     ArgListType: () (0x1000)
85; CHECK:     ThisAdjustment: 0
86; CHECK:   }
87; CHECK:   FieldList (0x1006) {
88; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
89; CHECK:     OneMethod {
90; CHECK:       AccessSpecifier: Public (0x3)
91; CHECK:       Type: void A::() (0x1005)
92; CHECK:       Name: A::f_default_public
93; CHECK:     }
94; CHECK:     OneMethod {
95; CHECK:       AccessSpecifier: Private (0x1)
96; CHECK:       Type: void A::() (0x1005)
97; CHECK:       Name: A::f_private
98; CHECK:     }
99; CHECK:     OneMethod {
100; CHECK:       AccessSpecifier: Protected (0x2)
101; CHECK:       Type: void A::() (0x1005)
102; CHECK:       Name: A::f_protected
103; CHECK:     }
104; CHECK:     OneMethod {
105; CHECK:       AccessSpecifier: Public (0x3)
106; CHECK:       Type: void A::() (0x1005)
107; CHECK:       Name: A::f_public
108; CHECK:     }
109; CHECK:   }
110; CHECK:   Struct (0x1007) {
111; CHECK:     TypeLeafKind: LF_STRUCTURE (0x1505)
112; CHECK:     MemberCount: 4
113; CHECK:     Properties [ (0x0)
114; CHECK:     ]
115; CHECK:     FieldList: <field list> (0x1006)
116; CHECK:     DerivedFrom: 0x0
117; CHECK:     VShape: 0x0
118; CHECK:     SizeOf: 1
119; CHECK:     Name: A
120; CHECK:   }
121; CHECK:   StringId (0x1008) {
122; CHECK:     TypeLeafKind: LF_STRING_ID (0x1605)
123; CHECK:     Id: 0x0
124; CHECK:     StringData: /t.cpp
125; CHECK:   }
126; CHECK:   UdtSourceLine (0x1009) {
127; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
128; CHECK:     UDT: A (0x1007)
129; CHECK:     SourceFile: /t.cpp (0x1008)
130; CHECK:     LineNumber: 1
131; CHECK:   }
132; CHECK:   Class (0x100A) {
133; CHECK:     TypeLeafKind: LF_CLASS (0x1504)
134; CHECK:     MemberCount: 0
135; CHECK:     Properties [ (0x80)
136; CHECK:       ForwardReference (0x80)
137; CHECK:     ]
138; CHECK:     FieldList: 0x0
139; CHECK:     DerivedFrom: 0x0
140; CHECK:     VShape: 0x0
141; CHECK:     SizeOf: 0
142; CHECK:     Name: B
143; CHECK:   }
144; CHECK:   Pointer (0x100B) {
145; CHECK:     TypeLeafKind: LF_POINTER (0x1002)
146; CHECK:     PointeeType: B (0x100A)
147; CHECK:     PtrType: Near32 (0xA)
148; CHECK:     PtrMode: Pointer (0x0)
149; CHECK:     IsFlat: 0
150; CHECK:     IsConst: 1
151; CHECK:     IsVolatile: 0
152; CHECK:     IsUnaligned: 0
153; CHECK:     SizeOf: 4
154; CHECK:   }
155; CHECK:   MemberFunction (0x100C) {
156; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
157; CHECK:     ReturnType: void (0x3)
158; CHECK:     ClassType: B (0x100A)
159; CHECK:     ThisType: B* const (0x100B)
160; CHECK:     CallingConvention: ThisCall (0xB)
161; CHECK:     FunctionOptions [ (0x0)
162; CHECK:     ]
163; CHECK:     NumParameters: 0
164; CHECK:     ArgListType: () (0x1000)
165; CHECK:     ThisAdjustment: 0
166; CHECK:   }
167; CHECK:   ArgList (0x100D) {
168; CHECK:     TypeLeafKind: LF_ARGLIST (0x1201)
169; CHECK:     NumArgs: 1
170; CHECK:     Arguments [
171; CHECK:       ArgType: float (0x40)
172; CHECK:     ]
173; CHECK:   }
174; CHECK:   MemberFunction (0x100E) {
175; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
176; CHECK:     ReturnType: void (0x3)
177; CHECK:     ClassType: B (0x100A)
178; CHECK:     ThisType: B* const (0x100B)
179; CHECK:     CallingConvention: ThisCall (0xB)
180; CHECK:     FunctionOptions [ (0x0)
181; CHECK:     ]
182; CHECK:     NumParameters: 1
183; CHECK:     ArgListType: (float) (0x100D)
184; CHECK:     ThisAdjustment: 0
185; CHECK:   }
186; CHECK:   ArgList (0x100F) {
187; CHECK:     TypeLeafKind: LF_ARGLIST (0x1201)
188; CHECK:     NumArgs: 1
189; CHECK:     Arguments [
190; CHECK:       ArgType: int (0x74)
191; CHECK:     ]
192; CHECK:   }
193; CHECK:   MemberFunction (0x1010) {
194; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
195; CHECK:     ReturnType: void (0x3)
196; CHECK:     ClassType: B (0x100A)
197; CHECK:     ThisType: B* const (0x100B)
198; CHECK:     CallingConvention: ThisCall (0xB)
199; CHECK:     FunctionOptions [ (0x0)
200; CHECK:     ]
201; CHECK:     NumParameters: 1
202; CHECK:     ArgListType: (int) (0x100F)
203; CHECK:     ThisAdjustment: 0
204; CHECK:   }
205; CHECK:   MethodOverloadList (0x1011) {
206; CHECK:     TypeLeafKind: LF_METHODLIST (0x1206)
207; CHECK:     Method [
208; CHECK:       AccessSpecifier: Public (0x3)
209; CHECK:       Type: void B::(float) (0x100E)
210; CHECK:     ]
211; CHECK:     Method [
212; CHECK:       AccessSpecifier: Public (0x3)
213; CHECK:       Type: void B::(int) (0x1010)
214; CHECK:     ]
215; CHECK:   }
216; CHECK:   FieldList (0x1012) {
217; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
218; CHECK:     OneMethod {
219; CHECK:       AccessSpecifier: Private (0x1)
220; CHECK:       Type: void B::() (0x100C)
221; CHECK:       Name: B::f_default_private
222; CHECK:     }
223; CHECK:     OverloadedMethod {
224; CHECK:       MethodCount: 0x2
225; CHECK:       MethodListIndex: 0x1011
226; CHECK:       Name: B::f
227; CHECK:     }
228; CHECK:   }
229; CHECK:   Class (0x1013) {
230; CHECK:     TypeLeafKind: LF_CLASS (0x1504)
231; CHECK:     MemberCount: 3
232; CHECK:     Properties [ (0x0)
233; CHECK:     ]
234; CHECK:     FieldList: <field list> (0x1012)
235; CHECK:     DerivedFrom: 0x0
236; CHECK:     VShape: 0x0
237; CHECK:     SizeOf: 1
238; CHECK:     Name: B
239; CHECK:   }
240; CHECK:   UdtSourceLine (0x1014) {
241; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
242; CHECK:     UDT: B (0x1013)
243; CHECK:     SourceFile: /t.cpp (0x1008)
244; CHECK:     LineNumber: 11
245; CHECK:   }
246; CHECK: ]
247
248
249target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
250target triple = "i686-pc-windows-msvc"
251
252%struct.A = type { i8 }
253%class.B = type { i8 }
254
255; Function Attrs: nounwind
256define void @"\01?foo@@YAXXZ"() #0 !dbg !6 {
257entry:
258  %a = alloca %struct.A, align 1
259  %b = alloca %class.B, align 1
260  call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !9, metadata !19), !dbg !20
261  call void @llvm.dbg.declare(metadata %class.B* %b, metadata !21, metadata !19), !dbg !36
262  ret void, !dbg !37
263}
264
265; Function Attrs: nounwind readnone
266declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
267
268attributes #0 = { nounwind }
269attributes #1 = { nounwind readnone }
270
271!llvm.dbg.cu = !{!0}
272!llvm.module.flags = !{!3, !4}
273!llvm.ident = !{!5}
274
275!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272316)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
276!1 = !DIFile(filename: "t.cpp", directory: "/")
277!2 = !{}
278!3 = !{i32 2, !"CodeView", i32 1}
279!4 = !{i32 2, !"Debug Info Version", i32 3}
280!5 = !{!"clang version 3.9.0 (trunk 272316)"}
281!6 = distinct !DISubprogram(name: "foo", linkageName: "\01?foo@@YAXXZ", scope: !1, file: !1, line: 18, type: !7, isLocal: false, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
282!7 = !DISubroutineType(types: !8)
283!8 = !{null}
284!9 = !DILocalVariable(name: "a", scope: !6, file: !1, line: 19, type: !10)
285!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 8, align: 8, elements: !11)
286!11 = !{!12, !16, !17, !18}
287!12 = !DISubprogram(name: "A::f_default_public", linkageName: "\01?f_default_public@A@@QAEXXZ", scope: !10, file: !1, line: 2, type: !13, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
288!13 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !14)
289!14 = !{null, !15}
290!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, align: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
291!16 = !DISubprogram(name: "A::f_private", linkageName: "\01?f_private@A@@AAEXXZ", scope: !10, file: !1, line: 4, type: !13, isLocal: false, isDefinition: false, scopeLine: 4, flags: DIFlagPrivate | DIFlagPrototyped, isOptimized: false)
292!17 = !DISubprogram(name: "A::f_protected", linkageName: "\01?f_protected@A@@IAEXXZ", scope: !10, file: !1, line: 6, type: !13, isLocal: false, isDefinition: false, scopeLine: 6, flags: DIFlagProtected | DIFlagPrototyped, isOptimized: false)
293!18 = !DISubprogram(name: "A::f_public", linkageName: "\01?f_public@A@@QAEXXZ", scope: !10, file: !1, line: 8, type: !13, isLocal: false, isDefinition: false, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false)
294!19 = !DIExpression()
295!20 = !DILocation(line: 19, scope: !6)
296!21 = !DILocalVariable(name: "b", scope: !6, file: !1, line: 20, type: !22)
297!22 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !1, line: 11, size: 8, align: 8, elements: !23)
298!23 = !{!24, !28, !32}
299!24 = !DISubprogram(name: "B::f_default_private", linkageName: "\01?f_default_private@B@@AAEXXZ", scope: !22, file: !1, line: 12, type: !25, isLocal: false, isDefinition: false, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false)
300!25 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !26)
301!26 = !{null, !27}
302!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32, align: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
303!28 = !DISubprogram(name: "B::f", linkageName: "\01?f@B@@QAEXM@Z", scope: !22, file: !1, line: 14, type: !29, isLocal: false, isDefinition: false, scopeLine: 14, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)
304!29 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !30)
305!30 = !{null, !27, !31}
306!31 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
307!32 = !DISubprogram(name: "B::f", linkageName: "\01?f@B@@QAEXH@Z", scope: !22, file: !1, line: 15, type: !33, isLocal: false, isDefinition: false, scopeLine: 15, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)
308!33 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !34)
309!34 = !{null, !27, !35}
310!35 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
311!36 = !DILocation(line: 20, scope: !6)
312!37 = !DILocation(line: 21, scope: !6)
313