Force the DJB hash seed to 0 for compatibility with HashString.

The obsolete llvm::HashString() was equivalent to
llvm::djbHash(seed=0) and was removed from llvm. This patch replaces
all occurences of llvm::HashString() with llvm::djbHash(seed=0), no
functional change.

The default seed of llvm::djbHash() is supposed to yield a higher
quality result that using seed=0, but changing it looks like it
affects the ordering of SIL serialization.
This commit is contained in:
Adrian Prantl
2018-02-28 14:10:25 -08:00
parent b7eb3bfeee
commit 0747d9a339
6 changed files with 39 additions and 20 deletions

View File

@@ -101,7 +101,8 @@ namespace {
switch (key.getKind()) {
case DeclBaseName::Kind::Normal:
assert(!key.empty());
return llvm::djbHash(key.getIdentifier().str());
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.getIdentifier().str(), 0);
case DeclBaseName::Kind::Subscript:
return static_cast<uint8_t>(DeclNameKind::Subscript);
case DeclBaseName::Kind::Destructor:
@@ -168,7 +169,8 @@ namespace {
hash_value_type ComputeHash(key_type_ref key) {
assert(!key.empty());
return llvm::djbHash(key.str());
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.str(), 0);
}
int32_t getNameDataForBase(const NominalTypeDecl *nominal,
@@ -230,7 +232,8 @@ namespace {
hash_value_type ComputeHash(key_type_ref key) {
assert(!key.empty());
return llvm::djbHash(key);
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key, 0);
}
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -270,7 +273,8 @@ namespace {
hash_value_type ComputeHash(key_type_ref key) {
assert(!key.empty());
return llvm::djbHash(key.str());
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.str(), 0);
}
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -313,7 +317,8 @@ namespace {
switch (key.getKind()) {
case DeclBaseName::Kind::Normal:
assert(!key.empty());
return llvm::djbHash(key.getIdentifier().str());
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.getIdentifier().str(), 0);
case DeclBaseName::Kind::Subscript:
return static_cast<uint8_t>(DeclNameKind::Subscript);
case DeclBaseName::Kind::Destructor:
@@ -4266,7 +4271,8 @@ public:
hash_value_type ComputeHash(key_type_ref key) {
assert(!key.empty());
return llvm::djbHash(key);
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key, 0);
}
std::pair<unsigned, unsigned>
@@ -4637,7 +4643,8 @@ namespace {
hash_value_type ComputeHash(key_type_ref key) {
llvm::SmallString<32> scratch;
return llvm::djbHash(key.getString(scratch));
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.getString(scratch), 0);
}
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,