Front-end: add a new module loader that loads explicitly built Swift modules

To support -disable-implicit-swift-modules, the explicitly built modules
are passed down as compiler arguments. We need this new module loader to
handle these modules.

This patch also stops ModuleInterfaceLoader from building module from interface
when -disable-implicit-swift-modules is set.
This commit is contained in:
Xi Ge
2020-06-03 12:05:46 -07:00
parent d992e04717
commit bd782be654
11 changed files with 176 additions and 1 deletions

View File

@@ -2190,6 +2190,30 @@ TypeDecl *ModuleFile::lookupLocalType(StringRef MangledName) {
return cast<TypeDecl>(getDecl(*iter));
}
std::unique_ptr<llvm::MemoryBuffer>
ModuleFile::getModuleName(ASTContext &Ctx, StringRef modulePath,
std::string &Name) {
// Open the module file
auto &fs = *Ctx.SourceMgr.getFileSystem();
auto moduleBuf = fs.getBufferForFile(modulePath);
if (!moduleBuf)
return nullptr;
// Load the module file without validation.
std::unique_ptr<ModuleFile> loadedModuleFile;
ExtendedValidationInfo ExtInfo;
bool isFramework = false;
serialization::ValidationInfo loadInfo =
ModuleFile::load(modulePath.str(),
std::move(moduleBuf.get()),
nullptr,
nullptr,
/*isFramework*/isFramework, loadedModuleFile,
&ExtInfo);
Name = loadedModuleFile->Name;
return std::move(loadedModuleFile->ModuleInputBuffer);
}
OpaqueTypeDecl *ModuleFile::lookupOpaqueResultType(StringRef MangledName) {
PrettyStackTraceModuleFile stackEntry(*this);