diff --git a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.test b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.test index 0adb2403db304..5a0da903e2a8b 100644 --- a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.test +++ b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.test @@ -1,4 +1,3 @@ -// XFAIL: system-darwin // RUN: %clang %target_itanium_abi_host_triple %p/Inputs/simplified_template_names.cpp -c -o - -gdwarf-4 -Xclang -gsimple-template-names=mangled -Xclang -debug-forward-template-params -std=c++20 -gtemplate-alias \ // RUN: | llvm-dwarfdump --verify - // diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h index 9108c718c4794..5201870131ce6 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h @@ -167,6 +167,23 @@ const char *toString(std::optional F) { } return nullptr; } + +/// Resolve the DW_AT_type of \c D until we reach a DIE that is not a +/// DW_TAG_typedef. +template DieType unwrapReferencedTypedefType(DieType D) { + auto TypeAttr = D.find(dwarf::DW_AT_type); + if (!TypeAttr) + return DieType(); + + auto Unwrapped = detail::resolveReferencedType(D, *TypeAttr); + if (!Unwrapped) + return DieType(); + + if (Unwrapped.getTag() == dwarf::DW_TAG_typedef) + return unwrapReferencedTypedefType(Unwrapped); + + return Unwrapped; +} } // namespace detail template @@ -588,10 +605,9 @@ bool DWARFTypePrinter::appendTemplateParameters(DieType D, } if (C.getTag() != dwarf::DW_TAG_template_type_parameter) continue; - auto TypeAttr = C.find(dwarf::DW_AT_type); Sep(); - appendQualifiedName(TypeAttr ? detail::resolveReferencedType(C, *TypeAttr) - : DieType()); + + appendQualifiedName(detail::unwrapReferencedTypedefType(C)); } if (IsTemplate && *FirstParameter && FirstParameter == &FirstParameterValue) { OS << '<';