Skip to content

Commit 06a2d8b

Browse files
committed
ClangImporter: Faster globals-as-members check in the lazy member loading path
1 parent 89d5725 commit 06a2d8b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,14 +3625,16 @@ ClangImporter::Implementation::loadNamedMembers(
36253625
return None;
36263626
}
36273627

3628-
// Also bail out if there are any global-as-member mappings for this type; we
3629-
// can support some of them lazily but the full set of idioms seems
3628+
// Also bail out if there are any global-as-member mappings for this context;
3629+
// we can support some of them lazily but the full set of idioms seems
36303630
// prohibitively complex (also they're not stored in by-name lookup, for
36313631
// reasons unclear).
3632-
if (forEachLookupTable([&](SwiftLookupTable &table) -> bool {
3632+
if (isa<ExtensionDecl>(D) && !checkedGlobalsAsMembers.insert(IDC).second) {
3633+
if (forEachLookupTable([&](SwiftLookupTable &table) -> bool {
36333634
return (!table.lookupGlobalsAsMembers(effectiveClangContext).empty());
36343635
}))
3635-
return None;
3636+
return None;
3637+
}
36363638

36373639
// There are 3 cases:
36383640
//

lib/ClangImporter/ImporterImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
564564
llvm::DenseMap<const Decl *, ArrayRef<ProtocolDecl *>>
565565
ImportedProtocols;
566566

567+
/// The set of declaration context for which we've already ruled out the
568+
/// presence of globals-as-members.
569+
llvm::DenseSet<const IterableDeclContext *> checkedGlobalsAsMembers;
570+
567571
void startedImportingEntity();
568572

569573
public:

0 commit comments

Comments
 (0)