Skip to content

Commit d0e0bff

Browse files
Merge pull request #14890 from adrian-prantl/djb
Force the DJB hash seed to 0 for compatibility with HashString.
2 parents 3a35fd4 + 0747d9a commit d0e0bff

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ namespace {
10551055
}
10561056

10571057
hash_value_type ComputeHash(key_type_ref key) {
1058-
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
1058+
// FIXME: DJB seed=0, audit whether the default seed could be used.
1059+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
10591060
}
10601061

10611062
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -1298,7 +1299,8 @@ namespace {
12981299
}
12991300

13001301
hash_value_type ComputeHash(internal_key_type key) {
1301-
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
1302+
// FIXME: DJB seed=0, audit whether the default seed could be used.
1303+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
13021304
}
13031305

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

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class DenseMapInfo<RawValueKey> {
169169
return DenseMapInfo<uint64_t>::getHashValue(k.intValue.v0) &
170170
DenseMapInfo<uint64_t>::getHashValue(k.intValue.v1);
171171
case RawValueKey::Kind::String:
172-
return llvm::djbHash(k.stringValue);
172+
// FIXME: DJB seed=0, audit whether the default seed could be used.
173+
return llvm::djbHash(k.stringValue, 0);
173174
case RawValueKey::Kind::Empty:
174175
case RawValueKey::Kind::Tombstone:
175176
return 0;

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class SILDeserializer::FuncTableInfo {
103103
external_key_type GetExternalKey(internal_key_type ID) { return ID; }
104104

105105
hash_value_type ComputeHash(internal_key_type key) {
106-
return llvm::djbHash(key);
106+
// FIXME: DJB seed=0, audit whether the default seed could be used.
107+
return llvm::djbHash(key, 0);
107108
}
108109

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

lib/Serialization/ModuleFile.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ class ModuleFile::DeclTableInfo {
318318

319319
hash_value_type ComputeHash(internal_key_type key) {
320320
if (key.first == DeclBaseName::Kind::Normal) {
321-
return llvm::djbHash(key.second);
321+
// FIXME: DJB seed=0, audit whether the default seed could be used.
322+
return llvm::djbHash(key.second, 0);
322323
} else {
323324
return (hash_value_type)key.first;
324325
}
@@ -380,7 +381,8 @@ class ModuleFile::ExtensionTableInfo {
380381
}
381382

382383
hash_value_type ComputeHash(internal_key_type key) {
383-
return llvm::djbHash(key);
384+
// FIXME: DJB seed=0, audit whether the default seed could be used.
385+
return llvm::djbHash(key, 0);
384386
}
385387

386388
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -438,8 +440,9 @@ class ModuleFile::LocalDeclTableInfo {
438440
return ID;
439441
}
440442

441-
hash_value_type ComputeHash(internal_key_type key) {
442-
return llvm::djbHash(key);
443+
hash_value_type ComputeHash(iternal_key_type key) {
444+
// FIXME: DJB seed=0, audit whether the default seed could be used.
445+
return llvm::djbHash(key, 0);
443446
}
444447

445448
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -476,7 +479,8 @@ class ModuleFile::NestedTypeDeclsTableInfo {
476479
}
477480

478481
hash_value_type ComputeHash(internal_key_type key) {
479-
return llvm::djbHash(key);
482+
// FIXME: DJB seed=0, audit whether the default seed could be used.
483+
return llvm::djbHash(key, 0);
480484
}
481485

482486
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -531,7 +535,8 @@ class ModuleFile::DeclMemberNamesTableInfo {
531535

532536
hash_value_type ComputeHash(internal_key_type key) {
533537
if (key.first == DeclBaseName::Kind::Normal) {
534-
return llvm::djbHash(key.second);
538+
// FIXME: DJB seed=0, audit whether the default seed could be used.
539+
return llvm::djbHash(key.second, 0);
535540
} else {
536541
return (hash_value_type)key.first;
537542
}
@@ -704,7 +709,8 @@ class ModuleFile::ObjCMethodTableInfo {
704709
}
705710

706711
hash_value_type ComputeHash(internal_key_type key) {
707-
return llvm::djbHash(key);
712+
// FIXME: DJB seed=0, audit whether the default seed could be used.
713+
return llvm::djbHash(key, 0);
708714
}
709715

710716
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -891,7 +897,8 @@ class ModuleFile::DeclCommentTableInfo {
891897

892898
hash_value_type ComputeHash(internal_key_type key) {
893899
assert(!key.empty());
894-
return llvm::djbHash(key);
900+
// FIXME: DJB seed=0, audit whether the default seed could be used.
901+
return llvm::djbHash(key, 0);
895902
}
896903

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

lib/Serialization/Serialization.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ namespace {
101101
switch (key.getKind()) {
102102
case DeclBaseName::Kind::Normal:
103103
assert(!key.empty());
104-
return llvm::djbHash(key.getIdentifier().str());
104+
// FIXME: DJB seed=0, audit whether the default seed could be used.
105+
return llvm::djbHash(key.getIdentifier().str(), 0);
105106
case DeclBaseName::Kind::Subscript:
106107
return static_cast<uint8_t>(DeclNameKind::Subscript);
107108
case DeclBaseName::Kind::Destructor:
@@ -168,7 +169,8 @@ namespace {
168169

169170
hash_value_type ComputeHash(key_type_ref key) {
170171
assert(!key.empty());
171-
return llvm::djbHash(key.str());
172+
// FIXME: DJB seed=0, audit whether the default seed could be used.
173+
return llvm::djbHash(key.str(), 0);
172174
}
173175

174176
int32_t getNameDataForBase(const NominalTypeDecl *nominal,
@@ -230,7 +232,8 @@ namespace {
230232

231233
hash_value_type ComputeHash(key_type_ref key) {
232234
assert(!key.empty());
233-
return llvm::djbHash(key);
235+
// FIXME: DJB seed=0, audit whether the default seed could be used.
236+
return llvm::djbHash(key, 0);
234237
}
235238

236239
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -270,7 +273,8 @@ namespace {
270273

271274
hash_value_type ComputeHash(key_type_ref key) {
272275
assert(!key.empty());
273-
return llvm::djbHash(key.str());
276+
// FIXME: DJB seed=0, audit whether the default seed could be used.
277+
return llvm::djbHash(key.str(), 0);
274278
}
275279

276280
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -313,7 +317,8 @@ namespace {
313317
switch (key.getKind()) {
314318
case DeclBaseName::Kind::Normal:
315319
assert(!key.empty());
316-
return llvm::djbHash(key.getIdentifier().str());
320+
// FIXME: DJB seed=0, audit whether the default seed could be used.
321+
return llvm::djbHash(key.getIdentifier().str(), 0);
317322
case DeclBaseName::Kind::Subscript:
318323
return static_cast<uint8_t>(DeclNameKind::Subscript);
319324
case DeclBaseName::Kind::Destructor:
@@ -4266,7 +4271,8 @@ class DeclCommentTableInfo {
42664271

42674272
hash_value_type ComputeHash(key_type_ref key) {
42684273
assert(!key.empty());
4269-
return llvm::djbHash(key);
4274+
// FIXME: DJB seed=0, audit whether the default seed could be used.
4275+
return llvm::djbHash(key, 0);
42704276
}
42714277

42724278
std::pair<unsigned, unsigned>
@@ -4637,7 +4643,8 @@ namespace {
46374643

46384644
hash_value_type ComputeHash(key_type_ref key) {
46394645
llvm::SmallString<32> scratch;
4640-
return llvm::djbHash(key.getString(scratch));
4646+
// FIXME: DJB seed=0, audit whether the default seed could be used.
4647+
return llvm::djbHash(key.getString(scratch), 0);
46414648
}
46424649

46434650
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,

lib/Serialization/SerializeSIL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ namespace {
111111

112112
hash_value_type ComputeHash(key_type_ref key) {
113113
assert(!key.empty());
114-
return llvm::djbHash(key.str());
114+
// FIXME: DJB seed=0, audit whether the default seed could be used.
115+
return llvm::djbHash(key.str(), 0);
115116
}
116117

117118
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,

0 commit comments

Comments
 (0)