Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,13 @@ ProtocolConformanceDeserializer::readNormalProtocolConformanceXRef(
auto error = llvm::make_error<ConformanceXRefError>(
nominal->getName(), proto->getName(), module);

if (!MF.enableExtendedDeserializationRecovery()) {
error = llvm::handleErrors(std::move(error),
[&](const ConformanceXRefError &error) -> llvm::Error {
error.diagnose(&MF);
return llvm::make_error<ConformanceXRefError>(std::move(error));
});
}
// Diagnose the root error here.
error = llvm::handleErrors(std::move(error),
[&](const ConformanceXRefError &error) -> llvm::Error {
error.diagnose(&MF);
return llvm::make_error<ConformanceXRefError>(std::move(error));
});

return error;
}

Expand Down Expand Up @@ -8868,23 +8868,27 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
if (maybeConformance) {
reqConformances.push_back(maybeConformance.get());
} else if (getContext().LangOpts.EnableDeserializationRecovery) {
llvm::Error error = maybeConformance.takeError();
if (error.isA<ConformanceXRefError>() &&
!enableExtendedDeserializationRecovery()) {
// If a conformance is missing, mark the whole protocol conformance
// as invalid. Something is broken with the context.
conformance->setInvalid();

llvm::Error error = maybeConformance.takeError();
if (error.isA<ConformanceXRefError>()) {
// The error was printed along with creating the ConformanceXRefError.
// Print the note here explaining the side effect.
std::string typeStr = conformance->getType()->getString();
auto &diags = getContext().Diags;
diags.diagnose(getSourceLoc(),
diag::modularization_issue_conformance_xref_note,
typeStr, proto->getName());

consumeError(std::move(error));
conformance->setInvalid();
return;
}

// Leave it up to the centralized service to report other errors.
diagnoseAndConsumeError(std::move(error));
reqConformances.push_back(ProtocolConformanceRef::forInvalid());
return;
} else {
fatal(maybeConformance.takeError());
}
Expand Down