From: Justin Lebar Date: Tue, 18 Oct 2016 17:50:39 +0000 (+0000) Subject: [ADT] Remove CachedHash. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=688c8347c994136971e0d0d47ec34d3d71376438;p=platform%2Fupstream%2Fllvm.git [ADT] Remove CachedHash. Nobody is using it. Differential Revision: https://reviews.llvm.org/D25630 llvm-svn: 284503 --- diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index 18c692e..a844ebc 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -30,36 +30,6 @@ struct DenseMapInfo { //static bool isEqual(const T &LHS, const T &RHS); }; -template struct CachedHash { - CachedHash(T Val) : Val(std::move(Val)) { - Hash = DenseMapInfo::getHashValue(Val); - } - CachedHash(T Val, unsigned Hash) : Val(std::move(Val)), Hash(Hash) {} - T Val; - unsigned Hash; -}; - -// Provide DenseMapInfo for all CachedHash. -template struct DenseMapInfo> { - static CachedHash getEmptyKey() { - T N = DenseMapInfo::getEmptyKey(); - return {N, 0}; - } - static CachedHash getTombstoneKey() { - T N = DenseMapInfo::getTombstoneKey(); - return {N, 0}; - } - static unsigned getHashValue(CachedHash Val) { - assert(!isEqual(Val, getEmptyKey()) && "Cannot hash the empty key!"); - assert(!isEqual(Val, getTombstoneKey()) && - "Cannot hash the tombstone key!"); - return Val.Hash; - } - static bool isEqual(CachedHash A, CachedHash B) { - return DenseMapInfo::isEqual(A.Val, B.Val); - } -}; - // Provide DenseMapInfo for all pointers. template struct DenseMapInfo { diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp index cbf1a44..80f0462 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -496,55 +496,6 @@ TEST(DenseMapCustomTest, StringRefTest) { EXPECT_EQ(42, M.lookup(StringRef("a", 0))); } -struct CachedHashTest { - unsigned Val; - unsigned *Counter = nullptr; - CachedHashTest(unsigned Val) : Val(Val) {} - CachedHashTest(unsigned Val, unsigned *Counter) - : Val(Val), Counter(Counter) {} -}; -} -namespace llvm { -template <> struct DenseMapInfo { - static CachedHashTest getEmptyKey() { return ~0; } - static CachedHashTest getTombstoneKey() { return ~0U - 1; } - static unsigned getHashValue(const CachedHashTest &X) { - ++*X.Counter; - return X.Val; - } - static bool isEqual(const CachedHashTest &LHS, const CachedHashTest &RHS) { - return LHS.Val == RHS.Val; - } -}; -} -namespace { - -TEST(DenseMapCustomTest, CachedHashTest) { - unsigned Counter = 0; - CachedHashTest Val(0, &Counter); - DenseMap Map; - - Map[Val] = 0; - ASSERT_EQ(1u, Counter); - - Map.reserve(64); - ASSERT_EQ(2u, Counter); -} - -// Like above, but now cache the hash. -TEST(DenseMapCustomTest, CachedHashTest2) { - unsigned Counter = 0; - CachedHashTest Val(0, &Counter); - typedef CachedHash Cached; - DenseMap Map; - - Map[Val] = 0; - ASSERT_EQ(1u, Counter); - - Map.reserve(64); - ASSERT_EQ(1u, Counter); -} - // Key traits that allows lookup with either an unsigned or char* key; // In the latter case, "a" == 0, "b" == 1 and so on. struct TestDenseMapInfo {