Description
While experimenting with -gsimple-template-names
our debugger folks discovered the following interesting case.
template<typename T, typename U>
struct X {
T m1;
U m2;
};
template<typename V>
using Y = X<V, int>;
Y<int> y = {1, 2};
produces (edited for size):
0x0000001e: DW_TAG_variable
DW_AT_name ("y")
DW_AT_type (0x00000029 "Y<int>")
0x00000029: DW_TAG_typedef
DW_AT_type (0x00000031 "X<int, int>")
DW_AT_name ("Y<int>")
0x00000031: DW_TAG_structure_type
DW_AT_name ("X") // without -gsimple-template-names, this is "X<int,int>"
0x00000037: DW_TAG_template_type_parameter
DW_AT_type (0x00000056 "int")
DW_AT_name ("T")
0x0000003d: DW_TAG_template_type_parameter
DW_AT_type (0x00000056 "int")
DW_AT_name ("U")
0x00000043: DW_TAG_member
DW_AT_name ("m1")
DW_AT_type (0x00000056 "int")
0x0000004c: DW_TAG_member
DW_AT_name ("m2")
DW_AT_type (0x00000056 "int")
The only difference with/without -gsimple-template-names
is as noted. I'm a little surprised to see the typedef's DW_AT_type have a name with template parameters in it rather than just "X" but I guess llvm-dwarfdump does the reconstruction?
More to the point, in both cases we see DW_TAG_typedef with name Y<int>
when it really seems like it ought to be DW_TAG_template_alias with name Y
. The alias could then have template parameters, and the name simplification would work like expected.
I don't see any support in clang/llvm at all for DW_TAG_template_alias, which is mildly surprising as it goes back to DWARF v4. I guess we'd still have to emit DW_TAG_typedef for v2/v3.