Skip to content

Commit 11e206a

Browse files
committed
Remove explicit seeds from string hashes that are compiler-dependent
The one for enum raw value checking isn't serialized anywhere, so we can use normal in-process hashing. The ones in the Clang importer's lookup tables are serialized, but the lookup table is already only valid for a particular compiler build anyway (it goes into a Clang PCM, which has the full compiler version in its cache key).
1 parent 016acf3 commit 11e206a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,7 @@ namespace {
10901090
}
10911091

10921092
hash_value_type ComputeHash(key_type_ref key) {
1093-
// FIXME: DJB seed=0, audit whether the default seed could be used.
1094-
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
1093+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
10951094
}
10961095

10971096
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -1340,8 +1339,7 @@ namespace {
13401339
}
13411340

13421341
hash_value_type ComputeHash(internal_key_type key) {
1343-
// FIXME: DJB seed=0, audit whether the default seed could be used.
1344-
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
1342+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
13451343
}
13461344

13471345
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct RawValueKey {
9797
// FIXME: doesn't accommodate >64-bit or signed raw integer or float values.
9898
union {
9999
StringRef stringValue;
100-
uint32_t charValue;
101100
IntValueTy intValue;
102101
FloatValueTy floatValue;
103102
};
@@ -181,8 +180,7 @@ class DenseMapInfo<RawValueKey> {
181180
return DenseMapInfo<uint64_t>::getHashValue(k.intValue.v0) &
182181
DenseMapInfo<uint64_t>::getHashValue(k.intValue.v1);
183182
case RawValueKey::Kind::String:
184-
// FIXME: DJB seed=0, audit whether the default seed could be used.
185-
return llvm::djbHash(k.stringValue, 0);
183+
return DenseMapInfo<StringRef>::getHashValue(k.stringValue);
186184
case RawValueKey::Kind::Empty:
187185
case RawValueKey::Kind::Tombstone:
188186
return 0;

0 commit comments

Comments
 (0)