Customizes how casts from From to To are performed.
Synopsis
Declared in <llvm/Support/Casting.h>
template<
typename To,
typename From,
typename Enable = void>
struct CastInfo
: CastIsPossible<To, From>
Description
This struct provides a method for customizing the way a cast is performed. It inherits from CastIsPossible, to support the case of declaring many CastIsPossible specializations without having to specialize the full CastInfo.
In order to specialize different behaviors, specify different functions in your CastInfo specialization. For isa<> customization, provide:
static bool isPossible(const From &f)
For cast<> customization, provide:
static To doCast(const From &f)
For dyn_cast<> and the *_if_present<> variants' customization, provide:
static To castFailed() and static To doCastIfPossible(const From &f)
Your specialization might look something like this:
template<> struct CastInfo<foo, bar> : public CastIsPossible<foo, bar> { static inline foo doCast(const bar &b) { return foo(const_cast<bar &>(b)); } static inline foo castFailed() { return foo(); } static inline foo doCastIfPossible(const bar &b) { if (!CastInfo<foo, bar>::isPossible(b)) return castFailed(); return doCast(b); } };
Base Classes
Name |
Description |
Trait that reports whether a cast from |
Type Aliases
Name |
Description |
Return type produced by successful casts in this specialization. |
|
This |
Static Member Functions
Name |
Description |
Returns a null cast result used when the cast fails. |
|
Unconditionally converts |
|
Casts |
|
Returns true if a cast from |
Specializations
Name |
Description |
Lets isa/cast/dyn_cast query which IR unit an IRUnitRef holds, naming the IR unit itself rather than a pointer to it: dyn_cast<Module>(IR). |
|
CastInfo specialization for const IRUnitRef, forwarding to the non‐const case. |
|
Provide CastInfo for SCEVUseT so that cast<SCEVUseT<const To *>>(use) returns SCEVUseT<const To *> with flags preserved. |
|
CastInfo specialization for const SCEVUse, forwarding to the non‐const case. |
|
Cast traits for DIExpression typed operand views. |
|
|
|
|
|
CastInfo specialization for non‐const PointerUnion sources. |
|
Provide a CastInfo specialized for casting out of |
|
Provide a CastInfo specialized for std::unique_ptr. |
|
|
CastInfo specialization for const PointerUnion sources. |
Derived Classes
Name |
Description |
CastInfo specialization for const IRUnitRef, forwarding to the non‐const case. |
|
CastInfo specialization for const SCEVUse, forwarding to the non‐const case. |
Created with MrDocs