[NFC] Get rid of ASTContext::getModuleByName dups

This method was reimplemented three times in various source tools.
This commit is contained in:
Brent Royal-Gordon
2020-08-31 12:46:30 -07:00
parent f2249e9af5
commit 61f716d5a8
3 changed files with 4 additions and 30 deletions

View File

@@ -91,16 +91,6 @@ typedef SwiftInterfaceGenContext::Implementation::TextReference TextReference;
typedef SwiftInterfaceGenContext::Implementation::TextDecl TextDecl;
typedef SwiftInterfaceGenContext::Implementation::SourceTextInfo SourceTextInfo;
static ModuleDecl *getModuleByFullName(ASTContext &Ctx, StringRef ModuleName) {
ImportPath::Module::Builder builder;
while (!ModuleName.empty()) {
StringRef SubModuleName;
std::tie(SubModuleName, ModuleName) = ModuleName.split('.');
builder.push_back(Ctx.getIdentifier(SubModuleName));
}
return Ctx.getModule(builder.get());
}
static ModuleDecl *getModuleByFullName(ASTContext &Ctx, Identifier ModuleName) {
return Ctx.getModule(ImportPath::Module::Builder(ModuleName).get());
}
@@ -293,7 +283,7 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
}
// Get the (sub)module to generate.
Mod = getModuleByFullName(Ctx, ModuleName);
Mod = Ctx.getModuleByName(ModuleName);
if (!Mod) {
ErrMsg = "Could not load module: ";
ErrMsg += ModuleName;