mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SR-11889: Using Located<T> instead of std::pair<SourceLoc, T>
This commit is contained in:
@@ -1468,12 +1468,12 @@ ClangModuleLoader *ASTContext::getDWARFModuleLoader() const {
|
||||
}
|
||||
|
||||
ModuleDecl *ASTContext::getLoadedModule(
|
||||
ArrayRef<std::pair<Identifier, SourceLoc>> ModulePath) const {
|
||||
ArrayRef<Located<Identifier>> ModulePath) const {
|
||||
assert(!ModulePath.empty());
|
||||
|
||||
// TODO: Swift submodules.
|
||||
if (ModulePath.size() == 1) {
|
||||
return getLoadedModule(ModulePath[0].first);
|
||||
return getLoadedModule(ModulePath[0].item);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1723,13 +1723,13 @@ bool ASTContext::shouldPerformTypoCorrection() {
|
||||
return NumTypoCorrections <= LangOpts.TypoCorrectionLimit;
|
||||
}
|
||||
|
||||
bool ASTContext::canImportModule(std::pair<Identifier, SourceLoc> ModulePath) {
|
||||
bool ASTContext::canImportModule(Located<Identifier> ModulePath) {
|
||||
// If this module has already been successfully imported, it is importable.
|
||||
if (getLoadedModule(ModulePath) != nullptr)
|
||||
return true;
|
||||
|
||||
// If we've failed loading this module before, don't look for it again.
|
||||
if (FailedModuleImportNames.count(ModulePath.first))
|
||||
if (FailedModuleImportNames.count(ModulePath.item))
|
||||
return false;
|
||||
|
||||
// Otherwise, ask the module loaders.
|
||||
@@ -1739,12 +1739,12 @@ bool ASTContext::canImportModule(std::pair<Identifier, SourceLoc> ModulePath) {
|
||||
}
|
||||
}
|
||||
|
||||
FailedModuleImportNames.insert(ModulePath.first);
|
||||
FailedModuleImportNames.insert(ModulePath.item);
|
||||
return false;
|
||||
}
|
||||
|
||||
ModuleDecl *
|
||||
ASTContext::getModule(ArrayRef<std::pair<Identifier, SourceLoc>> ModulePath) {
|
||||
ASTContext::getModule(ArrayRef<Located<Identifier>> ModulePath) {
|
||||
assert(!ModulePath.empty());
|
||||
|
||||
if (auto *M = getLoadedModule(ModulePath))
|
||||
@@ -1752,7 +1752,7 @@ ASTContext::getModule(ArrayRef<std::pair<Identifier, SourceLoc>> ModulePath) {
|
||||
|
||||
auto moduleID = ModulePath[0];
|
||||
for (auto &importer : getImpl().ModuleLoaders) {
|
||||
if (ModuleDecl *M = importer->loadModule(moduleID.second, ModulePath)) {
|
||||
if (ModuleDecl *M = importer->loadModule(moduleID.loc, ModulePath)) {
|
||||
return M;
|
||||
}
|
||||
}
|
||||
@@ -1761,7 +1761,7 @@ ASTContext::getModule(ArrayRef<std::pair<Identifier, SourceLoc>> ModulePath) {
|
||||
}
|
||||
|
||||
ModuleDecl *ASTContext::getModuleByName(StringRef ModuleName) {
|
||||
SmallVector<std::pair<Identifier, SourceLoc>, 4>
|
||||
SmallVector<Located<Identifier>, 4>
|
||||
AccessPath;
|
||||
while (!ModuleName.empty()) {
|
||||
StringRef SubModuleName;
|
||||
@@ -1778,7 +1778,7 @@ ModuleDecl *ASTContext::getStdlibModule(bool loadIfAbsent) {
|
||||
if (loadIfAbsent) {
|
||||
auto mutableThis = const_cast<ASTContext*>(this);
|
||||
TheStdlibModule =
|
||||
mutableThis->getModule({ std::make_pair(StdlibModuleName, SourceLoc()) });
|
||||
mutableThis->getModule({{ StdlibModuleName, SourceLoc() }});
|
||||
} else {
|
||||
TheStdlibModule = getLoadedModule(StdlibModuleName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user