1; RUN: llc  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
2
3; C++ source to regenerate:
4
5;template <typename T = char, int i = 3 >
6;class foo {
7;};
8;
9;int main() {
10; foo<int,6> f1;
11; foo<> f2;
12; return 0;
13;}
14
15; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp
16
17; CHECK: .debug_abbrev contents:
18; CHECK: DW_AT_default_value     DW_FORM_flag_present
19
20; CHECK: debug_info contents:
21
22; CHECK: DW_AT_name {{.*}} "foo<int, 6>"
23; CHECK: DW_AT_type {{.*}} "int"
24; CHECK-NEXT: DW_AT_name {{.*}} "T"
25; CHECK-NOT: DW_AT_default_value
26; CHECK: DW_AT_type {{.*}} "int"
27; CHECK-NEXT: DW_AT_name {{.*}} "i"
28; CHECK-NOT: DW_AT_default_value
29
30; CHECK: DW_AT_name {{.*}} "foo<char, 3>"
31; CHECK: DW_AT_type {{.*}} "char"
32; CHECK-NEXT: DW_AT_name {{.*}} "T"
33; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
34; CHECK: DW_AT_type {{.*}} "int"
35; CHECK-NEXT: DW_AT_name {{.*}} "i"
36; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
37
38; ModuleID = '/dir/test.cpp'
39source_filename = "test.cpp"
40target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-unknown-linux-gnu"
42
43%class.foo = type { i8 }
44%class.foo.0 = type { i8 }
45; Function Attrs: noinline norecurse nounwind optnone uwtable
46define dso_local i32 @main() #0 !dbg !7 {
47entry:
48  %retval = alloca i32, align 4
49  %f1 = alloca %class.foo, align 1
50  %f2 = alloca %class.foo.0, align 1
51  store i32 0, i32* %retval, align 4
52  call void @llvm.dbg.declare(metadata %class.foo* %f1, metadata !11, metadata !DIExpression()), !dbg !16
53  call void @llvm.dbg.declare(metadata %class.foo.0* %f2, metadata !17, metadata !DIExpression()), !dbg !23
54  ret i32 0, !dbg !24
55}
56; Function Attrs: nounwind readnone speculatable willreturn
57declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
58
59attributes #0 = { noinline norecurse nounwind optnone uwtable }
60attributes #1 = { nounwind readnone speculatable willreturn }
61
62!llvm.dbg.cu = !{!0}
63!llvm.module.flags = !{!3, !4, !5}
64!llvm.ident = !{!6}
65
66!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
67!1 = !DIFile(filename: "test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "863d08522c2300490dea873efc4b2369")
68!2 = !{}
69!3 = !{i32 7, !"Dwarf Version", i32 5}
70!4 = !{i32 2, !"Debug Info Version", i32 3}
71!5 = !{i32 1, !"wchar_size", i32 4}
72!6 = !{!"clang version 11.0.0"}
73!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 29, type: !8, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
74!8 = !DISubroutineType(types: !9)
75!9 = !{!10}
76!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
77!11 = !DILocalVariable(name: "f1", scope: !7, file: !1, line: 30, type: !12)
78!12 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<int, 6>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !13, identifier: "_ZTS3fooIiLi6EE")
79!13 = !{!14, !15}
80!14 = !DITemplateTypeParameter(name: "T", type: !10)
81!15 = !DITemplateValueParameter(name: "i", type: !10, value: i32 6)
82!16 = !DILocation(line: 30, column: 14, scope: !7)
83!17 = !DILocalVariable(name: "f2", scope: !7, file: !1, line: 31, type: !18)
84!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<char, 3>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !19, identifier: "_ZTS3fooIcLi3EE")
85!19 = !{!20, !22}
86!20 = !DITemplateTypeParameter(name: "T", type: !21, defaulted: true)
87!21 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
88!22 = !DITemplateValueParameter(name: "i", type: !10, defaulted: true, value: i32 3)
89!23 = !DILocation(line: 31, column: 9, scope: !7)
90!24 = !DILocation(line: 32, column: 3, scope: !7)
91