fix a bug in post-order iterators with external storage, patch by
[oota-llvm.git] / include / llvm / ADT / PointerIntPair.h
index 19b71d43c92ff13b9aba5896dfe7085492f28fe4..0aa478b1ff61cd7117d06ce780d319f11e7959e7 100644 (file)
@@ -42,16 +42,18 @@ class PointerIntPair {
   intptr_t Value;
   enum {
     /// PointerBitMask - The bits that come from the pointer.
-    PointerBitMask = ~(((intptr_t)1 << PtrTraits::NumLowBitsAvailable)-1),
+    PointerBitMask =
+      ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable)-1),
+
     /// IntShift - The number of low bits that we reserve for other uses, and
     /// keep zero.
-    IntShift = PtrTraits::NumLowBitsAvailable-IntBits,
+    IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable-IntBits,
     
     /// IntMask - This is the unshifted mask for valid bits of the int type.
-    IntMask = ((intptr_t)1 << IntBits)-1,
+    IntMask = (uintptr_t)(((intptr_t)1 << IntBits)-1),
     
     // ShiftedIntMask - This is the bits for the integer shifted in place.
-    ShiftedIntMask = IntMask << IntShift
+    ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
   };
 public:
   PointerIntPair() : Value(0) {}
@@ -125,8 +127,10 @@ struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
 };
 
 // Teach SmallPtrSet that PointerIntPair is "basically a pointer".
-template<typename PointerTy, unsigned IntBits, typename IntType>
-class PointerLikeTypeTraits<PointerIntPair<PointerTy, IntBits, IntType> > {
+template<typename PointerTy, unsigned IntBits, typename IntType,
+         typename PtrTraits>
+class PointerLikeTypeTraits<PointerIntPair<PointerTy, IntBits, IntType,
+                                           PtrTraits> > {
 public:
   static inline void *
   getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {