[ADT] Allow llvm::hash_code as DenseMap key.

Summary:
This is useful when hash collisions are unlikely and acceptable, e.g. in clangd
completion ranking.

Reviewers: ioeric

Subscribers: ilya-biryukov, llvm-commits

Differential Revision: https://reviews.llvm.org/D48361

llvm-svn: 335125
This commit is contained in:
Sam McCall 2018-06-20 13:56:25 +00:00
parent d8b780dcd6
commit 03953093f9
1 changed files with 7 additions and 0 deletions

View File

@ -262,6 +262,13 @@ template <typename T> struct DenseMapInfo<ArrayRef<T>> {
}
};
template <> struct DenseMapInfo<hash_code> {
static inline hash_code getEmptyKey() { return hash_code(-1); }
static inline hash_code getTombstoneKey() { return hash_code(-2); }
static unsigned getHashValue(hash_code val) { return val; }
static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
};
} // end namespace llvm
#endif // LLVM_ADT_DENSEMAPINFO_H