Merge pull request #34472 from bnbarham/benb/allow-errors-69815975

[Serialization] Add an option to output modules regardless of errors
This commit is contained in:
Ben Barham
2020-11-11 08:30:18 +10:00
committed by GitHub
21 changed files with 386 additions and 22 deletions

View File

@@ -1787,11 +1787,13 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
assert(ctx.getLoadedModules().begin()->second == Instance.getMainModule());
}
// Verify the AST for all the modules we've loaded.
ctx.verifyAllLoadedModules();
if (!opts.AllowModuleWithCompilerErrors) {
// Verify the AST for all the modules we've loaded.
ctx.verifyAllLoadedModules();
// Verify generic signatures if we've been asked to.
verifyGenericSignaturesIfNeeded(Invocation, ctx);
// Verify generic signatures if we've been asked to.
verifyGenericSignaturesIfNeeded(Invocation, ctx);
}
// Emit any additional outputs that we only need for a successful compilation.
// We don't want to unnecessarily delay getting any errors back to the user.
@@ -1913,7 +1915,8 @@ withSemanticAnalysis(CompilerInstance &Instance, FrontendObserver *observer,
(void)migrator::updateCodeAndEmitRemapIfNeeded(&Instance);
if (Instance.getASTContext().hadError())
if (Instance.getASTContext().hadError() &&
!opts.AllowModuleWithCompilerErrors)
return true;
return cont(Instance);
@@ -2096,7 +2099,8 @@ static bool performCompile(CompilerInstance &Instance,
if (Instance.hasASTContext() &&
FrontendOptions::doesActionPerformEndOfPipelineActions(Action)) {
performEndOfPipelineActions(Instance);
hadError |= Instance.getASTContext().hadError();
if (!opts.AllowModuleWithCompilerErrors)
hadError |= Instance.getASTContext().hadError();
}
return hadError;
}
@@ -2382,7 +2386,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
if (PSPs.haveModuleOrModuleDocOutputPaths()) {
if (Action == FrontendOptions::ActionType::MergeModules ||
Action == FrontendOptions::ActionType::EmitModuleOnly) {
return Context.hadError();
return Context.hadError() && !opts.AllowModuleWithCompilerErrors;
}
}
@@ -2400,7 +2404,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
// Check if we had any errors; if we did, don't proceed to IRGen.
if (Context.hadError())
return true;
return !opts.AllowModuleWithCompilerErrors;
runSILLoweringPasses(*SM);