<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54624>54624</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Support DW_TAG_template_alias
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dwblaikie
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pogo59
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNlk1zozgQhn8NvnTZhcGYcOCQGY-3ctjLr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