@@ -1787,11 +1787,13 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
17871787 assert (ctx.getLoadedModules ().begin ()->second == Instance.getMainModule ());
17881788 }
17891789
1790- // Verify the AST for all the modules we've loaded.
1791- ctx.verifyAllLoadedModules ();
1790+ if (!opts.AllowModuleWithCompilerErrors ) {
1791+ // Verify the AST for all the modules we've loaded.
1792+ ctx.verifyAllLoadedModules ();
17921793
1793- // Verify generic signatures if we've been asked to.
1794- verifyGenericSignaturesIfNeeded (Invocation, ctx);
1794+ // Verify generic signatures if we've been asked to.
1795+ verifyGenericSignaturesIfNeeded (Invocation, ctx);
1796+ }
17951797
17961798 // Emit any additional outputs that we only need for a successful compilation.
17971799 // We don't want to unnecessarily delay getting any errors back to the user.
@@ -1913,7 +1915,8 @@ withSemanticAnalysis(CompilerInstance &Instance, FrontendObserver *observer,
19131915
19141916 (void )migrator::updateCodeAndEmitRemapIfNeeded (&Instance);
19151917
1916- if (Instance.getASTContext ().hadError ())
1918+ if (Instance.getASTContext ().hadError () &&
1919+ !opts.AllowModuleWithCompilerErrors )
19171920 return true ;
19181921
19191922 return cont (Instance);
@@ -2096,7 +2099,8 @@ static bool performCompile(CompilerInstance &Instance,
20962099 if (Instance.hasASTContext () &&
20972100 FrontendOptions::doesActionPerformEndOfPipelineActions (Action)) {
20982101 performEndOfPipelineActions (Instance);
2099- hadError |= Instance.getASTContext ().hadError ();
2102+ if (!opts.AllowModuleWithCompilerErrors )
2103+ hadError |= Instance.getASTContext ().hadError ();
21002104 }
21012105 return hadError;
21022106}
@@ -2382,7 +2386,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
23822386 if (PSPs.haveModuleOrModuleDocOutputPaths ()) {
23832387 if (Action == FrontendOptions::ActionType::MergeModules ||
23842388 Action == FrontendOptions::ActionType::EmitModuleOnly) {
2385- return Context.hadError ();
2389+ return Context.hadError () && !opts. AllowModuleWithCompilerErrors ;
23862390 }
23872391 }
23882392
@@ -2400,7 +2404,7 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
24002404
24012405 // Check if we had any errors; if we did, don't proceed to IRGen.
24022406 if (Context.hadError ())
2403- return true ;
2407+ return !opts. AllowModuleWithCompilerErrors ;
24042408
24052409 runSILLoweringPasses (*SM);
24062410
0 commit comments