LLVM 20.0.0git
|
This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality. More...
#include "llvm/ADT/TypeSwitch.h"
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. | |
template<typename CallableT > | |
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. | |
operator ResultT () | |
template<typename CaseT , typename CaseT2 , typename... CaseTs, typename CallableT > | |
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG DerivedT & | Case (CallableT &&caseFn) |
Invoke a case on the derived class with multiple case types. | |
template<typename CallableT > | |
DerivedT & | Case (CallableT &&caseFn) |
Invoke a case on the derived class, inferring the type of the Case from the first input of the given callable. | |
Public Member Functions inherited from llvm::detail::TypeSwitchBase< DerivedT, 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 |
template<typename CaseT , typename CaseT2 , typename... CaseTs, typename CallableT > | |
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG DerivedT & | Case (CallableT &&caseFn) |
Invoke a case on the derived class with multiple case types. | |
template<typename CallableT > | |
DerivedT & | 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< DerivedT, T > | |
template<typename CastT , typename ValueT > | |
static decltype(auto) | castValue (ValueT &&value) |
Attempt to dyn_cast the given value to CastT . | |
Protected Attributes inherited from llvm::detail::TypeSwitchBase< DerivedT, T > | |
const T | value |
The root value we are switching on. | |
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) { ... });
Definition at line 87 of file TypeSwitch.h.
using llvm::TypeSwitch< T, ResultT >::BaseT = detail::TypeSwitchBase<TypeSwitch<T, ResultT>, T> |
Definition at line 89 of file TypeSwitch.h.
|
default |
|
inline |
Invoke a case on the derived class with multiple case types.
Definition at line 44 of file TypeSwitch.h.
|
inline |
Invoke a case on the derived class, inferring the type of the Case from the first input of the given callable.
Note: This inference rules for this overload are very simple: strip pointers and references.
Definition at line 54 of file TypeSwitch.h.
|
inline |
Add a case on the given type.
Definition at line 96 of file TypeSwitch.h.
References llvm::detail::TypeSwitchBase< DerivedT, T >::value.
Referenced by llvm::LoopVectorizationPlanner::emitInvalidCostRemarks(), and llvm::VPTypeAnalysis::inferScalarType().
|
inline |
As a default, invoke the given callable within the root value.
Definition at line 108 of file TypeSwitch.h.
References llvm::detail::TypeSwitchBase< DerivedT, T >::value.
|
inline |
As a default, return the given value.
Definition at line 114 of file TypeSwitch.h.
|
inline |
Definition at line 120 of file TypeSwitch.h.
References assert().