================ @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=simple \ +// RUN: | FileCheck %s + +//// Check that -gtemplate-alias causes DW_TAG_template_alias emission for +//// template aliases with default parameter values. See template-alias.cpp for +//// more template alias tests. + +template<typename T> +struct X { + char m; +}; + +template<typename T> +struct Y { + char n; +}; + +template <typename NonDefault, template <typename C> class T = Y, int I = 5, typename... Ts> +using A = X<NonDefault>; + +//// We should be able to emit type alias metadata which describes all the +//// values, including the defaulted parameters and empty parameter pack. +A<int> a; + +// CHECK: !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) +// CHECK: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", +// CHECK: ![[int:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +// CHECK: ![[extraData]] = !{![[NonDefault:[0-9]+]], ![[T:[0-9]+]], ![[I:[0-9]+]], ![[Ts:[0-9]+]]} +// CHECK: ![[NonDefault]] = !DITemplateTypeParameter(name: "NonDefault", type: ![[int]]) +// CHECK: ![[T]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "T", defaulted: true, value: !"Y") +// CHECK: ![[I]] = !DITemplateValueParameter(name: "I", type: ![[int]], defaulted: true, value: i32 5) +// CHECK: ![[Ts]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Ts", value: ![[types:[0-9]+]]) +// CHECK: ![[types]] = !{} ---------------- OCHyams wrote:
For anyone interested, the dwarf for this test case looks like this: ``` $ clang -gsimple-template-names test9.cpp -g -c -o - -gtemplate-alias | llvm-dwarfdump - --name A --show-children -: file format elf64-x86-64 0x00000029: DW_TAG_template_alias DW_AT_type (0x00000044 "X<int>") DW_AT_name ("A") DW_AT_decl_file ("/home/och/scratch/test9.cpp") DW_AT_decl_line (13) 0x00000031: DW_TAG_template_type_parameter DW_AT_type (0x0000005a "int") DW_AT_name ("NonDefault") 0x00000037: DW_TAG_GNU_template_template_param DW_AT_name ("T") DW_AT_default_value (true) DW_AT_GNU_template_name ("Y") 0x0000003a: DW_TAG_template_value_parameter DW_AT_type (0x0000005a "int") DW_AT_name ("I") DW_AT_default_value (true) DW_AT_const_value (5) 0x00000041: DW_TAG_GNU_template_parameter_pack DW_AT_name ("Ts") 0x00000043: NULL ``` https://github.com/llvm/llvm-project/pull/87623 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits