[swift-ide-test] Bail out when a module couldn't be loaded (#15563)

The importer in particular depends on the stdlib and the Foundation
overlay being successfully loaded, so if anything /can't/ be loaded
we have to assume that trying to walk a module's decls will result
in a crash.

rdar://problem/37540394
This commit is contained in:
Jordan Rose
2018-03-28 10:09:52 -07:00
committed by GitHub
parent 76c264e9a1
commit 4c47bd1104
2 changed files with 19 additions and 2 deletions

View File

@@ -1490,11 +1490,18 @@ static ModuleDecl *getModuleByFullName(ASTContext &Context, StringRef ModuleName
AccessPath.push_back(
{ Context.getIdentifier(SubModuleName), SourceLoc() });
}
return Context.getModule(AccessPath);
ModuleDecl *Result = Context.getModule(AccessPath);
if (!Result || Result->failedToLoad())
return nullptr;
return Result;
}
static ModuleDecl *getModuleByFullName(ASTContext &Context, Identifier ModuleName) {
return Context.getModule(std::make_pair(ModuleName, SourceLoc()));
ModuleDecl *Result = Context.getModule(std::make_pair(ModuleName,
SourceLoc()));
if (!Result || Result->failedToLoad())
return nullptr;
return Result;
}
static int doPrintAST(const CompilerInvocation &InitInvok,