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