My Project
Public Types | Public Member Functions | List of all members
mlir::TypeSwitch< T, ResultT > Class Template Reference

#include <TypeSwitch.h>

Inheritance diagram for mlir::TypeSwitch< T, ResultT >:
Inheritance graph
[legend]
Collaboration diagram for mlir::TypeSwitch< T, ResultT >:
Collaboration graph
[legend]

Public Types

using BaseT = detail::TypeSwitchBase< TypeSwitch< T, ResultT >, T >
 

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. More...
 
template<typename CallableT >
LLVM_NODISCARD ResultT Default (CallableT &&defaultFn)
 As a default, invoke the given callable within the root value. More...
 
LLVM_NODISCARD operator ResultT ()
 
- Public Member Functions inherited from mlir::detail::TypeSwitchBase< TypeSwitch< T, ResultT >, T >
 TypeSwitchBase (const T &value)
 
 TypeSwitchBase (TypeSwitchBase &&other)
 
 TypeSwitchBase (const TypeSwitchBase &)=delete
 TypeSwitchBase is not copyable. More...
 
 ~TypeSwitchBase ()=default
 
void operator= (const TypeSwitchBase &)=delete
 
void operator= (TypeSwitchBase &&other)=delete
 
TypeSwitch< T, ResultT > & Case (CallableT &&caseFn)
 Invoke a case on the derived class with multiple case types. More...
 
TypeSwitch< T, ResultT > & Case (CallableT &&caseFn)
 

Additional Inherited Members

- Protected Types inherited from mlir::detail::TypeSwitchBase< TypeSwitch< T, ResultT >, T >
using has_dyn_cast_t = decltype(std::declval< ValueT &>().template dyn_cast< CastT >())
 
- Static Protected Member Functions inherited from mlir::detail::TypeSwitchBase< TypeSwitch< T, ResultT >, T >
static auto castValue (ValueT value, typename std::enable_if_t< is_detected< has_dyn_cast_t, ValueT, CastT >::value > *=nullptr)
 
static auto castValue (ValueT value, typename std::enable_if_t< !is_detected< has_dyn_cast_t, ValueT, CastT >::value > *=nullptr)
 
- Protected Attributes inherited from mlir::detail::TypeSwitchBase< TypeSwitch< T, ResultT >, T >
const T value
 The root value we are switching on. More...
 

Detailed Description

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

This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality. Each Case<T> takes a callable to be invoked if the root value isa<T>, the callable is invoked with the result of dyn_cast<T>() as a parameter.

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

Member Typedef Documentation

◆ BaseT

template<typename T , typename ResultT = void>
using mlir::TypeSwitch< T, ResultT >::BaseT = detail::TypeSwitchBase<TypeSwitch<T, ResultT>, T>

Constructor & Destructor Documentation

◆ TypeSwitch()

template<typename T , typename ResultT = void>
mlir::TypeSwitch< T, ResultT >::TypeSwitch ( TypeSwitch< T, ResultT > &&  other)
default

Member Function Documentation

◆ Case()

template<typename T , typename ResultT = void>
template<typename CaseT , typename CallableT >
TypeSwitch<T, ResultT>& mlir::TypeSwitch< T, ResultT >::Case ( CallableT &&  caseFn)
inline

Add a case on the given type.

◆ Default()

template<typename T , typename ResultT = void>
template<typename CallableT >
LLVM_NODISCARD ResultT mlir::TypeSwitch< T, ResultT >::Default ( CallableT &&  defaultFn)
inline

As a default, invoke the given callable within the root value.

◆ operator ResultT()

template<typename T , typename ResultT = void>
LLVM_NODISCARD mlir::TypeSwitch< T, ResultT >::operator ResultT ( )
inline

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