Michael137 wrote:
> @Michael137, probably we should return finding and adding specialization in
> DWARFASTParserClang.cpp?
That would be equivalent to the way your current version handles this right? I
don't see how that would change anything.
I now realize this is trickier than expected. E.g., the infinite recursion
actually reproduces with valid DWARF. Consider:
```
template <typename T> struct Foo;
template <> struct Foo<__bf16> {};
template <> struct Foo<_Float16> : Foo<__bf16> {};
int main() {
Foo<_Float16> f1;
return 0;
}
```
This will crash:
```
clang++ main.cpp -g
lldb a.out -o "br se -p return -X main" -o run -o "expr f1"
```
I haven't stepped through LLDB in this case but what I suspect is happening is
that `__bf16` and `_Float16` both are floating point types with the same
bit-size we just pretend they both are `__fp16` (via
`GetBuiltinTypeForEncodingAndBitSize` most likely). So we have the same issue
as your malformed DWARF case where a template specialization derives from
another specialization but in the AST that LLDB creates the base specialization
has the same template parameter types as the derived class.
There are some defensive checks against creating duplicate decls which relies
on typenames:
https://github.com/llvm/llvm-project/blob/39572f5e9168b1b44c2f9078494616fed8752086/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1934-L1944
However, in my reproducer it doesn't work because in DWARF the typenames differ:
```
DW_AT_name ("Foo<_Float16>")
...
DW_AT_name ("Foo<__bf16>")
```
It's just that in the LLDB AST, the template parameter types don't match what
we encoded in the structure's name in DWARF.
My first instinct is that we might need to adjust the heuristics of the
`GetUniqueDWARFASTTypeMap` to account for this. But I haven't thought this
through enough to know whether this is possible/desirable.
https://github.com/llvm/llvm-project/pull/154123
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits