Skip to content

Commit dc6858b

Browse files
committed
Force the entire member table for superclasses
Note that this can be an optimization in many cases since we only have to scrounge around in the PCMs once.
1 parent fdb7379 commit dc6858b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,22 +3714,19 @@ void ClangImporter::Implementation::lookupAllObjCMembers(
37143714
}
37153715
}
37163716

3717-
// Force the named member of the entire inheritance hierarchy to be loaded and
3717+
// Force the members of the entire inheritance hierarchy to be loaded and
37183718
// deserialized before loading the named member of this class. This allows the
37193719
// decl members table to be warmed up and enables the correct identification of
37203720
// overrides.
3721-
static void loadNamedMemberOfSuperclassIfNeeded(const ClassDecl *CD,
3722-
DeclBaseName name) {
3721+
static void ensureSuperclassMembersAreLoaded(const ClassDecl *CD) {
37233722
if (!CD)
37243723
return;
37253724

37263725
CD = CD->getSuperclassDecl();
37273726
if (!CD || !CD->hasClangNode())
37283727
return;
37293728

3730-
auto ci = CD->getASTContext().getOrCreateLazyIterableContextData(
3731-
CD, /*lazyLoader=*/nullptr);
3732-
ci->loader->loadNamedMembers(CD, name, ci->memberData);
3729+
CD->loadAllMembers();
37333730
}
37343731

37353732
Optional<TinyPtrVector<ValueDecl *>>
@@ -3793,7 +3790,7 @@ ClangImporter::Implementation::loadNamedMembers(
37933790

37943791
assert(isa<clang::ObjCContainerDecl>(CD) || isa<clang::NamespaceDecl>(CD));
37953792

3796-
loadNamedMemberOfSuperclassIfNeeded(dyn_cast<ClassDecl>(D), N);
3793+
ensureSuperclassMembersAreLoaded(dyn_cast<ClassDecl>(D));
37973794

37983795
TinyPtrVector<ValueDecl *> Members;
37993796
for (auto entry : table->lookup(SerializedSwiftName(N),

test/NameBinding/named_lazy_member_loading_objc_interface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Check that named-lazy-member-loading reduces the number of Decls deserialized
99
// RUN: %target-swift-frontend -typecheck -I %S/Inputs/NamedLazyMembers -disable-named-lazy-member-loading -stats-output-dir %t/stats-pre -primary-file %s %S/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift
1010
// RUN: %target-swift-frontend -typecheck -I %S/Inputs/NamedLazyMembers -stats-output-dir %t/stats-post -primary-file %s %S/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift
11-
// RUN: %{python} %utils/process-stats-dir.py --evaluate-delta 'NumTotalClangImportedEntities < -10' %t/stats-pre %t/stats-post
11+
// RUN: %{python} %utils/process-stats-dir.py --evaluate-delta 'NumTotalClangImportedEntities <= -1' %t/stats-pre %t/stats-post
1212

1313
import NamedLazyMembers
1414

0 commit comments

Comments
 (0)