[serialization] Diagnose loading modules from older Swifts.

...with a better message than the generic "older version of the
compiler" one, when we know it's actually a different version of
Swift proper.

This still uses the same internal module version numbers to check
if the module is compatible; the presentation of language versions
is a diagnostic thing only.

Speaking of module version numbers, this deliberately does NOT
increment VERSION_MINOR; it's implemented in a backwards-compatible
way.

This will only work going forwards, of course; all existing modules
don't have a short version string, and I don't feel comfortable
assuming all older modules we might encounter are "Swift 2.2".

rdar://problem/25680392
This commit is contained in:
Jordan Rose
2016-04-29 14:47:46 -07:00
parent 22cef3ebd1
commit 8f820dea2b
18 changed files with 99 additions and 84 deletions

View File

@@ -190,6 +190,11 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
}
}
// This field was added later; be resilient against its absence.
if (scratch.size() > 2) {
result.shortVersion = blobData.slice(0, scratch[2]);
}
versionSeen = true;
break;
}
@@ -743,7 +748,7 @@ static bool isTargetTooNew(const llvm::Triple &moduleTarget,
ModuleFile::ModuleFile(
std::unique_ptr<llvm::MemoryBuffer> moduleInputBuffer,
std::unique_ptr<llvm::MemoryBuffer> moduleDocInputBuffer,
bool isFramework,
bool isFramework, serialization::ValidationInfo &info,
serialization::ExtendedValidationInfo *extInfo)
: ModuleInputBuffer(std::move(moduleInputBuffer)),
ModuleDocInputBuffer(std::move(moduleDocInputBuffer)),
@@ -775,7 +780,7 @@ ModuleFile::ModuleFile(
case CONTROL_BLOCK_ID: {
cursor.EnterSubBlock(CONTROL_BLOCK_ID);
auto info = validateControlBlock(cursor, scratch, extInfo);
info = validateControlBlock(cursor, scratch, extInfo);
if (info.status != Status::Valid) {
error(info.status);
return;