@@ -597,6 +597,9 @@ class TypeRefBuilder {
597597 // / an external file.
598598 remote::ExternalTypeRefCache *ExternalTypeRefCache = nullptr ;
599599
600+ // / Ensure all field descriptors are in the FieldTypeInfoCache.
601+ void ensureAllFieldDescriptorsCached ();
602+
600603 public:
601604 // /
602605 // / Dumping typerefs, field declarations, builtin types, captures,
@@ -746,20 +749,18 @@ class TypeRefBuilder {
746749 ConformanceCollectionResult collectAllConformances () {
747750 ConformanceCollectionResult result;
748751
749- // The Fields section has gathered info on types that includes their
750- // mangled names. Use that to build a dictionary from a type's demangled
751- // name to its mangled name
752+ ensureAllFieldDescriptorsCached ();
753+
754+ Demangler dem;
755+ // Build the demangled to mangled name map from the FieldTypeInfoCache.
752756 std::unordered_map<std::string, std::string> typeNameToManglingMap;
753- for (const auto §ion : ReflectionInfos) {
754- for (auto descriptor : section.Field ) {
755- TypeRefBuilder::ScopedNodeFactoryCheckpoint checkpoint (&Builder);
756- auto TypeRef = readTypeRef (descriptor, descriptor->MangledTypeName );
757- auto OptionalMangledTypeName = normalizeReflectionName (TypeRef);
758- auto TypeName = nodeToString (Builder.demangleTypeRef (TypeRef));
759- if (OptionalMangledTypeName.has_value ()) {
760- typeNameToManglingMap[TypeName] = OptionalMangledTypeName.value ();
761- }
762- }
757+ for (const auto &entry : FieldTypeInfoCache) {
758+ const std::string &mangledName = entry.first ;
759+ RemoteRef<FieldDescriptor> descriptor = entry.second ;
760+
761+ auto node = dem.demangleType (mangledName);
762+ auto demangledName = nodeToString (node);
763+ typeNameToManglingMap[demangledName] = mangledName;
763764 }
764765
765766 // Collect all conformances and aggregate them per-conforming-type.
0 commit comments