Debug info for template variables don't have unique names
| Bugzilla Link | 22119 |
| Version | unspecified |
| OS | Windows NT |
| CC | @dwblaikie,@ormris |
Extended Description
Use -g -std=c++14 to compile this source:
template <typename T> T crazy = T();
int foo() {
crazy<int> = 5;
crazy<short> = 10;
return crazy<int> + crazy<short>;
}
The names of the two local variables get correct types and mangled names,
but DW_AT_name = "crazy" for both.
Probably they should be crazy<int> and crazy<short> to disambiguate.
And maybe have child template-parameter DIEs too. :-P
A partial fix was committed as r343706 and r343707. Adding template
parameters to DW_AT_name will have to wait until LLDB can parse
them.
Paul - want to try writing a patch for this? Shouldn't be too hard.
+Larisse, in case she wants to dive into this.
I won't mind if somebody else gets to it first, but it would be convenient to have this done before the 3.6 branch. I'll put it on my list.
Paul - want to try writing a patch for this? Shouldn't be too hard.
+Larisse, in case she wants to dive into this.
Things have improved in Clang 21.0: https://godbolt.org/z/d5hqeedb3
DW_AT_names are still the same, but DW_AT_types and DW_AT_linkage_names differ. Also, they have attached DW_TAG_template_type_parameter. I wonder if this is good enough.
CC @dwblaikie
@llvm/issue-subscribers-debuginfo
Author: Paul T Robinson (pogo59)
Extended Description
Use -g -std=c++14 to compile this source:
template <typename T> T crazy = T();
int foo() {
crazy<int> = 5;
crazy<short> = 10;
return crazy<int> + crazy<short>;
}
The names of the two local variables get correct types and mangled names,
but DW_AT_name = "crazy" for both.
Probably they should be crazy<int> and crazy<short> to disambiguate.
And maybe have child template-parameter DIEs too. :-P
Things have improved in Clang 21.0: https://godbolt.org/z/d5hqeedb3
DW_AT_names are still the same, butDW_AT_types andDW_AT_linkage_names differ. Also, they have attachedDW_TAG_template_type_parameter. I wonder if this is good enough. CC @dwblaikie
I don't think it is sufficient, unfortunately - at least for now, in my exploration of Simplified Template Names ( https://groups.google.com/g/llvm-dev/c/ekLMllbLIZg/m/-dhJ0hO1AAAJ ) there are several cases where Clang's structured DWARF output isn't sufficiently descriptive to roundtrip/reproduce the textual name of the template specialization.
Check CGDebugInfo::HasReconstitutableArgs for examples of problems.