mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user