Separate parsing out Swift and Clang modules from the explicit module map

Since https://github.com/apple/swift/pull/63178 added support for Clang modules in the explicit module map, it is possible for there to be multiple modules with the same name: a Swift module and a Clang module. The current parsing logic just overwrites the corresponding entry module in a hashmap so we always only preserved the module that comes last, with the same name.

This change separates the parsing of the modulemap JSON file to produce a separate Swift module map and Clang module map. The Swift one is used by the 'ExplicitSwiftModuleLoader', as before, and the Clang one is only used to populate the ClangArgs with the requried -fmodule-... flags.
This commit is contained in:
Artem Chikin
2023-02-15 14:48:16 -08:00
parent e851856625
commit a0b5dd4241
5 changed files with 105 additions and 51 deletions

View File

@@ -83,8 +83,11 @@ bool PlaceholderSwiftModuleScanner::findModule(
}
auto &moduleInfo = it->getValue();
auto dependencies = ModuleDependencyInfo::forPlaceholderSwiftModuleStub(
moduleInfo.modulePath, moduleInfo.moduleDocPath,
moduleInfo.moduleSourceInfoPath);
moduleInfo.modulePath,
moduleInfo.moduleDocPath.has_value() ?
moduleInfo.moduleDocPath.value() : "",
moduleInfo.moduleSourceInfoPath.has_value() ?
moduleInfo.moduleSourceInfoPath.value() : "");
this->dependencies = std::move(dependencies);
return true;
}