[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sam McCall
2018-06-20 13:56:25 +00:00
parent 1979d71cfc
commit 60b40e954b
+7
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