mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Import incompatible targets when allowing errors
If allowing modules to be output with compile errors (-experimental-allow-module-with-errors), import targets regardless of whether they are compatible or not, and still output the module. The error diagnostic will still be output (preventing SILGen), but the AST will be available for various editor functionality.
This commit is contained in:
@@ -118,12 +118,14 @@ ModuleFile::ModuleFile(std::shared_ptr<const ModuleFileSharedCore> core)
|
||||
allocateBuffer(Identifiers, core->Identifiers);
|
||||
}
|
||||
|
||||
Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
|
||||
bool recoverFromIncompatibility) {
|
||||
PrettyStackTraceModuleFile stackEntry(*this);
|
||||
|
||||
assert(!hasError() && "error already detected; should not call this");
|
||||
assert(!FileContext && "already associated with an AST module");
|
||||
FileContext = file;
|
||||
Status status = Status::Valid;
|
||||
|
||||
ModuleDecl *M = file->getParentModule();
|
||||
if (M->getName().str() != Core->Name)
|
||||
@@ -134,12 +136,14 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
llvm::Triple moduleTarget(llvm::Triple::normalize(Core->TargetTriple));
|
||||
if (!areCompatibleArchitectures(moduleTarget, ctx.LangOpts.Target) ||
|
||||
!areCompatibleOSs(moduleTarget, ctx.LangOpts.Target)) {
|
||||
return error(Status::TargetIncompatible);
|
||||
}
|
||||
if (ctx.LangOpts.EnableTargetOSChecking &&
|
||||
!M->isResilient() &&
|
||||
isTargetTooNew(moduleTarget, ctx.LangOpts.Target)) {
|
||||
return error(Status::TargetTooNew);
|
||||
status = Status::TargetIncompatible;
|
||||
if (!recoverFromIncompatibility)
|
||||
return error(status);
|
||||
} else if (ctx.LangOpts.EnableTargetOSChecking && !M->isResilient() &&
|
||||
isTargetTooNew(moduleTarget, ctx.LangOpts.Target)) {
|
||||
status = Status::TargetTooNew;
|
||||
if (!recoverFromIncompatibility)
|
||||
return error(status);
|
||||
}
|
||||
|
||||
for (const auto &searchPath : Core->SearchPaths)
|
||||
@@ -240,7 +244,7 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
None);
|
||||
}
|
||||
|
||||
return Status::Valid;
|
||||
return status;
|
||||
}
|
||||
|
||||
bool ModuleFile::mayHaveDiagnosticsPointingAtBuffer() const {
|
||||
|
||||
Reference in New Issue
Block a user