LLVM 20.0.0git
Classes | Namespaces | Typedefs | Functions | Variables
Casting.h File Reference
#include "llvm/Support/Compiler.h"
#include "llvm/Support/type_traits.h"
#include <cassert>
#include <memory>
#include <optional>
#include <type_traits>

Go to the source code of this file.

Classes

struct  llvm::simplify_type< From >
 Define a template that can be specialized by smart pointers to reflect the fact that they are automatically dereferenced, and are not involved with the template selection process... the default implementation is a noop. More...
 
struct  llvm::simplify_type< const From >
 
struct  llvm::isa_impl< To, From, Enabler >
 
struct  llvm::isa_impl< To, From, std::enable_if_t< std::is_base_of_v< To, From > > >
 
struct  llvm::isa_impl_cl< To, From >
 
struct  llvm::isa_impl_cl< To, const From >
 
struct  llvm::isa_impl_cl< To, const std::unique_ptr< From > >
 
struct  llvm::isa_impl_cl< To, From * >
 
struct  llvm::isa_impl_cl< To, From *const >
 
struct  llvm::isa_impl_cl< To, const From * >
 
struct  llvm::isa_impl_cl< To, const From *const >
 
struct  llvm::isa_impl_wrap< To, From, SimpleFrom >
 
struct  llvm::isa_impl_wrap< To, FromTy, FromTy >
 
struct  llvm::cast_retty_impl< To, From >
 
struct  llvm::cast_retty_impl< To, const From >
 
struct  llvm::cast_retty_impl< To, From * >
 
struct  llvm::cast_retty_impl< To, const From * >
 
struct  llvm::cast_retty_impl< To, const From *const >
 
struct  llvm::cast_retty_impl< To, std::unique_ptr< From > >
 
struct  llvm::cast_retty_wrap< To, From, SimpleFrom >
 
struct  llvm::cast_retty_wrap< To, FromTy, FromTy >
 
struct  llvm::cast_retty< To, From >
 
struct  llvm::cast_convert_val< To, From, SimpleFrom >
 
struct  llvm::cast_convert_val< To, FromTy, FromTy >
 
struct  llvm::cast_convert_val< To, FromTy *, FromTy * >
 
struct  llvm::is_simple_type< X >
 
struct  llvm::CastIsPossible< To, From, Enable >
 This struct provides a way to check if a given cast is possible. More...
 
struct  llvm::CastIsPossible< To, std::optional< From > >
 
struct  llvm::CastIsPossible< To, From, std::enable_if_t< std::is_base_of_v< To, From > > >
 Upcasting (from derived to base) and casting from a type to itself should always be possible. More...
 
struct  llvm::NullableValueCastFailed< To >
 All of these cast traits are meant to be implementations for useful casts that users may want to use that are outside the standard behavior. More...
 
struct  llvm::DefaultDoCastIfPossible< To, From, Derived >
 This cast trait just provides the default implementation of doCastIfPossible to make CastInfo specializations more declarative. More...
 
struct  llvm::ValueFromPointerCast< To, From, Derived >
 This cast trait provides casting for the specific case of casting to a value-typed object from a pointer-typed object. More...
 
struct  llvm::UniquePtrCast< To, From, Derived >
 This cast trait provides std::unique_ptr casting. More...
 
struct  llvm::OptionalValueCast< To, From, Derived >
 This cast trait provides std::optional<T> casting. More...
 
struct  llvm::ConstStrippingForwardingCast< To, From, ForwardTo >
 Provides a cast trait that strips const from types to make it easier to implement a const-version of a non-const cast. More...
 
struct  llvm::ForwardToPointerCast< To, From, ForwardTo >
 Provides a cast trait that uses a defined pointer to pointer cast as a base for reference-to-reference casts. More...
 
struct  llvm::CastInfo< To, From, Enable >
 This struct provides a method for customizing the way a cast is performed. More...
 
struct  llvm::CastInfo< To, From, std::enable_if_t<!is_simple_type< From >::value > >
 This struct provides an overload for CastInfo where From has simplify_type defined. More...
 
struct  llvm::CastInfo< To, std::unique_ptr< From > >
 Provide a CastInfo specialized for std::unique_ptr. More...
 
struct  llvm::CastInfo< To, std::optional< From > >
 Provide a CastInfo specialized for std::optional<From>. More...
 
struct  llvm::ValueIsPresent< T, Enable >
 ValueIsPresent provides a way to check if a value is, well, present. More...
 
struct  llvm::ValueIsPresent< std::optional< T > >
 
struct  llvm::ValueIsPresent< T, std::enable_if_t< IsNullable< T > > >
 
struct  llvm::detail::IsaCheckPredicate< Types >
 
struct  llvm::detail::IsaAndPresentCheckPredicate< Types >
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::detail
 These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:all_of, llvm::none_of, etc.
 

Typedefs

template<typename OptionalDerived , typename Default >
using llvm::detail::SelfType = std::conditional_t< std::is_same_v< OptionalDerived, void >, Default, OptionalDerived >
 A helper to derive the type to use with Self for cast traits, when the provided CRTP derived type is allowed to be void.
 

Functions

template<typename To , typename From >
bool llvm::isa (const From &Val)
 isa<X> - Return true if the parameter to the template is an instance of one of the template type arguments.
 
template<typename First , typename Second , typename... Rest, typename From >
bool llvm::isa (const From &Val)
 
template<typename To , typename From >
decltype(auto) llvm::cast (const From &Val)
 cast<X> - Return the argument parameter cast to the specified type.
 
template<typename To , typename From >
decltype(auto) llvm::cast (From &Val)
 
template<typename To , typename From >
decltype(auto) llvm::cast (From *Val)
 
template<typename To , typename From >
decltype(auto) llvm::cast (std::unique_ptr< From > &&Val)
 
template<typename T >
bool llvm::detail::isPresent (const T &t)
 
template<typename T >
decltype(auto) llvm::detail::unwrapValue (T &t)
 
template<typename To , typename From >
decltype(auto) llvm::dyn_cast (const From &Val)
 dyn_cast<X> - Return the argument parameter cast to the specified type.
 
template<typename To , typename From >
decltype(auto) llvm::dyn_cast (From &Val)
 
template<typename To , typename From >
decltype(auto) llvm::dyn_cast (From *Val)
 
template<typename To , typename From >
decltype(auto) llvm::dyn_cast (std::unique_ptr< From > &Val)
 
template<typename... X, class Y >
bool llvm::isa_and_present (const Y &Val)
 isa_and_present<X> - Functionally identical to isa, except that a null value is accepted.
 
template<typename... X, class Y >
bool llvm::isa_and_nonnull (const Y &Val)
 
template<class X , class Y >
auto llvm::cast_if_present (const Y &Val)
 cast_if_present<X> - Functionally identical to cast, except that a null value is accepted.
 
template<class X , class Y >
auto llvm::cast_if_present (Y &Val)
 
template<class X , class Y >
auto llvm::cast_if_present (Y *Val)
 
template<class X , class Y >
auto llvm::cast_if_present (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
auto llvm::cast_or_null (const Y &Val)
 
template<class X , class Y >
auto llvm::cast_or_null (Y &Val)
 
template<class X , class Y >
auto llvm::cast_or_null (Y *Val)
 
template<class X , class Y >
auto llvm::cast_or_null (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
auto llvm::dyn_cast_if_present (const Y &Val)
 dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case of optionals) value is accepted.
 
template<class X , class Y >
auto llvm::dyn_cast_if_present (Y &Val)
 
template<class X , class Y >
auto llvm::dyn_cast_if_present (Y *Val)
 
template<class X , class Y >
auto llvm::dyn_cast_or_null (const Y &Val)
 
template<class X , class Y >
auto llvm::dyn_cast_or_null (Y &Val)
 
template<class X , class Y >
auto llvm::dyn_cast_or_null (Y *Val)
 
template<class X , class Y >
CastInfo< X, std::unique_ptr< Y > >::CastResultType llvm::unique_dyn_cast (std::unique_ptr< Y > &Val)
 unique_dyn_cast<X> - Given a unique_ptr<Y>, try to return a unique_ptr<X>, taking ownership of the input pointer iff isa<X>(Val) is true.
 
template<class X , class Y >
auto llvm::unique_dyn_cast (std::unique_ptr< Y > &&Val)
 
template<class X , class Y >
CastInfo< X, std::unique_ptr< Y > >::CastResultType llvm::unique_dyn_cast_or_null (std::unique_ptr< Y > &Val)
 
template<class X , class Y >
auto llvm::unique_dyn_cast_or_null (std::unique_ptr< Y > &&Val)
 

Variables

template<typename T >
constexpr bool llvm::IsNullable
 
template<typename... Types>
constexpr detail::IsaCheckPredicate< Types... > llvm::IsaPred {}
 Function object wrapper for the llvm::isa type check.
 
template<typename... Types>
constexpr detail::IsaAndPresentCheckPredicate< Types... > llvm::IsaAndPresentPred {}
 Function object wrapper for the llvm::isa_and_present type check.