From: Chris Lattner Date: Sun, 29 Mar 2009 00:18:42 +0000 (+0000) Subject: teach SmallPtrSet that PointerIntPair is "basically a pointer". X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4d4177b9b3ab634e852be1c0a7565a4ec1c7df93;p=oota-llvm.git teach SmallPtrSet that PointerIntPair is "basically a pointer". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h index 8b476199d38..92259298efc 100644 --- a/include/llvm/ADT/PointerIntPair.h +++ b/include/llvm/ADT/PointerIntPair.h @@ -21,6 +21,8 @@ namespace llvm { template struct DenseMapInfo; +template +class PointerLikeTypeInfo; /// PointerIntPair - This class implements a pair of a pointer and small /// integer. It is designed to represent this in the space required by one @@ -62,6 +64,10 @@ public: void *getOpaqueValue() const { return reinterpret_cast(Value); } void setFromOpaqueValue(void *Val) { Value = reinterpret_cast(Val);} + static PointerIntPair getFromOpaqueValue(void *V) { + PointerIntPair P; P.setFromOpaqueValue(V); return P; + } + bool operator==(const PointerIntPair &RHS) const {return Value == RHS.Value;} bool operator!=(const PointerIntPair &RHS) const {return Value != RHS.Value;} bool operator<(const PointerIntPair &RHS) const {return Value < RHS.Value;} @@ -89,5 +95,19 @@ struct DenseMapInfo > { static bool isPod() { return true; } }; +// Teach SmallPtrSet that PointerIntPair is "basically a pointer". +template +class PointerLikeTypeInfo > { +public: + static inline void * + getAsVoidPointer(const PointerIntPair &P) { + return P.getOpaqueValue(); + } + static inline PointerIntPair + getFromVoidPointer(void *P) { + return PointerIntPair::getFromOpaqueValue(P); + } +}; + } // end namespace llvm #endif