forked from OSchip/llvm-project
Allow PointerIntPairs to be created from const void *.
For a measure of safety, this conversion is only permitted if the stored pointer type can also be created from a const void *. llvm-svn: 160456
This commit is contained in:
parent
68777ac253
commit
82632bffbc
|
@ -109,6 +109,13 @@ public:
|
|||
PointerIntPair P; P.setFromOpaqueValue(V); return P;
|
||||
}
|
||||
|
||||
// Allow PointerIntPairs to be created from const void * if and only if the
|
||||
// pointer type could be created from a const void *.
|
||||
static PointerIntPair getFromOpaqueValue(const void *V) {
|
||||
(void)PtrTraits::getFromVoidPointer(V);
|
||||
return getFromOpaqueValue(const_cast<void *>(V));
|
||||
}
|
||||
|
||||
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;}
|
||||
|
@ -158,6 +165,10 @@ public:
|
|||
getFromVoidPointer(void *P) {
|
||||
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
|
||||
}
|
||||
static inline PointerIntPair<PointerTy, IntBits, IntType>
|
||||
getFromVoidPointer(const void *P) {
|
||||
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
|
||||
}
|
||||
enum {
|
||||
NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue