ModuleInterface/Serialization: allow library authors to define a custom module version number

This allows library authors to pass down a project version number so that library users can conditionally
import that library based on the available version in the search paths.

Needed for rdar://73992299
This commit is contained in:
Xi Ge
2021-04-29 15:59:56 -07:00
parent dfec9e6434
commit fe5c7ef995
17 changed files with 79 additions and 6 deletions

View File

@@ -251,7 +251,12 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
// These fields were added later; be resilient against their absence.
switch (scratch.size()) {
default:
// Add new cases here, in descending order.
// Add new cases here, in descending order.
case 6:
case 5: {
result.userModuleVersion = llvm::VersionTuple(scratch[4], scratch[5]);
LLVM_FALLTHROUGH;
}
case 4:
if (scratch[3] != 0) {
result.compatibilityVersion =
@@ -1172,6 +1177,7 @@ ModuleFileSharedCore::ModuleFileSharedCore(
Name = info.name;
TargetTriple = info.targetTriple;
CompatibilityVersion = info.compatibilityVersion;
UserModuleVersion = info.userModuleVersion;
Bits.ArePrivateImportsEnabled = extInfo.arePrivateImportsEnabled();
Bits.IsSIB = extInfo.isSIB();
Bits.IsTestable = extInfo.isTestable();