LLVM: llvm::TypeSwitch< T, ResultT > Class Template Reference (original) (raw)

This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality. More...

#include "[llvm/ADT/TypeSwitch.h](TypeSwitch%5F8h%5Fsource.html)"

Public Member Functions
TypeSwitch (TypeSwitch &&other)=default
template<typename CaseT, typename CallableT>
TypeSwitch< T, ResultT > & Case (CallableT &&caseFn)
Add a case on the given type.
template
ResultT Default (CallableT &&defaultFn)
As a default, invoke the given callable within the root value.
ResultT Default (ResultT defaultResult)
As a default, return the given value.
template<typename ArgT = ResultT, typename = std::enable_if_t<std::is_constructible_v<ArgT, std::nullptr_t>>>
ResultT Default (std::nullptr_t)
Default for pointer-like results types that accept nullptr.
template<typename ArgT = ResultT, typename = std::enable_if_t<std::is_constructible_v<ArgT, std::nullopt_t>>>
ResultT Default (std::nullopt_t)
Default for optional results types that accept std::nullopt.
ResultT DefaultUnreachable (const char *message="Fell off the end of a type-switch")
Declare default as unreachable, making sure that all cases were handled.
operator ResultT ()
Public Member Functions inherited from llvm::detail::TypeSwitchBase< TypeSwitch< T, void >, T >
TypeSwitchBase (const T &value)
TypeSwitchBase (TypeSwitchBase &&other)
~TypeSwitchBase ()=default
TypeSwitchBase (const TypeSwitchBase &)=delete
TypeSwitchBase is not copyable.
void operator= (const TypeSwitchBase &)=delete
void operator= (TypeSwitchBase &&other)=delete
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG TypeSwitch< T, void > & Case (CallableT &&caseFn)
Invoke a case on the derived class with multiple case types.
TypeSwitch< T, void > & Case (CallableT &&caseFn)
Invoke a case on the derived class, inferring the type of the Case from the first input of the given callable.
Additional Inherited Members
Static Protected Member Functions inherited from llvm::detail::TypeSwitchBase< TypeSwitch< T, void >, T >
static decltype(auto) castValue (ValueT &&value)
Attempt to dyn_cast the given value to CastT.
Protected Attributes inherited from llvm::detail::TypeSwitchBase< TypeSwitch< T, void >, T >
const T value
The root value we are switching on.

template<typename T, typename ResultT = void>
class llvm::TypeSwitch< T, ResultT >

This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality.

Each Case takes a callable to be invoked if the root value isa, the callable is invoked with the result of dyn_cast() as a parameter.

Example: Operation *op = ...; LogicalResult result = TypeSwitch<Operation *, LogicalResult>(op) .Case([](ConstantOp op) { ... }) .Default([](Operation *op) { ... });

Definition at line 88 of file TypeSwitch.h.

BaseT

template<typename T, typename ResultT = void>

template<typename T, typename ResultT = void>

Case()

template<typename T, typename ResultT = void>

template<typename CaseT, typename CallableT>

Default() [1/4]

template<typename T, typename ResultT = void>

template

ResultT llvm::TypeSwitch< T, ResultT >::Default ( CallableT && defaultFn) inlinenodiscard

Default() [2/4]

template<typename T, typename ResultT = void>

ResultT llvm::TypeSwitch< T, ResultT >::Default ( ResultT defaultResult) inlinenodiscard

As a default, return the given value.

Definition at line 116 of file TypeSwitch.h.

Default() [3/4]

template<typename T, typename ResultT = void>

template<typename ArgT = ResultT, typename = std::enable_if_t<std::is_constructible_v<ArgT, std::nullopt_t>>>

Default() [4/4]

template<typename T, typename ResultT = void>

template<typename ArgT = ResultT, typename = std::enable_if_t<std::is_constructible_v<ArgT, std::nullptr_t>>>

DefaultUnreachable()

template<typename T, typename ResultT = void>

ResultT llvm::TypeSwitch< T, ResultT >::DefaultUnreachable ( const char * message = "Fell off the end of a type-switch") inlinenodiscard

operator ResultT()

template<typename T, typename ResultT = void>


The documentation for this class was generated from the following file: