Skip to content

Commit

Permalink
Merge pull request #32399 from hamishknight/salted-hash
Browse files Browse the repository at this point in the history
Remove Type's hash_value function
  • Loading branch information
CodaFi authored Jun 16, 2020
2 parents ecaf9af + 6041d2a commit 0de7fb8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/swift/AST/Requirement.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Requirement {
case RequirementKind::Conformance:
case RequirementKind::Superclass:
case RequirementKind::SameType:
second = hash_value(requirement.getSecondType());
second = hash_value(requirement.getSecondType().getPointer());
break;

case RequirementKind::Layout:
Expand Down
9 changes: 4 additions & 5 deletions include/swift/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,6 @@ class Type {
/// Return the name of the type as a string, for use in diagnostics only.
std::string getString(const PrintOptions &PO = PrintOptions()) const;

friend llvm::hash_code hash_value(Type type) {
using llvm::hash_value;
return hash_value(type.getPointer());
}

/// Return the name of the type, adding parens in cases where
/// appending or prepending text to the result would cause that text
/// to be appended to only a portion of the returned type. For
Expand Down Expand Up @@ -502,6 +497,10 @@ class CanType : public Type {
bool operator==(CanType T) const { return getPointer() == T.getPointer(); }
bool operator!=(CanType T) const { return !operator==(T); }

friend llvm::hash_code hash_value(CanType T) {
return llvm::hash_value(T.getPointer());
}

bool operator<(CanType T) const { return getPointer() < T.getPointer(); }
};

Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/Witness.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ struct TypeWitnessAndDecl {
}

friend llvm::hash_code hash_value(const TypeWitnessAndDecl &owner) {
return llvm::hash_combine(owner.witnessType,
return llvm::hash_combine(owner.witnessType.getPointer(),
owner.witnessDecl);
}

friend bool operator==(const TypeWitnessAndDecl &lhs,
const TypeWitnessAndDecl &rhs) {
return lhs.witnessType->isEqual(rhs.witnessType) &&
return lhs.witnessType.getPointer() == rhs.witnessType.getPointer() &&
lhs.witnessDecl == rhs.witnessDecl;
}

Expand Down

0 comments on commit 0de7fb8

Please sign in to comment.