-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ClangImporter: Don't force loading of all superclass members in loadNamedMembers() #29348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
slavapestov
wants to merge
1
commit into
swiftlang:master
from
slavapestov:load-all-members-considered-harmful
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3726,21 +3726,32 @@ void ClangImporter::Implementation::lookupAllObjCMembers( | |
// deserialized before loading the named member of this class. This allows the | ||
// decl members table to be warmed up and enables the correct identification of | ||
// overrides. | ||
// | ||
// FIXME: Very low hanging fruit: Loading everything is extremely wasteful. We | ||
// should be able to just load the name lazy member loading is asking for. | ||
static void ensureSuperclassMembersAreLoaded(const ClassDecl *CD) { | ||
static void loadNamedMemberOfSuperclassIfNeeded(const ClassDecl *CD, | ||
DeclBaseName name) { | ||
if (!CD) | ||
return; | ||
|
||
CD = CD->getSuperclassDecl(); | ||
if (!CD || !CD->hasClangNode()) | ||
if (!CD) | ||
return; | ||
|
||
CD->loadAllMembers(); | ||
|
||
for (auto *ED : const_cast<ClassDecl *>(CD)->getExtensions()) | ||
ED->loadAllMembers(); | ||
auto &ctx = CD->getASTContext(); | ||
|
||
if (CD->hasClangNode() && CD->hasLazyMembers()) { | ||
auto ci = ctx.getOrCreateLazyIterableContextData( | ||
CD, /*lazyLoader=*/nullptr); | ||
if (true || !ci->loader->loadNamedMembers(CD, name, ci->memberData)) | ||
CD->loadAllMembers(); | ||
} | ||
|
||
for (auto *ED : const_cast<ClassDecl *>(CD)->getExtensions()) { | ||
if (ED->hasClangNode() && ED->hasLazyMembers()) { | ||
auto ci = ctx.getOrCreateLazyIterableContextData( | ||
ED, /*lazyLoader=*/nullptr); | ||
if (true || !ci->loader->loadNamedMembers(ED, name, ci->memberData)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat debugging trick, but we oughta get these out before this is merged. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that wasn't supposed to be in there. It works without the 'true ||' too. |
||
ED->loadAllMembers(); | ||
} | ||
} | ||
} | ||
|
||
Optional<TinyPtrVector<ValueDecl *>> | ||
|
@@ -3793,7 +3804,7 @@ ClangImporter::Implementation::loadNamedMembers( | |
|
||
assert(isa<clang::ObjCContainerDecl>(CD) || isa<clang::NamespaceDecl>(CD)); | ||
|
||
ensureSuperclassMembersAreLoaded(dyn_cast<ClassDecl>(D)); | ||
loadNamedMemberOfSuperclassIfNeeded(dyn_cast<ClassDecl>(D), N); | ||
|
||
TinyPtrVector<ValueDecl *> Members; | ||
for (auto entry : table->lookup(SerializedSwiftName(N), | ||
|
@@ -3823,7 +3834,7 @@ ClangImporter::Implementation::loadNamedMembers( | |
auto member = entry.get<clang::NamedDecl *>(); | ||
if (!isVisibleClangEntry(clangCtx, member)) continue; | ||
|
||
// Skip Decls from different clang::DeclContexts | ||
// Skip Decls from different clang::DeclContexts | ||
if (member->getDeclContext() != CDC) continue; | ||
|
||
SmallVector<Decl*, 4> tmp; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can actually be replaced with a call to
(void) CD->lookupDirect(name)
. I'm going to test and benchmark both versions before checking this in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is.