[Frontend] Load standard libarary in CompilerInstance::setup

Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
This commit is contained in:
Alex Hoppen
2021-12-13 15:32:08 +01:00
parent 5a6341bd65
commit 63c31033fc
29 changed files with 224 additions and 105 deletions

View File

@@ -2247,8 +2247,9 @@ swift::ide::api::getSDKNodeRoot(SDKContext &SDKCtx,
// The PrintDiags is only responsible compiler errors, we should remove the
// consumer immediately after importing is done.
SWIFT_DEFER { CI.getDiags().removeConsumer(PrintDiags); };
if (CI.setup(Invocation)) {
llvm::errs() << "Failed to setup the compiler instance\n";
std::string InstanceSetupError;
if (CI.setup(Invocation, InstanceSetupError)) {
llvm::errs() << InstanceSetupError << '\n';
return nullptr;
}