Skip to content

Commit c8f990b

Browse files
committed
ClangImporter: Don't force loading of all superclass members in loadNamedMembers()
1 parent 08dca46 commit c8f990b

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,27 +3730,6 @@ void ClangImporter::Implementation::lookupAllObjCMembers(
37303730
}
37313731
}
37323732

3733-
// Force the members of the entire inheritance hierarchy to be loaded and
3734-
// deserialized before loading the named member of this class. This allows the
3735-
// decl members table to be warmed up and enables the correct identification of
3736-
// overrides.
3737-
//
3738-
// FIXME: Very low hanging fruit: Loading everything is extremely wasteful. We
3739-
// should be able to just load the name lazy member loading is asking for.
3740-
static void ensureSuperclassMembersAreLoaded(const ClassDecl *CD) {
3741-
if (!CD)
3742-
return;
3743-
3744-
CD = CD->getSuperclassDecl();
3745-
if (!CD || !CD->hasClangNode())
3746-
return;
3747-
3748-
CD->loadAllMembers();
3749-
3750-
for (auto *ED : const_cast<ClassDecl *>(CD)->getExtensions())
3751-
ED->loadAllMembers();
3752-
}
3753-
37543733
Optional<TinyPtrVector<ValueDecl *>>
37553734
ClangImporter::Implementation::loadNamedMembers(
37563735
const IterableDeclContext *IDC, DeclBaseName N, uint64_t contextData) {
@@ -3799,7 +3778,16 @@ ClangImporter::Implementation::loadNamedMembers(
37993778

38003779
assert(isa<clang::ObjCContainerDecl>(CD) || isa<clang::NamespaceDecl>(CD));
38013780

3802-
ensureSuperclassMembersAreLoaded(dyn_cast<ClassDecl>(D));
3781+
// Force the members of the entire inheritance hierarchy to be loaded and
3782+
// deserialized before loading the named member of a class. This warms up
3783+
// ClangImporter::Implementation::MembersForNominal, used for computing
3784+
// property overrides.
3785+
//
3786+
// FIXME: If getOverriddenDecl() kicked off a request for imported decls,
3787+
// we could postpone this until overrides are actually requested.
3788+
if (auto *classDecl = dyn_cast<ClassDecl>(D))
3789+
if (auto *superclassDecl = classDecl->getSuperclassDecl())
3790+
(void) const_cast<ClassDecl *>(superclassDecl)->lookupDirect(N);
38033791

38043792
TinyPtrVector<ValueDecl *> Members;
38053793
for (auto entry : table->lookup(SerializedSwiftName(N),
@@ -3829,7 +3817,7 @@ ClangImporter::Implementation::loadNamedMembers(
38293817
auto member = entry.get<clang::NamedDecl *>();
38303818
if (!isVisibleClangEntry(member)) continue;
38313819

3832-
// Skip Decls from different clang::DeclContexts
3820+
// Skip Decls from different clang::DeclContexts
38333821
if (member->getDeclContext() != CDC) continue;
38343822

38353823
SmallVector<Decl*, 4> tmp;

0 commit comments

Comments
 (0)