15 #ifndef LLVM_SUPPORT_CASTING_H
16 #define LLVM_SUPPORT_CASTING_H
31 template<
typename From>
struct simplify_type {
52 template <
typename To,
typename From,
typename Enabler =
void>
54 static inline bool doit(
const From &Val) {
55 return To::classof(&Val);
60 template <
typename To,
typename From>
66 static inline bool doit(
const From &) {
return true; }
70 static inline bool doit(
const From &Val) {
75 template <
typename To,
typename From>
struct isa_impl_cl<To, const From> {
76 static inline bool doit(
const From &Val) {
81 template <
typename To,
typename From>
struct isa_impl_cl<To, From*> {
82 static inline bool doit(
const From *Val) {
83 assert(Val &&
"isa<> used on a null pointer");
88 template <
typename To,
typename From>
struct isa_impl_cl<To, From*
const> {
89 static inline bool doit(
const From *Val) {
90 assert(Val &&
"isa<> used on a null pointer");
95 template <
typename To,
typename From>
struct isa_impl_cl<To, const From*> {
96 static inline bool doit(
const From *Val) {
97 assert(Val &&
"isa<> used on a null pointer");
102 template <
typename To,
typename From>
struct isa_impl_cl<To, const From*
const> {
103 static inline bool doit(
const From *Val) {
104 assert(Val &&
"isa<> used on a null pointer");
109 template<
typename To,
typename From,
typename SimpleFrom>
113 static bool doit(
const From &Val) {
120 template<
typename To,
typename FromTy>
123 static bool doit(
const FromTy &Val) {
133 template <
class X,
class Y>
134 inline bool isa(
const Y &Val) {
168 template<
class To,
class From,
class SimpleFrom>
176 template<
class To,
class FromTy>
182 template<
class To,
class From>
221 template <
class X,
class Y>
225 assert(isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!");
230 template <
class X,
class Y>
232 assert(isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!");
237 template <
class X,
class Y>
239 assert(isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!");
247 template <
class X,
class Y>
249 if (Val == 0)
return 0;
250 assert(isa<X>(Val) &&
"cast_or_null<Ty>() argument of incompatible type!");
263 template <
class X,
class Y>
264 inline typename enable_if_c<!is_simple_type<Y>::value,
265 typename cast_retty<X, const Y>::ret_type>::type
267 return isa<X>(Val) ? cast<X>(Val) : 0;
270 template <
class X,
class Y>
272 return isa<X>(Val) ? cast<X>(Val) : 0;
275 template <
class X,
class Y>
277 return isa<X>(Val) ? cast<X>(Val) : 0;
283 template <
class X,
class Y>
285 return (Val && isa<X>(Val)) ? cast<X>(Val) : 0;
static bool doit(const From *Val)
static cast_retty< To, FromTy >::ret_type doit(const FromTy &Val)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static RetType getSimplifiedValue(const From &Val)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
static bool doit(const From &)
static bool doit(const From &Val)
static bool doit(const From *Val)
cast_retty< X, Y * >::ret_type dyn_cast_or_null(Y *Val)
static bool doit(const From &Val)
Metafunction that determines whether the two given types are equivalent.
static cast_retty< To, From >::ret_type doit(From &Val)
static bool doit(const From *Val)
simplify_type< From >::SimpleType NonConstSimpleType
static bool doit(const From &Val)
cast_retty< X, Y * >::ret_type cast_or_null(Y *Val)
static bool doit(const From &Val)
add_lvalue_reference_if_not_pointer< SimpleType >::type RetType
static bool doit(const FromTy &Val)
add_const_past_pointer< NonConstSimpleType >::type SimpleType
cast_retty_wrap< To, From, typename simplify_type< From >::SimpleType >::ret_type ret_type
cast_retty_impl< To, FromTy >::ret_type ret_type
cast_retty< To, SimpleFrom >::ret_type ret_type
static SimpleType & getSimplifiedValue(From &Val)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
static bool doit(const From *Val)