[DebugInfo] Fix an assertion in DWARFTypePrinter (#178986)

A `DW_TAG_ptr_to_member_type` has no `RawName` and would trigger an
assertion.


7e48b14d1e/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (L497-L502)

The assertion is mostly benign since it will be compared with other
strings and return false.


7e48b14d1e/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (L505-L510)

But this is blocking our assertion builds.
We should escape `DW_TAG_ptr_to_member_type` as well when looking for
type names.

Adding a test to demonstrate how the assertion could be triggered, and
how we fixed it.

Depends on https://github.com/llvm/llvm-project/pull/180655

[Assisted-by](https://t.ly/Dkjjk): [Claude Opus
4.5](https://www.anthropic.com/news/claude-opus-4-5)
This commit is contained in:
Peter Rong 2026-02-09 20:59:53 -08:00 committed by GitHub
parent fdd9555fc0
commit 9cd29a8ba1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3562 additions and 3429 deletions

View File

@ -274,3 +274,12 @@ void f1() {
t3<> v2;
}
} // namespace complex_type_units
// Test for ptr_to_member_type in template value parameter
namespace ptr_to_member_test {
struct S {
int data_mem;
};
template <int S::*P> void f() {}
void test() { f<&S::data_mem>(); }
} // namespace ptr_to_member_test

View File

@ -495,7 +495,8 @@ bool DWARFTypePrinter<DieType>::appendTemplateParameters(DieType D,
// symbol in the ELF symbol table to get back to the variable...
// but probably not worth it.
if (T.getTag() == dwarf::DW_TAG_pointer_type ||
T.getTag() == dwarf::DW_TAG_reference_type)
T.getTag() == dwarf::DW_TAG_reference_type ||
T.getTag() == dwarf::DW_TAG_ptr_to_member_type)
continue;
const char *RawName = detail::toString(T.find(dwarf::DW_AT_name));
assert(RawName);

File diff suppressed because it is too large Load Diff