Skip to content

Commit f7fd6d4

Browse files
committed
Clang importer: use lookup table version number in the module file extension hash.
We were verifying the Swift full version information from the module file extension metadata for the Swift name lookup tables, but not actually putting it in the hash, which meant that having an older module cache around would cause spurious failures when Swift name lookup tables were enabled. Instead, use just the major/minor version numbers of the lookup tables. When the lookup table format or contents of the lookup table change, we'll bump the version number.
1 parent e56bc1b commit f7fd6d4

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,12 +4464,11 @@ ClangImporter::Implementation::createExtensionReader(
44644464
clang::serialization::ModuleFile &mod,
44654465
const llvm::BitstreamCursor &stream)
44664466
{
4467-
// Make sure we have a compatible block.
4467+
// Make sure we have a compatible block. Since these values are part
4468+
// of the hash, it should never be wrong.
44684469
assert(metadata.BlockName == "swift.lookup");
4469-
if (metadata.MajorVersion != SWIFT_LOOKUP_TABLE_VERSION_MAJOR ||
4470-
metadata.MinorVersion != SWIFT_LOOKUP_TABLE_VERSION_MINOR ||
4471-
metadata.UserInfo != version::getSwiftFullVersion())
4472-
return nullptr;
4470+
assert(metadata.MajorVersion == SWIFT_LOOKUP_TABLE_VERSION_MAJOR);
4471+
assert(metadata.MinorVersion == SWIFT_LOOKUP_TABLE_VERSION_MINOR);
44734472

44744473
// Check whether we already have an entry in the set of lookup tables.
44754474
auto &entry = LookupTables[mod.ModuleName];

lib/ClangImporter/SwiftLookupTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MAJOR = 1;
5050
/// Lookup table major version number.
5151
///
5252
/// When the format changes IN ANY WAY, this number should be incremented.
53-
const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 0;
53+
const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 1;
5454

5555
/// A lookup table that maps Swift names to the set of Clang
5656
/// declarations with that particular name.

0 commit comments

Comments
 (0)