llvm::TypeSwitch

A switch()-like dispatch on a value of type T using dyn_cast.

Synopsis

Declared in <llvm/ADT/TypeSwitch.h>

template<
    typename T,
    typename ResultT = void>
class TypeSwitch
    : public /* implementation-defined */

Description

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>([]op) { ... }) .Default([]*op) { ... });

Base Classes

NameDescription
/* implementation-defined */

Type Aliases

NameDescription
BaseT CRTP base that provides Case() helpers for this TypeSwitch.

Member Functions

NameDescription
TypeSwitch [constructor]Move-construct from another TypeSwitch.
operator= Assignment operators
Case Case overloads
Default Default overloads
DefaultUnreachable Declare default as unreachable, making sure that all cases were handled.
operator ResultT Convert to ResultT, treating a missing case as unreachable.

Using Declarations

NameDescription
Unnamed using Inherit constructors from the CRTP base.
Case Inherit Case() overloads from the CRTP base.

Protected Static Member Functions

NameDescription
castValue Attempt to dyn_cast the given value to CastT.

Protected Data Members

NameDescription
value The root value we are switching on.

Specializations

NameDescription
TypeSwitch<T, void> Specialization of TypeSwitch for void returning callables.