@@ -1208,7 +1208,8 @@ bool MemoryBufferSerializedModuleLoader::canImportModule(
12081208
12091209ModuleDecl *
12101210SerializedModuleLoaderBase::loadModule (SourceLoc importLoc,
1211- ImportPath::Module path) {
1211+ ImportPath::Module path,
1212+ bool AllowMemoryCache) {
12121213 // FIXME: Swift submodules?
12131214 if (path.size () > 1 )
12141215 return nullptr ;
@@ -1233,7 +1234,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
12331234
12341235 auto M = ModuleDecl::create (moduleID.Item , Ctx);
12351236 M->setIsSystemModule (isSystemModule);
1236- Ctx.addLoadedModule (M);
1237+ if (AllowMemoryCache)
1238+ Ctx.addLoadedModule (M);
12371239 SWIFT_DEFER { M->setHasResolvedImports (); };
12381240
12391241 llvm::sys::path::native (moduleInterfacePath);
@@ -1264,7 +1266,8 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
12641266
12651267ModuleDecl *
12661268MemoryBufferSerializedModuleLoader::loadModule (SourceLoc importLoc,
1267- ImportPath::Module path) {
1269+ ImportPath::Module path,
1270+ bool AllowMemoryCache) {
12681271 // FIXME: Swift submodules?
12691272 if (path.size () > 1 )
12701273 return nullptr ;
@@ -1300,7 +1303,8 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
13001303 if (BypassResilience)
13011304 M->setBypassResilience ();
13021305 M->addFile (*file);
1303- Ctx.addLoadedModule (M);
1306+ if (AllowMemoryCache)
1307+ Ctx.addLoadedModule (M);
13041308 return M;
13051309}
13061310
0 commit comments