Skip to content

Commit 0de7fb8

Browse files
authored
Merge pull request #32399 from hamishknight/salted-hash
Remove Type's hash_value function
2 parents ecaf9af + 6041d2a commit 0de7fb8

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

include/swift/AST/Requirement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Requirement {
142142
case RequirementKind::Conformance:
143143
case RequirementKind::Superclass:
144144
case RequirementKind::SameType:
145-
second = hash_value(requirement.getSecondType());
145+
second = hash_value(requirement.getSecondType().getPointer());
146146
break;
147147

148148
case RequirementKind::Layout:

include/swift/AST/Type.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,6 @@ class Type {
325325
/// Return the name of the type as a string, for use in diagnostics only.
326326
std::string getString(const PrintOptions &PO = PrintOptions()) const;
327327

328-
friend llvm::hash_code hash_value(Type type) {
329-
using llvm::hash_value;
330-
return hash_value(type.getPointer());
331-
}
332-
333328
/// Return the name of the type, adding parens in cases where
334329
/// appending or prepending text to the result would cause that text
335330
/// to be appended to only a portion of the returned type. For
@@ -502,6 +497,10 @@ class CanType : public Type {
502497
bool operator==(CanType T) const { return getPointer() == T.getPointer(); }
503498
bool operator!=(CanType T) const { return !operator==(T); }
504499

500+
friend llvm::hash_code hash_value(CanType T) {
501+
return llvm::hash_value(T.getPointer());
502+
}
503+
505504
bool operator<(CanType T) const { return getPointer() < T.getPointer(); }
506505
};
507506

include/swift/AST/Witness.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ struct TypeWitnessAndDecl {
206206
}
207207

208208
friend llvm::hash_code hash_value(const TypeWitnessAndDecl &owner) {
209-
return llvm::hash_combine(owner.witnessType,
209+
return llvm::hash_combine(owner.witnessType.getPointer(),
210210
owner.witnessDecl);
211211
}
212212

213213
friend bool operator==(const TypeWitnessAndDecl &lhs,
214214
const TypeWitnessAndDecl &rhs) {
215-
return lhs.witnessType->isEqual(rhs.witnessType) &&
215+
return lhs.witnessType.getPointer() == rhs.witnessType.getPointer() &&
216216
lhs.witnessDecl == rhs.witnessDecl;
217217
}
218218

0 commit comments

Comments
 (0)