LLVM API Documentation
#include <PointerUnion.h>
Classes | |
struct | IsPT1 |
struct | IsPT2 |
struct | UNION_DOESNT_CONTAIN_TYPE |
Public Types | |
typedef PointerIntPair< void *, 1, bool, PointerUnionUIntTraits< PT1, PT2 > > | ValTy |
Public Member Functions | |
PointerUnion () | |
PointerUnion (PT1 V) | |
PointerUnion (PT2 V) | |
bool | isNull () const |
LLVM_EXPLICIT | operator bool () const |
template<typename T > | |
int | is () const |
is<T>() return true if the Union currently holds the type matching T. | |
template<typename T > | |
T | get () const |
template<typename T > | |
T | dyn_cast () const |
PT1 const * | getAddrOfPtr1 () const |
If the union is set to the first pointer type get an address pointing to it. | |
PT1 * | getAddrOfPtr1 () |
If the union is set to the first pointer type get an address pointing to it. | |
const PointerUnion & | operator= (std::nullptr_t) |
Assignment from nullptr which just clears the union. | |
const PointerUnion & | operator= (const PT1 &RHS) |
const PointerUnion & | operator= (const PT2 &RHS) |
void * | getOpaqueValue () const |
Static Public Member Functions | |
static PointerUnion | getFromOpaqueValue (void *VP) |
PointerUnion - This implements a discriminated union of two pointer types, and keeps the discriminator bit-mangled into the low bits of the pointer. This allows the implementation to be extremely efficient in space, but permits a very natural and type-safe API.
Common use patterns would be something like this: PointerUnion<int*, float*> P; P = (int*)0; printf("%d %d", P.is<int*>(), P.is<float*>()); // prints "1 0" X = P.get<int*>(); // ok. Y = P.get<float*>(); // runtime assertion failure. Z = P.get<double*>(); // compile time failure. P = (float*)0; Y = P.get<float*>(); // ok. X = P.get<int*>(); // runtime assertion failure.
Definition at line 81 of file PointerUnion.h.
typedef PointerIntPair<void*, 1, bool, PointerUnionUIntTraits<PT1,PT2> > llvm::PointerUnion< PT1, PT2 >::ValTy |
Definition at line 84 of file PointerUnion.h.
llvm::PointerUnion< PT1, PT2 >::PointerUnion | ( | ) | [inline] |
Definition at line 98 of file PointerUnion.h.
llvm::PointerUnion< PT1, PT2 >::PointerUnion | ( | PT1 | V | ) | [inline] |
Definition at line 100 of file PointerUnion.h.
llvm::PointerUnion< PT1, PT2 >::PointerUnion | ( | PT2 | V | ) | [inline] |
Definition at line 103 of file PointerUnion.h.
T llvm::PointerUnion< PT1, PT2 >::dyn_cast | ( | ) | const [inline] |
dyn_cast<T>() - If the current value is of the specified pointer type, return it, otherwise return null.
Definition at line 138 of file PointerUnion.h.
Referenced by llvm::MachineMemOperand::getPseudoValue(), and llvm::MachineMemOperand::getValue().
T llvm::PointerUnion< PT1, PT2 >::get | ( | ) | const [inline] |
get<T>() - Return the value of the specified pointer type. If the specified pointer type is incorrect, assert.
Definition at line 130 of file PointerUnion.h.
Referenced by llvm::MachinePointerInfo::getWithOffset(), and llvm::LazyCallGraph::iterator::operator*().
PT1 const* llvm::PointerUnion< PT1, PT2 >::getAddrOfPtr1 | ( | ) | const [inline] |
If the union is set to the first pointer type get an address pointing to it.
Definition at line 145 of file PointerUnion.h.
Referenced by llvm::TinyPtrVector< EltTy >::begin(), llvm::PointerUnion< const Value *, const PseudoSourceValue * >::getAddrOfPtr1(), and llvm::TinyPtrVector< EltTy >::operator ArrayRef< EltTy >().
PT1* llvm::PointerUnion< PT1, PT2 >::getAddrOfPtr1 | ( | ) | [inline] |
If the union is set to the first pointer type get an address pointing to it.
Definition at line 151 of file PointerUnion.h.
static PointerUnion llvm::PointerUnion< PT1, PT2 >::getFromOpaqueValue | ( | void * | VP | ) | [inline, static] |
Definition at line 179 of file PointerUnion.h.
void* llvm::PointerUnion< PT1, PT2 >::getOpaqueValue | ( | ) | const [inline] |
Definition at line 178 of file PointerUnion.h.
Referenced by llvm::PointerLikeTypeTraits< PointerUnion< PT1, PT2 > >::getAsVoidPointer(), llvm::DenseMapInfo< PointerUnion< T, U > >::getHashValue(), llvm::MachineMemOperand::getOpaqueValue(), llvm::PointerUnion3< PT1, PT2, PT3 >::getOpaqueValue(), llvm::PointerUnion4< PT1, PT2, PT3, PT4 >::getOpaqueValue(), llvm::operator!=(), and llvm::operator==().
int llvm::PointerUnion< PT1, PT2 >::is | ( | ) | const [inline] |
is<T>() return true if the Union currently holds the type matching T.
Definition at line 118 of file PointerUnion.h.
Referenced by llvm::MachinePointerInfo::getWithOffset(), and llvm::LazyCallGraph::iterator::operator*().
bool llvm::PointerUnion< PT1, PT2 >::isNull | ( | ) | const [inline] |
isNull - Return true if the pointer held in the union is null, regardless of which type it is.
Definition at line 109 of file PointerUnion.h.
Referenced by llvm::TinyPtrVector< EltTy >::empty(), llvm::TinyPtrVector< EltTy >::end(), llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTruncStore(), llvm::MachinePointerInfo::getWithOffset(), llvm::TinyPtrVector< EltTy >::insert(), llvm::PointerUnion3< PT1, PT2, PT3 >::isNull(), llvm::PointerUnion4< PT1, PT2, PT3, PT4 >::isNull(), llvm::TinyPtrVector< EltTy >::operator ArrayRef< EltTy >(), llvm::PointerUnion< const Value *, const PseudoSourceValue * >::operator bool(), llvm::LazyCallGraph::iterator::operator++(), llvm::TinyPtrVector< EltTy >::operator[](), and llvm::TinyPtrVector< EltTy >::push_back().
LLVM_EXPLICIT llvm::PointerUnion< PT1, PT2 >::operator bool | ( | ) | const [inline] |
Definition at line 114 of file PointerUnion.h.
const PointerUnion& llvm::PointerUnion< PT1, PT2 >::operator= | ( | std::nullptr_t | ) | [inline] |
Assignment from nullptr which just clears the union.
Definition at line 159 of file PointerUnion.h.
const PointerUnion& llvm::PointerUnion< PT1, PT2 >::operator= | ( | const PT1 & | RHS | ) | [inline] |
Assignment operators - Allow assigning into this union from either pointer type, setting the discriminator to remember what it came from.
Definition at line 166 of file PointerUnion.h.
const PointerUnion& llvm::PointerUnion< PT1, PT2 >::operator= | ( | const PT2 & | RHS | ) | [inline] |
Definition at line 171 of file PointerUnion.h.