Merge pull request #61649 from xymus/index-swiftinterfaces

[Index] Force indexing of system modules to read only from swiftinterfaces
This commit is contained in:
Alexis Laferrière
2022-10-31 14:18:45 -07:00
committed by GitHub
28 changed files with 268 additions and 50 deletions

View File

@@ -445,7 +445,8 @@ std::error_code ImplicitSerializedModuleLoader::findModuleFilesInDirectory(
(!ModuleBuffer && !ModuleDocBuffer)) &&
"Module and Module Doc buffer must both be initialized or NULL");
if (LoadMode == ModuleLoadingMode::OnlyInterface)
if (LoadMode == ModuleLoadingMode::OnlyInterface ||
Ctx.IgnoreAdjacentModules)
return std::make_error_code(std::errc::not_supported);
auto ModuleErr = openModuleFile(ModuleID, BaseName, ModuleBuffer);
@@ -1209,7 +1210,8 @@ bool MemoryBufferSerializedModuleLoader::canImportModule(
ModuleDecl *
SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
ImportPath::Module path) {
ImportPath::Module path,
bool AllowMemoryCache) {
// FIXME: Swift submodules?
if (path.size() > 1)
return nullptr;
@@ -1234,7 +1236,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
auto M = ModuleDecl::create(moduleID.Item, Ctx);
M->setIsSystemModule(isSystemModule);
Ctx.addLoadedModule(M);
if (AllowMemoryCache)
Ctx.addLoadedModule(M);
SWIFT_DEFER { M->setHasResolvedImports(); };
llvm::sys::path::native(moduleInterfacePath);
@@ -1265,7 +1268,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
ModuleDecl *
MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
ImportPath::Module path) {
ImportPath::Module path,
bool AllowMemoryCache) {
// FIXME: Swift submodules?
if (path.size() > 1)
return nullptr;
@@ -1301,7 +1305,8 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
if (BypassResilience)
M->setBypassResilience();
M->addFile(*file);
Ctx.addLoadedModule(M);
if (AllowMemoryCache)
Ctx.addLoadedModule(M);
return M;
}