[llvm-commits] [llvm] r82163 - /llvm/trunk/include/llvm/ADT/PointerIntPair.h
John McCall
rjmccall at apple.com
Thu Sep 17 13:35:18 PDT 2009
Author: rjmccall
Date: Thu Sep 17 15:35:18 2009
New Revision: 82163
URL: http://llvm.org/viewvc/llvm-project?rev=82163&view=rev
Log:
Fix a few places where PointerIntPair was using PointerLikeTypeTraits<PointerTy>
instead of the PtrTraits provided. Allows PointerIntPair to contain a
PointerUnion safely, as long as the bits add up.
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=82163&r1=82162&r2=82163&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Thu Sep 17 15:35:18 2009
@@ -65,7 +65,8 @@
}
PointerTy getPointer() const {
- return reinterpret_cast<PointerTy>(Value & PointerBitMask);
+ return PtrTraits::getFromVoidPointer(
+ reinterpret_cast<void*>(Value & PointerBitMask));
}
IntType getInt() const {
@@ -73,7 +74,8 @@
}
void setPointer(PointerTy Ptr) {
- intptr_t PtrVal = reinterpret_cast<intptr_t>(Ptr);
+ intptr_t PtrVal
+ = reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
assert((PtrVal & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
"Pointer is not sufficiently aligned");
// Preserve all low bits, just update the pointer.
@@ -141,8 +143,7 @@
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
}
enum {
- NumLowBitsAvailable =
- PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable - IntBits
+ NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits
};
};
More information about the llvm-commits
mailing list