Make sure all failures to load module interfaces are diagnosed (#25636)

...specifically, diagnosed in the parent DiagnosticEngine. This not
only provides a better user experience, but makes sure that the
compiler exits with a nonzero exit code even if the module goes
unused.

rdar://problem/50789839
This commit is contained in:
Jordan Rose
2019-06-20 14:14:38 -07:00
committed by GitHub
parent de1c0cdd85
commit 3243f21280
9 changed files with 42 additions and 4 deletions

View File

@@ -18,6 +18,7 @@
#include "swift/AST/FileSystem.h"
#include "swift/AST/Module.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/Basic/Defer.h"
#include "swift/Basic/Lazy.h"
#include "swift/Basic/Platform.h"
#include "swift/Basic/STLExtras.h"
@@ -564,6 +565,17 @@ public:
SubInstance.createDependencyTracker(FEOpts.TrackSystemDeps);
SWIFT_DEFER {
// Make sure to emit a generic top-level error if a module fails to
// load. This is not only good for users; it also makes sure that we've
// emitted an error in the parent diagnostic engine, which is what
// determines whether the process exits with a proper failure status.
if (SubInstance.getASTContext().hadError()) {
diags.diagnose(diagnosticLoc, diag::serialization_load_failed,
moduleName);
}
};
if (SubInstance.setup(subInvocation)) {
SubError = true;
return;