-//===-- Support/Casting.h - Allow flexible, checked, casts -------*- C++ -*--=//
+//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This file defines the isa<X>(), cast<X>(), dyn_cast<X>(), cast_or_null<X>(),
// and dyn_cast_or_null<X>() templates.
#ifndef SUPPORT_CASTING_H
#define SUPPORT_CASTING_H
-#include <assert.h>
-
//===----------------------------------------------------------------------===//
// isa<x> Support Templates
//===----------------------------------------------------------------------===//
};
// isa_impl_cl - Use class partial specialization to transform types to a single
-// cannonical form for isa_impl.
+// canonical form for isa_impl.
//
template<typename FromCl>
struct isa_impl_cl {
//
template <class X, class Y>
inline typename cast_retty<X, Y>::ret_type cast(const Y &Val) {
- assert(isa<X>(Val) && "cast<Ty>() argument of uncompatible type!");
+ assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!");
return cast_convert_val<X, Y,
typename simplify_type<Y>::SimpleType>::doit(Val);
}
template <class X, class Y>
inline typename cast_retty<X, Y*>::ret_type cast_or_null(Y *Val) {
if (Val == 0) return 0;
- assert(isa<X>(Val) && "cast_or_null<Ty>() argument of uncompatible type!");
+ assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!");
return cast<X>(Val);
}
// be used to test for a type as well as cast if successful. This should be
// used in the context of an if statement like this:
//
-// if (const Instruction *I = dyn_cast<const Instruction>(myVal)) { ... }
+// if (const Instruction *I = dyn_cast<Instruction>(myVal)) { ... }
//
template <class X, class Y>
// value is accepted.
//
template <class X, class Y>
-inline typename cast_retty<X, Y*>::ret_type dyn_cast_or_null(Y *Val) {
- return (Val && isa<X>(Val)) ? cast<X, Y*>(Val) : 0;
+inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(Y Val) {
+ return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0;
}