[lldb][DataFormatter] Unwrap reference type when formatting std::unordered_map (#145872)

Desugar any potential references/typedefs before checking
`isStdTemplate`. Previously, the typename might've been:
```
const std::unordered_map<...> &
```
for references. This patch gets the pointee type before grabbing the
canonical type. `GetNonReferenceType` will unwrap typedefs too, so we
should always end up with a non-reference before we get to
`GetCanonicalType`.

https://github.com/llvm/llvm-project/issues/145847
This commit is contained in:
Michael Buch
2025-06-26 17:10:12 +01:00
committed by GitHub
parent e0b83ca8a4
commit aeea062dd4
3 changed files with 50 additions and 2 deletions

View File

@@ -113,8 +113,10 @@ CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
// wraps a std::pair. Peel away the internal wrapper type - whose structure is
// of no value to users, to expose the std::pair. This matches the structure
// returned by the std::map synthetic provider.
if (isUnorderedMap(
m_backend.GetCompilerType().GetCanonicalType().GetTypeName())) {
if (isUnorderedMap(m_backend.GetCompilerType()
.GetNonReferenceType()
.GetCanonicalType()
.GetTypeName())) {
std::string name;
CompilerType field_type =
element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);