LLVM  14.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]
Collaboration diagram for llvm::detail::TypeSwitchBase< DerivedT, T >:
Collaboration graph
[legend]

Public Member Functions

 TypeSwitchBase (const T &value)
 
 TypeSwitchBase (TypeSwitchBase &&other)
 
 ~TypeSwitchBase ()=default
 
 TypeSwitchBase (const TypeSwitchBase &)=delete
 TypeSwitchBase is not copyable. More...
 
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. More...
 
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. More...
 

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. More...
 

Static Protected Member Functions

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

Protected Attributes

const T value
 The root value we are switching on. More...
 

Detailed Description

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

Definition at line 24 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 26 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 27 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 43 of file TypeSwitch.h.

Referenced by llvm::detail::TypeSwitchBase< TypeSwitch< T, void >, 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 53 of file TypeSwitch.h.

◆ castValue() [1/2]

template<typename DerivedT , typename T >
template<typename CastT , typename ValueT >
static auto llvm::detail::TypeSwitchBase< DerivedT, T >::castValue ( ValueT  value,
typename 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 82 of file TypeSwitch.h.

◆ castValue() [2/2]

template<typename DerivedT , typename T >
template<typename CastT , typename ValueT >
static auto llvm::detail::TypeSwitchBase< DerivedT, T >::castValue ( ValueT  value,
typename 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 72 of file TypeSwitch.h.

◆ 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 root value we are switching on.

Definition at line 90 of file TypeSwitch.h.

Referenced by llvm::detail::TypeSwitchBase< TypeSwitch< T, void >, T >::castValue().


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