LLVM 19.0.0git
Public Member Functions | Protected Types | Static Protected Member Functions | Protected Attributes | List of all members
llvm::detail::TypeSwitchBase< DerivedT, T > Class Template Reference

#include "llvm/ADT/TypeSwitch.h"

Inheritance diagram for llvm::detail::TypeSwitchBase< DerivedT, T >:
Inheritance graph
[legend]

Public Member Functions

 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.
 

Protected Types

template<typename ValueT , typename CastT >
using has_dyn_cast_t = decltype(std::declval< ValueT & >().template dyn_cast< CastT >())
 Trait to check whether ValueT provides a 'dyn_cast' method with type CastT.
 

Static Protected Member Functions

template<typename CastT , typename ValueT >
static decltype(auto) castValue (ValueT &&value, std::enable_if_t< is_detected< has_dyn_cast_t, ValueT, CastT >::value > *=nullptr)
 Attempt to dyn_cast the given value to CastT.
 
template<typename CastT , typename ValueT >
static decltype(auto) castValue (ValueT &&value, std::enable_if_t<!is_detected< has_dyn_cast_t, ValueT, CastT >::value > *=nullptr)
 Attempt to dyn_cast the given value to CastT.
 

Protected Attributes

const T value
 The root value we are switching on.
 

Detailed Description

template<typename DerivedT, typename T>
class llvm::detail::TypeSwitchBase< DerivedT, T >

Definition at line 25 of file TypeSwitch.h.

Member Typedef Documentation

◆ has_dyn_cast_t

template<typename DerivedT , typename T >
template<typename ValueT , typename CastT >
using llvm::detail::TypeSwitchBase< DerivedT, T >::has_dyn_cast_t = decltype(std::declval<ValueT &>().template dyn_cast<CastT>())
protected

Trait to check whether ValueT provides a 'dyn_cast' method with type CastT.

Definition at line 67 of file TypeSwitch.h.

Constructor & Destructor Documentation

◆ TypeSwitchBase() [1/3]

template<typename DerivedT , typename T >
llvm::detail::TypeSwitchBase< DerivedT, T >::TypeSwitchBase ( const T value)
inline

Definition at line 27 of file TypeSwitch.h.

◆ TypeSwitchBase() [2/3]

template<typename DerivedT , typename T >
llvm::detail::TypeSwitchBase< DerivedT, T >::TypeSwitchBase ( TypeSwitchBase< DerivedT, T > &&  other)
inline

Definition at line 28 of file TypeSwitch.h.

◆ ~TypeSwitchBase()

template<typename DerivedT , typename T >
llvm::detail::TypeSwitchBase< DerivedT, T >::~TypeSwitchBase ( )
default

◆ TypeSwitchBase() [3/3]

template<typename DerivedT , typename T >
llvm::detail::TypeSwitchBase< DerivedT, T >::TypeSwitchBase ( const TypeSwitchBase< DerivedT, T > &  )
delete

TypeSwitchBase is not copyable.

Member Function Documentation

◆ Case() [1/2]

template<typename DerivedT , typename T >
template<typename CaseT , typename CaseT2 , typename... CaseTs, typename CallableT >
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG DerivedT & llvm::detail::TypeSwitchBase< DerivedT, T >::Case ( CallableT &&  caseFn)
inline

Invoke a case on the derived class with multiple case types.

Definition at line 44 of file TypeSwitch.h.

References llvm::detail::TypeSwitchBase< DerivedT, T >::Case().

Referenced by llvm::detail::TypeSwitchBase< DerivedT, T >::Case().

◆ Case() [2/2]

template<typename DerivedT , typename T >
template<typename CallableT >
DerivedT & llvm::detail::TypeSwitchBase< DerivedT, T >::Case ( CallableT &&  caseFn)
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.

◆ castValue() [1/2]

template<typename DerivedT , typename T >
template<typename CastT , typename ValueT >
static decltype(auto) llvm::detail::TypeSwitchBase< DerivedT, T >::castValue ( ValueT &&  value,
std::enable_if_t< is_detected< has_dyn_cast_t, ValueT, CastT >::value > *  = nullptr 
)
inlinestaticprotected

Attempt to dyn_cast the given value to CastT.

This overload is selected if value already has a suitable dyn_cast method.

Definition at line 73 of file TypeSwitch.h.

References llvm::detail::TypeSwitchBase< DerivedT, T >::value.

◆ castValue() [2/2]

template<typename DerivedT , typename T >
template<typename CastT , typename ValueT >
static decltype(auto) llvm::detail::TypeSwitchBase< DerivedT, T >::castValue ( ValueT &&  value,
std::enable_if_t<!is_detected< has_dyn_cast_t, ValueT, CastT >::value > *  = nullptr 
)
inlinestaticprotected

Attempt to dyn_cast the given value to CastT.

This overload is selected if llvm::dyn_cast should be used.

Definition at line 83 of file TypeSwitch.h.

References llvm::detail::TypeSwitchBase< DerivedT, T >::value.

◆ operator=() [1/2]

template<typename DerivedT , typename T >
void llvm::detail::TypeSwitchBase< DerivedT, T >::operator= ( const TypeSwitchBase< DerivedT, T > &  )
delete

◆ operator=() [2/2]

template<typename DerivedT , typename T >
void llvm::detail::TypeSwitchBase< DerivedT, T >::operator= ( TypeSwitchBase< DerivedT, T > &&  other)
delete

Member Data Documentation

◆ value

template<typename DerivedT , typename T >
const T llvm::detail::TypeSwitchBase< DerivedT, T >::value
protected

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