[Explicit Module Builds] Add canImport functionality to the ExplicitSwiftModuleLoader

It needs to check against the provided ExplicitModuleMap instead of looking into search paths.
This commit is contained in:
Artem Chikin
2020-07-07 17:11:55 -07:00
parent 5a8fdafc54
commit f361b250de
3 changed files with 30 additions and 0 deletions

View File

@@ -1514,6 +1514,17 @@ std::error_code ExplicitSwiftModuleLoader::findModuleFilesInDirectory(
return std::error_code();
}
bool ExplicitSwiftModuleLoader::canImportModule(
Located<Identifier> mID) {
StringRef moduleName = mID.Item.str();
auto it = Impl.ExplicitModuleMap.find(moduleName);
// If no provided explicit module matches the name, then it cannot be imported.
if (it == Impl.ExplicitModuleMap.end()) {
return false;
}
return true;
}
void ExplicitSwiftModuleLoader::collectVisibleTopLevelModuleNames(
SmallVectorImpl<Identifier> &names) const {
for (auto &entry: Impl.ExplicitModuleMap) {