@@ -266,8 +266,8 @@ _buildDemanglingForMetadataPack(MetadataPackPointer pack, size_t count,
266266 return node;
267267}
268268
269- // / Build an array of demangling trees for each generic argument of the given
270- // / type metadata .
269+ // / Build an array of demangling trees for each generic argument to the given
270+ // / generic type context descriptor .
271271// /
272272// / Note:
273273// / - The input array has an entry for those generic parameter descriptors which
@@ -286,15 +286,14 @@ _buildDemanglingForMetadataPack(MetadataPackPointer pack, size_t count,
286286// / The output array is flat; the generic parameters of each depth are
287287// / concatenated together.
288288static bool _buildDemanglingForGenericArgs (
289- const Metadata *type,
290289 const TypeContextDescriptor *description,
290+ const Metadata *const *genericArgs,
291291 llvm::SmallVectorImpl<NodePointer> &demangledGenerics,
292292 Demangle::Demangler &Dem) {
293293 auto generics = description->getGenericContext ();
294294 if (!generics)
295295 return true ;
296296
297- auto genericArgs = description->getGenericArguments (type);
298297 auto packHeader = generics->getGenericPackShapeHeader ();
299298 auto packDescriptors = generics->getGenericPackShapeDescriptors ();
300299
@@ -420,12 +419,16 @@ _buildDemanglingForNominalType(const Metadata *type, Demangle::Demangler &Dem) {
420419 return nullptr ;
421420 }
422421
423- // Gather the complete set of generic arguments that must be written to
424- // form this type.
425422 llvm::SmallVector<NodePointer, 8 > demangledGenerics;
426- if (!_buildDemanglingForGenericArgs (type, description, demangledGenerics, Dem))
427- return nullptr ;
428-
423+ if (description->isGeneric ()) {
424+ auto genericArgs = description->getGenericArguments (type);
425+ // Gather the complete set of generic arguments that must be written to
426+ // form this type.
427+ if (!_buildDemanglingForGenericArgs (description, genericArgs,
428+ demangledGenerics, Dem))
429+ return nullptr ;
430+ }
431+
429432 return _buildDemanglingForContext (description, demangledGenerics, Dem);
430433}
431434
@@ -819,6 +822,25 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
819822 return nullptr ;
820823}
821824
825+ Demangle::NodePointer
826+ swift::_buildDemanglingForGenericType (const TypeContextDescriptor *description,
827+ const void *const *arguments,
828+ Demangle::Demangler &Dem) {
829+ auto kind = description->getKind ();
830+ if (kind != ContextDescriptorKind::Class &&
831+ kind != ContextDescriptorKind::Enum &&
832+ kind != ContextDescriptorKind::Struct)
833+ return nullptr ;
834+
835+ llvm::SmallVector<NodePointer, 8 > demangledGenerics;
836+ if (!_buildDemanglingForGenericArgs (description,
837+ (const Metadata *const *)arguments,
838+ demangledGenerics, Dem))
839+ return nullptr ;
840+
841+ return _buildDemanglingForContext (description, demangledGenerics, Dem);
842+ }
843+
822844// NB: This function is not used directly in the Swift codebase, but is
823845// exported for Xcode support and is used by the sanitizers. Please coordinate
824846// before changing.
0 commit comments