Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions include/swift/RemoteInspection/TypeRefBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ class TypeRefBuilder {
/// an external file.
remote::ExternalTypeRefCache *ExternalTypeRefCache = nullptr;

/// Ensure all field descriptors are in the FieldTypeInfoCache.
void ensureAllFieldDescriptorsCached();

public:
///
/// Dumping typerefs, field declarations, builtin types, captures,
Expand Down Expand Up @@ -746,20 +749,18 @@ class TypeRefBuilder {
ConformanceCollectionResult collectAllConformances() {
ConformanceCollectionResult result;

// The Fields section has gathered info on types that includes their
// mangled names. Use that to build a dictionary from a type's demangled
// name to its mangled name
ensureAllFieldDescriptorsCached();

Demangler dem;
// Build the demangled to mangled name map from the FieldTypeInfoCache.
std::unordered_map<std::string, std::string> typeNameToManglingMap;
for (const auto &section : ReflectionInfos) {
for (auto descriptor : section.Field) {
TypeRefBuilder::ScopedNodeFactoryCheckpoint checkpoint(&Builder);
auto TypeRef = readTypeRef(descriptor, descriptor->MangledTypeName);
auto OptionalMangledTypeName = normalizeReflectionName(TypeRef);
auto TypeName = nodeToString(Builder.demangleTypeRef(TypeRef));
if (OptionalMangledTypeName.has_value()) {
typeNameToManglingMap[TypeName] = OptionalMangledTypeName.value();
}
}
for (const auto &entry : FieldTypeInfoCache) {
const std::string &mangledName = entry.first;
RemoteRef<FieldDescriptor> descriptor = entry.second;

auto node = dem.demangleType(mangledName);
auto demangledName = nodeToString(node);
typeNameToManglingMap[demangledName] = mangledName;
}

// Collect all conformances and aggregate them per-conforming-type.
Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/RemoteInspection/TypeRefBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ void TypeRefBuilder::ReflectionTypeDescriptorFinder::
ProcessedReflectionInfoIndexes.insert(Index);
}

void TypeRefBuilder::ReflectionTypeDescriptorFinder::
ensureAllFieldDescriptorsCached() {
for (size_t i = 0; i < ReflectionInfos.size(); ++i) {
populateFieldTypeInfoCacheWithReflectionAtIndex(i);
}
}

std::optional<RemoteRef<FieldDescriptor>>
TypeRefBuilder::ReflectionTypeDescriptorFinder::findFieldDescriptorAtIndex(
size_t Index, const std::string &MangledName) {
Expand Down