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. llvm-svn: 82163
This commit is contained in:
parent
691a0c45d2
commit
26a96b0369
|
@ -65,7 +65,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerTy getPointer() const {
|
PointerTy getPointer() const {
|
||||||
return reinterpret_cast<PointerTy>(Value & PointerBitMask);
|
return PtrTraits::getFromVoidPointer(
|
||||||
|
reinterpret_cast<void*>(Value & PointerBitMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
IntType getInt() const {
|
IntType getInt() const {
|
||||||
|
@ -73,7 +74,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPointer(PointerTy Ptr) {
|
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 &&
|
assert((PtrVal & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
|
||||||
"Pointer is not sufficiently aligned");
|
"Pointer is not sufficiently aligned");
|
||||||
// Preserve all low bits, just update the pointer.
|
// Preserve all low bits, just update the pointer.
|
||||||
|
@ -141,8 +143,7 @@ public:
|
||||||
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
|
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
|
||||||
}
|
}
|
||||||
enum {
|
enum {
|
||||||
NumLowBitsAvailable =
|
NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits
|
||||||
PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable - IntBits
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue