[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

@@ -193,9 +193,20 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
}
}
// This field was added later; be resilient against its absence.
if (scratch.size() > 2) {
// These fields were added later; be resilient against their absence.
switch (scratch.size()) {
default:
// Add new cases here, in descending order.
case 4:
result.compatibilityVersion = blobData.substr(scratch[2]+1, scratch[3]);
LLVM_FALLTHROUGH;
case 3:
result.shortVersion = blobData.slice(0, scratch[2]);
LLVM_FALLTHROUGH;
case 2:
case 1:
case 0:
break;
}
versionSeen = true;
@@ -932,6 +943,7 @@ ModuleFile::ModuleFile(
}
Name = info.name;
TargetTriple = info.targetTriple;
CompatibilityVersion = info.compatibilityVersion;
hasValidControlBlock = true;
break;