Factor out the pre-registered MemoryBuffer functionality

form SerializedModuleLoader into its own ModuleLoader class. (NFC-ish)

This gives better control over the order in which the various module
load mechanisms are applied.
This commit is contained in:
Adrian Prantl
2019-04-19 15:18:19 -07:00
parent 007fbb6ebd
commit b244b0928e
8 changed files with 165 additions and 66 deletions

View File

@@ -315,6 +315,13 @@ bool CompilerInstance::setUpModuleLoaders() {
}
}
if (Invocation.getLangOptions().EnableMemoryBufferImporter) {
auto MemoryBufferLoader = MemoryBufferSerializedModuleLoader::create(
*Context, getDependencyTracker());
this->MemoryBufferLoader = MemoryBufferLoader.get();
Context->addModuleLoader(std::move(MemoryBufferLoader));
}
std::unique_ptr<SerializedModuleLoader> SML =
SerializedModuleLoader::create(*Context, getDependencyTracker(), MLM);
this->SML = SML.get();
@@ -1067,6 +1074,7 @@ void CompilerInstance::freeASTContext() {
Context.reset();
MainModule = nullptr;
SML = nullptr;
MemoryBufferLoader = nullptr;
PrimaryBufferIDs.clear();
PrimarySourceFiles.clear();
}