@@ -1458,7 +1458,7 @@ ModuleFile::getSubstitutionMapChecked(serialization::SubstitutionMapID id) {
1458
1458
for (auto typeID : replacementTypeIDs) {
1459
1459
auto typeOrError = getTypeChecked (typeID);
1460
1460
if (!typeOrError) {
1461
- consumeError (typeOrError.takeError ());
1461
+ diagnoseAndConsumeError (typeOrError.takeError ());
1462
1462
continue ;
1463
1463
}
1464
1464
replacementTypes.push_back (typeOrError.get ());
@@ -1713,7 +1713,7 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
1713
1713
if (maybeType.errorIsA <FatalDeserializationError>())
1714
1714
return maybeType.takeError ();
1715
1715
// FIXME: Don't throw away the inner error's information.
1716
- consumeError (maybeType.takeError ());
1716
+ diagnoseAndConsumeError (maybeType.takeError ());
1717
1717
return llvm::make_error<XRefError>(" couldn't decode type" ,
1718
1718
pathTrace, name);
1719
1719
}
@@ -2083,7 +2083,7 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
2083
2083
return maybeType.takeError ();
2084
2084
2085
2085
// FIXME: Don't throw away the inner error's information.
2086
- consumeError (maybeType.takeError ());
2086
+ diagnoseAndConsumeError (maybeType.takeError ());
2087
2087
return llvm::make_error<XRefError>(" couldn't decode type" ,
2088
2088
pathTrace, memberName);
2089
2089
}
@@ -2922,7 +2922,7 @@ class DeclDeserializer {
2922
2922
2923
2923
auto maybeType = MF.getTypeChecked (typeID);
2924
2924
if (!maybeType) {
2925
- llvm::consumeError (maybeType.takeError ());
2925
+ MF. diagnoseAndConsumeError (maybeType.takeError ());
2926
2926
continue ;
2927
2927
}
2928
2928
inheritedTypes.push_back (
@@ -3248,10 +3248,10 @@ class DeclDeserializer {
3248
3248
return overriddenOrError.takeError ();
3249
3249
} else if (MF.allowCompilerErrors ()) {
3250
3250
// Drop overriding relationship when allowing errors.
3251
- llvm::consumeError (overriddenOrError.takeError ());
3251
+ MF. diagnoseAndConsumeError (overriddenOrError.takeError ());
3252
3252
overridden = nullptr ;
3253
3253
} else {
3254
- llvm::consumeError (overriddenOrError.takeError ());
3254
+ MF. diagnoseAndConsumeError (overriddenOrError.takeError ());
3255
3255
if (overriddenAffectsABI || !ctx.LangOpts .EnableDeserializationRecovery ) {
3256
3256
return llvm::make_error<OverrideError>(name, errorFlags,
3257
3257
numVTableEntries);
@@ -3395,7 +3395,7 @@ class DeclDeserializer {
3395
3395
if (overridden.errorIsA <FatalDeserializationError>())
3396
3396
return overridden.takeError ();
3397
3397
3398
- llvm::consumeError (overridden.takeError ());
3398
+ MF. diagnoseAndConsumeError (overridden.takeError ());
3399
3399
3400
3400
return llvm::make_error<OverrideError>(
3401
3401
name, getErrorFlags (), numVTableEntries);
@@ -3507,7 +3507,7 @@ class DeclDeserializer {
3507
3507
3508
3508
// FIXME: This is actually wrong. We can't just drop stored properties
3509
3509
// willy-nilly if the struct is @frozen.
3510
- consumeError (backingDecl.takeError ());
3510
+ MF. diagnoseAndConsumeError (backingDecl.takeError ());
3511
3511
return var;
3512
3512
}
3513
3513
@@ -3724,15 +3724,15 @@ class DeclDeserializer {
3724
3724
overridden = overriddenOrError.get ();
3725
3725
} else {
3726
3726
if (overriddenAffectsABI || !ctx.LangOpts .EnableDeserializationRecovery ) {
3727
- llvm::consumeError (overriddenOrError.takeError ());
3727
+ MF. diagnoseAndConsumeError (overriddenOrError.takeError ());
3728
3728
return llvm::make_error<OverrideError>(name, errorFlags,
3729
3729
numVTableEntries);
3730
3730
}
3731
3731
// Pass through deserialization errors.
3732
3732
if (overriddenOrError.errorIsA <FatalDeserializationError>())
3733
3733
return overriddenOrError.takeError ();
3734
3734
3735
- llvm::consumeError (overriddenOrError.takeError ());
3735
+ MF. diagnoseAndConsumeError (overriddenOrError.takeError ());
3736
3736
overridden = nullptr ;
3737
3737
}
3738
3738
@@ -4054,7 +4054,7 @@ class DeclDeserializer {
4054
4054
return pattern.takeError ();
4055
4055
4056
4056
// Silently drop the pattern...
4057
- llvm::consumeError (pattern.takeError ());
4057
+ MF. diagnoseAndConsumeError (pattern.takeError ());
4058
4058
// ...but continue to read any further patterns we're expecting.
4059
4059
continue ;
4060
4060
}
@@ -4572,7 +4572,7 @@ class DeclDeserializer {
4572
4572
// Pass through deserialization errors.
4573
4573
if (overridden.errorIsA <FatalDeserializationError>())
4574
4574
return overridden.takeError ();
4575
- llvm::consumeError (overridden.takeError ());
4575
+ MF. diagnoseAndConsumeError (overridden.takeError ());
4576
4576
4577
4577
DeclDeserializationError::Flags errorFlags;
4578
4578
return llvm::make_error<OverrideError>(
@@ -5096,7 +5096,7 @@ llvm::Error DeclDeserializer::deserializeCustomAttrs() {
5096
5096
// is safe to drop when it can't be deserialized.
5097
5097
// rdar://problem/56599179. When allowing errors we're doing a best
5098
5098
// effort to create a module, so ignore in that case as well.
5099
- consumeError (deserialized.takeError ());
5099
+ MF. diagnoseAndConsumeError (deserialized.takeError ());
5100
5100
} else
5101
5101
return deserialized.takeError ();
5102
5102
} else if (!deserialized.get () && MF.allowCompilerErrors ()) {
@@ -6028,7 +6028,7 @@ Expected<Type> DESERIALIZE_TYPE(NAME_ALIAS_TYPE)(
6028
6028
6029
6029
// We're going to recover by falling back to the underlying type, so
6030
6030
// just ignore the error.
6031
- llvm::consumeError (aliasOrError.takeError ());
6031
+ MF. diagnoseAndConsumeError (aliasOrError.takeError ());
6032
6032
}
6033
6033
6034
6034
if (!alias || !alias->getDeclaredInterfaceType ()->isEqual (underlyingType)) {
@@ -7355,7 +7355,7 @@ llvm::Error ModuleFile::consumeExpectedError(llvm::Error &&error) {
7355
7355
if (error.isA <XRefNonLoadedModuleError>() ||
7356
7356
error.isA <UnsafeDeserializationError>() ||
7357
7357
error.isA <ModularizationError>()) {
7358
- consumeError (std::move (error));
7358
+ diagnoseAndConsumeError (std::move (error));
7359
7359
return llvm::Error::success ();
7360
7360
}
7361
7361
@@ -7369,7 +7369,7 @@ llvm::Error ModuleFile::consumeExpectedError(llvm::Error &&error) {
7369
7369
if (TE->underlyingReasonIsA <XRefNonLoadedModuleError>() ||
7370
7370
TE->underlyingReasonIsA <UnsafeDeserializationError>() ||
7371
7371
TE->underlyingReasonIsA <ModularizationError>()) {
7372
- consumeError (std::move (errorInfo));
7372
+ diagnoseAndConsumeError (std::move (errorInfo));
7373
7373
return llvm::Error::success ();
7374
7374
}
7375
7375
@@ -7379,6 +7379,11 @@ llvm::Error ModuleFile::consumeExpectedError(llvm::Error &&error) {
7379
7379
return std::move (error);
7380
7380
}
7381
7381
7382
+ void ModuleFile::diagnoseAndConsumeError (llvm::Error error) const {
7383
+
7384
+ consumeError (std::move (error));
7385
+ }
7386
+
7382
7387
namespace {
7383
7388
class LazyConformanceLoaderInfo final
7384
7389
: llvm::TrailingObjects<LazyConformanceLoaderInfo,
@@ -7447,7 +7452,7 @@ ModuleFile::loadAllConformances(const Decl *D, uint64_t contextData,
7447
7452
// Ignore if allowing errors, it's just doing a best effort to produce
7448
7453
// *some* module anyway.
7449
7454
if (allowCompilerErrors ())
7450
- consumeError (std::move (unconsumedError));
7455
+ diagnoseAndConsumeError (std::move (unconsumedError));
7451
7456
else
7452
7457
fatal (std::move (unconsumedError));
7453
7458
}
@@ -7537,7 +7542,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7537
7542
if (maybeConformance) {
7538
7543
reqConformances.push_back (maybeConformance.get ());
7539
7544
} else if (allowCompilerErrors ()) {
7540
- consumeError (maybeConformance.takeError ());
7545
+ diagnoseAndConsumeError (maybeConformance.takeError ());
7541
7546
reqConformances.push_back (ProtocolConformanceRef::forInvalid ());
7542
7547
} else {
7543
7548
fatal (maybeConformance.takeError ());
@@ -7605,7 +7610,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7605
7610
second = *secondOrError;
7606
7611
} else if (getContext ().LangOpts .EnableDeserializationRecovery ) {
7607
7612
second = ErrorType::get (getContext ());
7608
- consumeError (secondOrError.takeError ());
7613
+ diagnoseAndConsumeError (secondOrError.takeError ());
7609
7614
} else {
7610
7615
fatal (secondOrError.takeError ());
7611
7616
}
@@ -7615,7 +7620,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7615
7620
third = cast_or_null<TypeDecl>(*thirdOrError);
7616
7621
} else if (getContext ().LangOpts .EnableDeserializationRecovery ) {
7617
7622
third = nullptr ;
7618
- consumeError (thirdOrError.takeError ());
7623
+ diagnoseAndConsumeError (thirdOrError.takeError ());
7619
7624
} else {
7620
7625
fatal (thirdOrError.takeError ());
7621
7626
}
@@ -7656,7 +7661,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7656
7661
if (deserializedReq) {
7657
7662
req = cast_or_null<ValueDecl>(*deserializedReq);
7658
7663
} else if (getContext ().LangOpts .EnableDeserializationRecovery ) {
7659
- consumeError (deserializedReq.takeError ());
7664
+ diagnoseAndConsumeError (deserializedReq.takeError ());
7660
7665
req = nullptr ;
7661
7666
needToFillInOpaqueValueWitnesses = true ;
7662
7667
} else {
@@ -7673,7 +7678,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7673
7678
// In that case, we want the conformance to still be available, but
7674
7679
// we can't make use of the relationship to the underlying decl.
7675
7680
} else if (getContext ().LangOpts .EnableDeserializationRecovery ) {
7676
- consumeError (deserializedWitness.takeError ());
7681
+ diagnoseAndConsumeError (deserializedWitness.takeError ());
7677
7682
isOpaque = true ;
7678
7683
witness = nullptr ;
7679
7684
} else {
@@ -7706,7 +7711,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
7706
7711
if (witnessSubstitutions.errorIsA <XRefNonLoadedModuleError>() ||
7707
7712
witnessSubstitutions.errorIsA <UnsafeDeserializationError>() ||
7708
7713
allowCompilerErrors ()) {
7709
- consumeError (witnessSubstitutions.takeError ());
7714
+ diagnoseAndConsumeError (witnessSubstitutions.takeError ());
7710
7715
isOpaque = true ;
7711
7716
}
7712
7717
else
0 commit comments