@@ -232,21 +232,15 @@ void ExtensionError::diagnose(const ModuleFile *MF) const {
232232 diag::modularization_issue_side_effect_extension_error);
233233}
234234
235- llvm::Error ModuleFile::diagnoseFatal (llvm::Error error) const {
236-
237- auto &ctx = getContext ();
238- if (FileContext) {
239- if (ctx.LangOpts .EnableDeserializationRecovery ) {
240- // Attempt to report relevant errors as diagnostics.
241- // At this time, only ModularizationErrors are reported directly. They
242- // can get here either directly or as underlying causes to a TypeError or
243- // and ExtensionError.
244- auto handleModularizationError =
245- [&](const ModularizationError &modularError) -> llvm::Error {
246- modularError.diagnose (this );
247- return llvm::Error::success ();
248- };
249- error = llvm::handleErrors (std::move (error),
235+ llvm::Error
236+ ModuleFile::diagnoseModularizationError (llvm::Error error,
237+ DiagnosticBehavior limit) const {
238+ auto handleModularizationError =
239+ [&](const ModularizationError &modularError) -> llvm::Error {
240+ modularError.diagnose (this , limit);
241+ return llvm::Error::success ();
242+ };
243+ llvm::Error outError = llvm::handleErrors (std::move (error),
250244 handleModularizationError,
251245 [&](TypeError &typeError) -> llvm::Error {
252246 if (typeError.diagnoseUnderlyingReason (handleModularizationError)) {
@@ -263,6 +257,16 @@ llvm::Error ModuleFile::diagnoseFatal(llvm::Error error) const {
263257 return llvm::make_error<ExtensionError>(std::move (extError));
264258 });
265259
260+ return outError;
261+ }
262+
263+ llvm::Error ModuleFile::diagnoseFatal (llvm::Error error) const {
264+
265+ auto &ctx = getContext ();
266+ if (FileContext) {
267+ if (ctx.LangOpts .EnableDeserializationRecovery ) {
268+ error = diagnoseModularizationError (std::move (error));
269+
266270 // If no error is left, it was reported as a diagnostic. There's no
267271 // need to crash.
268272 if (!error)
0 commit comments