class PointerSumType

Declaration

template <typename TagT, typename... MemberTs>
class PointerSumType { /* full declaration omitted */ };

Description

A sum type over pointer-like types. This is a normal tagged union across pointer-like types that uses the low bits of the pointers to store the tag. Each member of the sum type is specified by passing a \c PointerSumTypeMember specialization in the variadic member argument list. This allows the user to control the particular tag value associated with a particular type, use the same type for multiple different tags, and customize the pointer-like traits used for a particular member. Note that these *must* be specializations of \c PointerSumTypeMember, no other type will suffice, even if it provides a compatible interface. This type implements all of the comparison operators and even hash table support by comparing the underlying storage of the pointer values. It doesn't support delegating to particular members for comparisons. It also default constructs to a zero tag with a null pointer, whatever that would be. This means that the zero value for the tag type is significant and may be desirable to set to a state that is particularly desirable to default construct. Having a supported zero-valued tag also enables getting the address of a pointer stored with that tag provided it is stored in its natural bit representation. This works because in the case of a zero-valued tag, the pointer's value is directly stored into this object and we can expose the address of that internal storage. This is especially useful when building an `ArrayRef` of a single pointer stored in a sum type. There is no support for constructing or accessing with a dynamic tag as that would fundamentally violate the type safety provided by the sum type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:70

Templates

TagT
MemberTs

Method Overview

  • public PointerSumType<TagT, MemberTs...>()
  • public template <TagT N>typename HelperT::template Lookup<N>::PointerT cast() const
  • public void clear()
  • public template <TagT N>static PointerSumType<TagT, MemberTs...> create(typename HelperT::template Lookup<N>::PointerT Pointer)
  • public template <TagT N>typename HelperT::template Lookup<N>::PointerT get() const
  • public const typename HelperT::template Lookup<HelperT::MinTag>::PointerT * getAddrOfZeroTagPointer() const
  • public typename HelperT::template Lookup<HelperT::MinTag>::PointerT * getAddrOfZeroTagPointer()
  • public uintptr_t getOpaqueValue() const
  • public TagT getTag() const
  • protected void * getVoidPtr() const
  • public template <TagT N>bool is() const
  • public bool operator bool() const
  • public template <TagT N>void set(typename HelperT::template Lookup<N>::PointerT Pointer)

Methods

PointerSumType<TagT, MemberTs...>()

Declared at: llvm/include/llvm/ADT/PointerSumType.h:96

template <TagT N>
typename HelperT::template Lookup<N>::PointerT
cast() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:131

Templates

TagT N

void clear()

Description

Clear the value to null with the min tag type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:117

template <TagT N>
static PointerSumType<TagT, MemberTs...> create(
    typename HelperT::template Lookup<N>::PointerT
        Pointer)

Description

A typed constructor for a specific tagged member of the sum type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:110

Templates

TagT N

Parameters

typename HelperT::template Lookup<N>::PointerT Pointer

template <TagT N>
typename HelperT::template Lookup<N>::PointerT
get() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:125

Templates

TagT N

const typename HelperT::template Lookup<
    HelperT::MinTag>::PointerT*
getAddrOfZeroTagPointer() const

Description

If the tag is zero and the pointer's value isn't changed when being stored, get the address of the stored value type-punned to the zero-tag's pointer type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:141

typename HelperT::template Lookup<
    HelperT::MinTag>::PointerT*
getAddrOfZeroTagPointer()

Description

If the tag is zero and the pointer's value isn't changed when being stored, get the address of the stored value type-punned to the zero-tag's pointer type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:149

uintptr_t getOpaqueValue() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:188

TagT getTag() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:119

void* getVoidPtr() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:195

template <TagT N>
bool is() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:123

Templates

TagT N

bool operator bool() const

Declared at: llvm/include/llvm/ADT/PointerSumType.h:166

template <TagT N>
void set(
    typename HelperT::template Lookup<N>::PointerT
        Pointer)

Description

A typed setter to a given tagged member of the sum type.

Declared at: llvm/include/llvm/ADT/PointerSumType.h:100

Templates

TagT N

Parameters

typename HelperT::template Lookup<N>::PointerT Pointer