[serialization] Reject modules with a different version number.

From now on, /any/ changes to SIL or AST serialization must increment
VERSION_MINOR in ModuleFormat.h.

The original intent of VERSION_MAJOR/VERSION_MINOR was that VERSION_MAJOR
would only increment when backwards-incompatible changes are introduced,
and VERSION_MINOR merely indicates whether to expect additional information.
However, the module infrastructure currently isn't forgiving enough to accept
even backwards-compatible changes to the record schemas, and the SIL
serialization design might not be compatible with that at all.

So for now, treat any version number 0.x as incompatible with any other 0.y.
We can bump to 1 when we hit stability.

<rdar://problem/15494343>

Swift SVN r13841
This commit is contained in:
Jordan Rose
2014-02-12 21:33:45 +00:00
parent dd4db41048
commit f7977e6807
5 changed files with 25 additions and 6 deletions

View File

@@ -94,8 +94,19 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
uint16_t versionMajor = scratch[0];
if (versionMajor > VERSION_MAJOR)
result = ModuleStatus::FormatTooNew;
else if (versionMajor < VERSION_MAJOR)
result = ModuleStatus::FormatTooOld;
else
result = ModuleStatus::Valid;
// Major version 0 does not have stable minor versions.
if (versionMajor == 0) {
uint16_t versionMinor = scratch[1];
if (versionMinor != VERSION_MINOR)
result = versionMinor < VERSION_MINOR ? ModuleStatus::FormatTooOld
: ModuleStatus::FormatTooNew;
}
versionSeen = true;
}
break;