1; Tests that DW_AT_default_value is correctly emitted for C++ template 2; parameters that are defaulted. 3; 4; ModuleID = 'debug-info-template-parameter.cpp' 5; 6; template <typename T = char, int i = 3, bool b = true, int x = sizeof(T)> 7; class foo { 8; }; 9; 10; int main() { 11; foo<int, 6, false, 3> f1; 12; foo<> f2; 13; return 0; 14; } 15; 16; RUN: llc -filetype=obj -dwarf-version=4 %s -o - | llvm-dwarfdump - --debug-info | FileCheck %s --check-prefixes=DWARF-DUMP,DWARFv4 17; RUN: llc -filetype=obj -dwarf-version=4 -strict-dwarf=true %s -o - | llvm-dwarfdump - --debug-info | FileCheck %s --check-prefixes=DWARF-DUMP,STRICT 18 19; DWARF-DUMP: DW_TAG_class_type 20; DWARF-DUMP-LABEL: DW_AT_name ("foo<char, 3, true, 1>") 21; DWARF-DUMP: DW_TAG_template_type_parameter 22; DWARF-DUMP-DAG: DW_AT_type ({{.*}} "char") 23; DWARF-DUMP-DAG: DW_AT_name ("T") 24; DWARFv4-DAG: DW_AT_default_value (true) 25; STRICT-NOT: DW_AT_default_value 26; DWARF-DUMP: DW_TAG_template_value_parameter 27; DWARF-DUMP-DAG: DW_AT_type ({{.*}} "int") 28; DWARF-DUMP-DAG: DW_AT_name ("i") 29; DWARFv4-DAG: DW_AT_default_value (true) 30; STRICT-NOT: DW_AT_default_value (true) 31; DWARF-DUMP: DW_TAG_template_value_parameter 32; DWARF-DUMP-DAG: DW_AT_type ({{.*}} "bool") 33; DWARF-DUMP-DAG: DW_AT_name ("b") 34; DWARFv4-DAG: DW_AT_default_value (true) 35; STRICT-NOT: DW_AT_default_value 36; DWARF-DUMP: {{DW_TAG|NULL}} 37 38source_filename = "/tmp/debug-info-template-parameter.cpp" 39target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 40target triple = "x86_64" 41 42%class.foo = type { i8 } 43%class.foo.0 = type { i8 } 44 45; Function Attrs: mustprogress noinline norecurse nounwind optnone 46define dso_local noundef i32 @main() #0 !dbg !6 { 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, ptr %retval, align 4 52 call void @llvm.dbg.declare(metadata ptr %f1, metadata !12, metadata !DIExpression()), !dbg !20 53 call void @llvm.dbg.declare(metadata ptr %f2, metadata !21, metadata !DIExpression()), !dbg !29 54 ret i32 0, !dbg !30 55} 56 57; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 58declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 59 60attributes #0 = { mustprogress noinline norecurse nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } 61attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } 62 63!llvm.dbg.cu = !{!0} 64!llvm.linker.options = !{} 65!llvm.module.flags = !{!2, !3, !4} 66!llvm.ident = !{!5} 67 68!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 16.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 69!1 = !DIFile(filename: "/tmp/debug-info-template-parameter.cpp", directory: "/") 70!2 = !{i32 7, !"Dwarf Version", i32 4} 71!3 = !{i32 2, !"Debug Info Version", i32 3} 72!4 = !{i32 1, !"wchar_size", i32 4} 73!5 = !{!"clang version 16.0.0"} 74!6 = distinct !DISubprogram(name: "main", scope: !7, file: !7, line: 49, type: !8, scopeLine: 49, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !11) 75!7 = !DIFile(filename: "/tmp/debug-info-template-parameter.cpp", directory: "/") 76!8 = !DISubroutineType(types: !9) 77!9 = !{!10} 78!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 79!11 = !{} 80!12 = !DILocalVariable(name: "f1", scope: !6, file: !7, line: 50, type: !13) 81!13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<int, 6, false, 3>", file: !7, line: 46, size: 8, flags: DIFlagTypePassByValue, elements: !11, templateParams: !14, identifier: "_ZTS3fooIiLi6ELb0ELi3EE") 82!14 = !{!15, !16, !17, !19} 83!15 = !DITemplateTypeParameter(name: "T", type: !10) 84!16 = !DITemplateValueParameter(name: "i", type: !10, value: i32 6) 85!17 = !DITemplateValueParameter(name: "b", type: !18, value: i1 false) 86!18 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) 87!19 = !DITemplateValueParameter(name: "x", type: !10, value: i32 3) 88!20 = !DILocation(line: 50, column: 25, scope: !6) 89!21 = !DILocalVariable(name: "f2", scope: !6, file: !7, line: 51, type: !22) 90!22 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<char, 3, true, 1>", file: !7, line: 46, size: 8, flags: DIFlagTypePassByValue, elements: !11, templateParams: !23, identifier: "_ZTS3fooIcLi3ELb1ELi1EE") 91!23 = !{!24, !26, !27, !28} 92!24 = !DITemplateTypeParameter(name: "T", type: !25, defaulted: true) 93!25 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 94!26 = !DITemplateValueParameter(name: "i", type: !10, defaulted: true, value: i32 3) 95!27 = !DITemplateValueParameter(name: "b", type: !18, defaulted: true, value: i1 true) 96!28 = !DITemplateValueParameter(name: "x", type: !10, value: i32 1) 97!29 = !DILocation(line: 51, column: 9, scope: !6) 98!30 = !DILocation(line: 52, column: 3, scope: !6) 99