[Serialization] When crashing, note if mix-and-match may be to blame.

That is, a Swift 3 target imported into a Swift 4 context or vice
versa. This requires serializing the compatibility mode explicitly,
instead of including it in the textual version string that's only
for debugging.
This commit is contained in:
Jordan Rose
2017-04-07 17:20:35 -07:00
parent 2e8179d43a
commit 7e8d642e8e
10 changed files with 68 additions and 12 deletions

View File

@@ -344,6 +344,17 @@ static bool skipRecord(llvm::BitstreamCursor &cursor, unsigned recordKind) {
void ModuleFile::fatal(llvm::Error error) {
if (FileContext) {
getContext().Diags.diagnose(SourceLoc(), diag::serialization_fatal, Name);
if (!CompatibilityVersion.empty()) {
SmallString<16> buffer;
llvm::raw_svector_ostream out(buffer);
out << getContext().LangOpts.EffectiveLanguageVersion;
if (out.str() != CompatibilityVersion) {
getContext().Diags.diagnose(
SourceLoc(), diag::serialization_compatibility_version_mismatch,
out.str(), Name, CompatibilityVersion);
}
}
}
logAllUnhandledErrors(std::move(error), llvm::errs(),