From eca64f0980e3f686a36007c53272780119635337 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 11 Jul 2008 22:43:07 +0000 Subject: Minor tweaks to the ImmutableList iterator interface. Added partial specialization of DenseMapInfo for ImmutableList. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53485 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ImmutableList.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'include/llvm/ADT/ImmutableList.h') diff --git a/include/llvm/ADT/ImmutableList.h b/include/llvm/ADT/ImmutableList.h index 2219edd902..dd88023fd1 100644 --- a/include/llvm/ADT/ImmutableList.h +++ b/include/llvm/ADT/ImmutableList.h @@ -73,7 +73,7 @@ public: // This constructor should normally only be called by ImmutableListFactory. // There may be cases, however, when one needs to extract the internal pointer // and reconstruct a list object from that pointer. - ImmutableList(ImmutableListImpl* x) : X(x) {} + ImmutableList(ImmutableListImpl* x = 0) : X(x) {} ImmutableListImpl* getInternalPointer() const { return X; @@ -88,7 +88,8 @@ public: iterator& operator++() { L = L->getTail(); return *this; } bool operator==(const iterator& I) const { return L == I.L; } bool operator!=(const iterator& I) const { return L != I.L; } - ImmutableList operator*() const { return L; } + const value_type& operator*() const { return L->getHead(); } + ImmutableList getList() const { return L; } }; /// begin - Returns an iterator referring to the head of the list, or @@ -186,6 +187,29 @@ public: } }; +//===----------------------------------------------------------------------===// +// Partially-specialized Traits. +//===----------------------------------------------------------------------===// + +template struct DenseMapInfo; +template struct DenseMapInfo > { + static inline ImmutableList getEmptyKey() { + return reinterpret_cast*>(-1); + } + static inline ImmutableList getTombstoneKey() { + return reinterpret_cast*>(-2); + } + static unsigned getHashValue(ImmutableList X) { + uintptr_t PtrVal = reinterpret_cast(X.getInternalPointer()); + return (unsigned((uintptr_t)PtrVal) >> 4) ^ + (unsigned((uintptr_t)PtrVal) >> 9); + } + static bool isEqual(ImmutableList X1, ImmutableList X2) { + return X1 == X2; + } + static bool isPod() { return true; } +}; + } // end llvm namespace #endif -- cgit v1.2.3