Merge pull request #32754 from artemcm/CanImportExplicitly

[Explicit Module Builds] Add canImport functionality to the ExplicitSwiftModuleLoader
This commit is contained in:
Artem Chikin
2020-07-09 16:06:40 -07:00
committed by GitHub
3 changed files with 30 additions and 0 deletions

View File

@@ -1616,6 +1616,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) {