llvm.org GIT mirror llvm / eca64f0
Minor tweaks to the ImmutableList iterator interface. Added partial specialization of DenseMapInfo<T> for ImmutableList. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53485 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 11 years ago
1 changed file(s) with 26 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7272 // This constructor should normally only be called by ImmutableListFactory.
7373 // There may be cases, however, when one needs to extract the internal pointer
7474 // and reconstruct a list object from that pointer.
75 ImmutableList(ImmutableListImpl* x) : X(x) {}
75 ImmutableList(ImmutableListImpl* x = 0) : X(x) {}
7676
7777 ImmutableListImpl* getInternalPointer() const {
7878 return X;
8787 iterator& operator++() { L = L->getTail(); return *this; }
8888 bool operator==(const iterator& I) const { return L == I.L; }
8989 bool operator!=(const iterator& I) const { return L != I.L; }
90 ImmutableList operator*() const { return L; }
90 const value_type& operator*() const { return L->getHead(); }
91 ImmutableList getList() const { return L; }
9192 };
9293
9394 /// begin - Returns an iterator referring to the head of the list, or
185186 }
186187 };
187188
189 //===----------------------------------------------------------------------===//
190 // Partially-specialized Traits.
191 //===----------------------------------------------------------------------===//
192
193 template struct DenseMapInfo;
194 template struct DenseMapInfo > {
195 static inline ImmutableList getEmptyKey() {
196 return reinterpret_cast*>(-1);
197 }
198 static inline ImmutableList getTombstoneKey() {
199 return reinterpret_cast*>(-2);
200 }
201 static unsigned getHashValue(ImmutableList X) {
202 uintptr_t PtrVal = reinterpret_cast(X.getInternalPointer());
203 return (unsigned((uintptr_t)PtrVal) >> 4) ^
204 (unsigned((uintptr_t)PtrVal) >> 9);
205 }
206 static bool isEqual(ImmutableList X1, ImmutableList X2) {
207 return X1 == X2;
208 }
209 static bool isPod() { return true; }
210 };
211
188212 } // end llvm namespace
189213
190214 #endif