mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ExplicitModuleLoader: teach the module loader to accept forwarding modules
Since -emit-module-from-interface now emits forwarding modules, explicit module loader should be able to accept forwarding modules and unbox their actual binary contents.
This commit is contained in:
@@ -1654,6 +1654,31 @@ std::error_code ExplicitSwiftModuleLoader::findModuleFilesInDirectory(
|
||||
moduleInfo.modulePath);
|
||||
return moduleBuf.getError();
|
||||
}
|
||||
|
||||
assert(moduleBuf);
|
||||
const bool isForwardingModule = !serialization::isSerializedAST(moduleBuf
|
||||
.get()->getBuffer());
|
||||
// If the module is a forwarding module, read the actual content from the path
|
||||
// encoded in the forwarding module as the actual module content.
|
||||
if (isForwardingModule) {
|
||||
auto forwardingModule = ForwardingModule::load(*moduleBuf.get());
|
||||
if (forwardingModule) {
|
||||
moduleBuf = fs.getBufferForFile(forwardingModule->underlyingModulePath);
|
||||
if (!moduleBuf) {
|
||||
// We cannot read the module content, diagnose.
|
||||
Ctx.Diags.diagnose(SourceLoc(), diag::error_opening_explicit_module_file,
|
||||
moduleInfo.modulePath);
|
||||
return moduleBuf.getError();
|
||||
}
|
||||
} else {
|
||||
// We cannot read the module content, diagnose.
|
||||
Ctx.Diags.diagnose(SourceLoc(), diag::error_opening_explicit_module_file,
|
||||
moduleInfo.modulePath);
|
||||
return forwardingModule.getError();
|
||||
}
|
||||
}
|
||||
assert(moduleBuf);
|
||||
// Move the opened module buffer to the caller.
|
||||
*ModuleBuffer = std::move(moduleBuf.get());
|
||||
|
||||
// Open .swiftdoc file
|
||||
|
||||
Reference in New Issue
Block a user