mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Name lookup: avoid even calling lookup code on Clang submodules.
This is a hack. We currently don't put anything in Clang submodules; they're just wrappers to track what is and isn't visible. All lookups happen through the top- level module. This commit adds a new API getImportedModulesForLookup, which is ONLY used by top-level name lookup and forAllVisibleModules. It is identical to getImportedModules for everything but ClangModuleUnits, which instead compute and cache a list of their transitively imported top-level modules. This speeds up building Foundation.swiftmodule with a release compiler by a bit more than 5%, and makes a previously lookup-bound test case compile a third faster than before. This is a hack. rdar://problem/20813240 Swift SVN r28598
This commit is contained in:
@@ -1076,8 +1076,6 @@ LOOKUP_OPERATOR(Postfix)
|
||||
|
||||
void Module::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
|
||||
Module::ImportFilter filter) const {
|
||||
// FIXME: Audit uses of this function and make sure they make sense in a
|
||||
// multi-file world.
|
||||
FORWARD(getImportedModules, (modules, filter));
|
||||
}
|
||||
|
||||
@@ -1103,6 +1101,11 @@ SourceFile::getImportedModules(SmallVectorImpl<Module::ImportedModule> &modules,
|
||||
}
|
||||
}
|
||||
|
||||
void Module::getImportedModulesForLookup(
|
||||
SmallVectorImpl<ImportedModule> &modules) const {
|
||||
FORWARD(getImportedModulesForLookup, (modules));
|
||||
}
|
||||
|
||||
bool Module::isSameAccessPath(AccessPathTy lhs, AccessPathTy rhs) {
|
||||
using AccessPathElem = std::pair<Identifier, SourceLoc>;
|
||||
if (lhs.size() != rhs.size())
|
||||
@@ -1288,7 +1291,11 @@ static bool forAllImportedModules(Module *topLevel,
|
||||
|
||||
if (!fn(next))
|
||||
return false;
|
||||
next.second->getImportedModules(stack, filter);
|
||||
|
||||
if (respectVisibility)
|
||||
next.second->getImportedModulesForLookup(stack);
|
||||
else
|
||||
next.second->getImportedModules(stack, filter);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user