forked from OSchip/llvm-project
parent
78244c4667
commit
f6cb8e759a
llvm/include/llvm
|
@ -204,8 +204,17 @@ inline bool isa(Y Val) {
|
|||
//
|
||||
template <class X, class Y>
|
||||
inline X *cast(Y Val) {
|
||||
assert(isa<X>(Val) && "cast<Ty>() argument of uncompatible type!");
|
||||
return (X*)(real_type<Y>::Type)Val;
|
||||
}
|
||||
|
||||
// cast_or_null<X> - Functionally identical to cast, except that a null value is
|
||||
// accepted.
|
||||
//
|
||||
template <class X, class Y>
|
||||
inline X *cast_or_null(Y Val) {
|
||||
assert((Val == 0 || isa<X>(Val)) &&
|
||||
"cast<Ty>() argument of uncompatible type!");
|
||||
"cast_or_null<Ty>() argument of uncompatible type!");
|
||||
return (X*)(real_type<Y>::Type)Val;
|
||||
}
|
||||
|
||||
|
@ -223,6 +232,16 @@ inline X *dyn_cast(Y Val) {
|
|||
return isa<X>(Val) ? cast<X>(Val) : 0;
|
||||
}
|
||||
|
||||
// dyn_cast_or_null<X> - Functionally identical to dyn_cast, except that a null
|
||||
// value is accepted.
|
||||
//
|
||||
template <class X, class Y>
|
||||
inline X *dyn_cast_or_null(Y Val) {
|
||||
assert((Val == 0 || isa<X>(Val)) &&
|
||||
"cast_or_null<Ty>() argument of uncompatible type!");
|
||||
return (Val && isa<X>(Val)) ? cast<X>(Val) : 0;
|
||||
}
|
||||
|
||||
|
||||
// isa - Provide some specializations of isa so that we have to include the
|
||||
// subtype header files to test to see if the value is a subclass...
|
||||
|
|
Loading…
Reference in New Issue