[llvm-commits] [llvm] r67970 - /llvm/trunk/include/llvm/ADT/PointerIntPair.h

Chris Lattner sabre at nondot.org
Sat Mar 28 17:18:43 PDT 2009


Author: lattner
Date: Sat Mar 28 19:18:42 2009
New Revision: 67970

URL: http://llvm.org/viewvc/llvm-project?rev=67970&view=rev
Log:
teach SmallPtrSet that PointerIntPair is "basically a pointer".

Modified:
    llvm/trunk/include/llvm/ADT/PointerIntPair.h

Modified: llvm/trunk/include/llvm/ADT/PointerIntPair.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=67970&r1=67969&r2=67970&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Sat Mar 28 19:18:42 2009
@@ -21,6 +21,8 @@
 
 template<typename T>
 struct DenseMapInfo;
+template<typename>
+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 @@
   void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }
   void setFromOpaqueValue(void *Val) { Value = reinterpret_cast<intptr_t>(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 @@
   static bool isPod() { return true; }
 };
 
+// Teach SmallPtrSet that PointerIntPair is "basically a pointer".
+template<typename PointerTy, unsigned IntBits, typename IntType>
+class PointerLikeTypeInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
+public:
+  static inline void *
+  getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {
+    return P.getOpaqueValue();
+  }
+  static inline PointerIntPair<PointerTy, IntBits, IntType>
+  getFromVoidPointer(void *P) {
+    return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
+  }
+};
+
 } // end namespace llvm
 #endif





More information about the llvm-commits mailing list