mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user