SR-11889: Using Located<T> instead of std::pair<SourceLoc, T>

This commit is contained in:
Kita, Maksim
2019-12-08 22:51:48 +03:00
parent 06014e6226
commit b7cb3b67bf
38 changed files with 209 additions and 171 deletions

View File

@@ -428,7 +428,7 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
bool &isFramework, bool &isSystemModule) {
llvm::SmallString<64> moduleName(moduleID.first.str());
llvm::SmallString<64> moduleName(moduleID.item.str());
ModuleFilenamePair fileNames(moduleName);
SmallVector<ModuleFilenamePair, 4> targetFileNamePairs;
@@ -465,7 +465,7 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
// We can only get here if all targetFileNamePairs failed with
// 'std::errc::no_such_file_or_directory'.
if (maybeDiagnoseTargetMismatch(moduleID.second, moduleName,
if (maybeDiagnoseTargetMismatch(moduleID.loc, moduleName,
primaryTargetSpecificName, currPath)) {
return false;
} else {
@@ -517,7 +517,7 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
case SearchPathKind::Framework: {
isFramework = true;
llvm::sys::path::append(currPath,
moduleID.first.str() + ".framework");
moduleID.item.str() + ".framework");
// Check if the framework directory exists.
if (!fs.exists(currPath))
@@ -825,7 +825,7 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
}
bool SerializedModuleLoaderBase::canImportModule(
std::pair<Identifier, SourceLoc> mID) {
Located<Identifier> mID) {
// Look on disk.
SmallVector<char, 0> *unusedModuleInterfacePath = nullptr;
std::unique_ptr<llvm::MemoryBuffer> *unusedModuleBuffer = nullptr;
@@ -839,9 +839,9 @@ bool SerializedModuleLoaderBase::canImportModule(
}
bool MemoryBufferSerializedModuleLoader::canImportModule(
std::pair<Identifier, SourceLoc> mID) {
Located<Identifier> mID) {
// See if we find it in the registered memory buffers.
return MemoryBuffers.count(mID.first.str());
return MemoryBuffers.count(mID.item.str());
}
ModuleDecl *
@@ -876,15 +876,15 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
assert(moduleInputBuffer);
auto M = ModuleDecl::create(moduleID.first, Ctx);
auto M = ModuleDecl::create(moduleID.item, Ctx);
M->setIsSystemModule(isSystemModule);
Ctx.LoadedModules[moduleID.first] = M;
Ctx.LoadedModules[moduleID.item] = M;
SWIFT_DEFER { M->setHasResolvedImports(); };
StringRef moduleInterfacePathStr =
Ctx.AllocateCopy(moduleInterfacePath.str());
if (!loadAST(*M, moduleID.second, moduleInterfacePathStr,
if (!loadAST(*M, moduleID.loc, moduleInterfacePathStr,
std::move(moduleInputBuffer), std::move(moduleDocInputBuffer),
std::move(moduleSourceInfoInputBuffer),
isFramework, /*treatAsPartialModule*/false)) {
@@ -908,7 +908,7 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
// FIXME: Right now this works only with access paths of length 1.
// Once submodules are designed, this needs to support suffix
// matching and a search path.
auto bufIter = MemoryBuffers.find(moduleID.first.str());
auto bufIter = MemoryBuffers.find(moduleID.item.str());
if (bufIter == MemoryBuffers.end())
return nullptr;
@@ -919,16 +919,16 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
MemoryBuffers.erase(bufIter);
assert(moduleInputBuffer);
auto *M = ModuleDecl::create(moduleID.first, Ctx);
auto *M = ModuleDecl::create(moduleID.item, Ctx);
SWIFT_DEFER { M->setHasResolvedImports(); };
if (!loadAST(*M, moduleID.second, /*moduleInterfacePath*/ "",
if (!loadAST(*M, moduleID.loc, /*moduleInterfacePath*/ "",
std::move(moduleInputBuffer), {}, {},
isFramework, treatAsPartialModule)) {
return nullptr;
}
Ctx.LoadedModules[moduleID.first] = M;
Ctx.LoadedModules[moduleID.item] = M;
return M;
}