1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

PointerUnion::getAddrOf() does not need to be template since we can only

use the first pointer type for it. Rename it to getAddrOfPtr1().

llvm-svn: 152106
This commit is contained in:
Argyrios Kyrtzidis 2012-03-06 07:14:54 +00:00
parent 86f61a903c
commit 267b14e42c
3 changed files with 16 additions and 9 deletions

View File

@ -92,10 +92,14 @@ public:
} }
PointerTy const *getAddrOfPointer() const { PointerTy const *getAddrOfPointer() const {
return const_cast<PointerIntPair *>(this)->getAddrOfPointer();
}
PointerTy *getAddrOfPointer() {
assert(Value == reinterpret_cast<intptr_t>(getPointer()) && assert(Value == reinterpret_cast<intptr_t>(getPointer()) &&
"Can only return the address if IntBits is cleared and " "Can only return the address if IntBits is cleared and "
"PtrTraits doesn't change the pointer"); "PtrTraits doesn't change the pointer");
return reinterpret_cast<PointerTy const *>(&Value); return reinterpret_cast<PointerTy *>(&Value);
} }
void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); } void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }

View File

@ -142,16 +142,19 @@ namespace llvm {
return T(); return T();
} }
/// \brief If the union is set to the first pointer type we can get an /// \brief If the union is set to the first pointer type get an address
/// address pointing to it. /// pointing to it.
template <typename T> PT1 const *getAddrOfPtr1() const {
PT1 const *getAddrOf() const { return const_cast<PointerUnion *>(this)->getAddrOfPtr1();
}
/// \brief If the union is set to the first pointer type get an address
/// pointing to it.
PT1 *getAddrOfPtr1() {
assert(is<PT1>() && "Val is not the first pointer"); assert(is<PT1>() && "Val is not the first pointer");
assert(get<PT1>() == Val.getPointer() && assert(get<PT1>() == Val.getPointer() &&
"Can't get the address because PointerLikeTypeTraits changes the ptr"); "Can't get the address because PointerLikeTypeTraits changes the ptr");
T const *can_only_get_address_of_first_pointer_type return (PT1 *)Val.getAddrOfPointer();
= reinterpret_cast<PT1 const *>(Val.getAddrOfPointer());
return can_only_get_address_of_first_pointer_type;
} }
/// Assignment operators - Allow assigning into this union from either /// Assignment operators - Allow assigning into this union from either

View File

@ -69,7 +69,7 @@ public:
return 0; return 0;
if (Val.template is<EltTy>()) if (Val.template is<EltTy>())
return Val.template getAddrOf<EltTy>(); return Val.getAddrOfPtr1();
return Val.template get<VecTy *>()->begin(); return Val.template get<VecTy *>()->begin();