Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/ClangImporter/SwiftLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,8 @@ namespace {
}

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

std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
Expand Down Expand Up @@ -1298,7 +1299,8 @@ namespace {
}

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

static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class DenseMapInfo<RawValueKey> {
return DenseMapInfo<uint64_t>::getHashValue(k.intValue.v0) &
DenseMapInfo<uint64_t>::getHashValue(k.intValue.v1);
case RawValueKey::Kind::String:
return llvm::djbHash(k.stringValue);
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(k.stringValue, 0);
case RawValueKey::Kind::Empty:
case RawValueKey::Kind::Tombstone:
return 0;
Expand Down
3 changes: 2 additions & 1 deletion lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class SILDeserializer::FuncTableInfo {
external_key_type GetExternalKey(internal_key_type ID) { return ID; }

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

static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
Expand Down
23 changes: 15 additions & 8 deletions lib/Serialization/ModuleFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class ModuleFile::DeclTableInfo {

hash_value_type ComputeHash(internal_key_type key) {
if (key.first == DeclBaseName::Kind::Normal) {
return llvm::djbHash(key.second);
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.second, 0);
} else {
return (hash_value_type)key.first;
}
Expand Down Expand Up @@ -380,7 +381,8 @@ class ModuleFile::ExtensionTableInfo {
}

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

static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
Expand Down Expand Up @@ -438,8 +440,9 @@ class ModuleFile::LocalDeclTableInfo {
return ID;
}

hash_value_type ComputeHash(internal_key_type key) {
return llvm::djbHash(key);
hash_value_type ComputeHash(iternal_key_type key) {
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key, 0);
}

static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
Expand Down Expand Up @@ -476,7 +479,8 @@ class ModuleFile::NestedTypeDeclsTableInfo {
}

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

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

hash_value_type ComputeHash(internal_key_type key) {
if (key.first == DeclBaseName::Kind::Normal) {
return llvm::djbHash(key.second);
// FIXME: DJB seed=0, audit whether the default seed could be used.
return llvm::djbHash(key.second, 0);
} else {
return (hash_value_type)key.first;
}
Expand Down Expand Up @@ -704,7 +709,8 @@ class ModuleFile::ObjCMethodTableInfo {
}

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

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

hash_value_type ComputeHash(internal_key_type 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);
}

static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
Expand Down
21 changes: 14 additions & 7 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -4266,7 +4271,8 @@ class DeclCommentTableInfo {

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>
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion lib/Serialization/SerializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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,
Expand Down