Skip to content

Remove Type's hash_value function #32399

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 2 commits into from
Jun 16, 2020
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
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