mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
PR7952: Make isa<> use the same logic as cast<>, so that they both work
consistently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,8 +23,6 @@ namespace llvm {
|
|||||||
// isa<x> Support Templates
|
// isa<x> Support Templates
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
template<typename FromCl> struct isa_impl_cl;
|
|
||||||
|
|
||||||
// Define a template that can be specialized by smart pointers to reflect the
|
// 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
|
// fact that they are automatically dereferenced, and are not involved with the
|
||||||
// template selection process... the default implementation is a noop.
|
// template selection process... the default implementation is a noop.
|
||||||
@@ -43,12 +41,9 @@ template<typename From> struct simplify_type<const From> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The core of the implementation of isa<X> is here; To and From should be
|
||||||
// isa<X> - Return true if the parameter to the template is an instance of the
|
// the names of classes. This template can be specialized to customize the
|
||||||
// template type argument. Used like this:
|
// implementation of isa<> without rewriting it from scratch.
|
||||||
//
|
|
||||||
// if (isa<Type*>(myVal)) { ... }
|
|
||||||
//
|
|
||||||
template <typename To, typename From>
|
template <typename To, typename From>
|
||||||
struct isa_impl {
|
struct isa_impl {
|
||||||
static inline bool doit(const From &Val) {
|
static inline bool doit(const From &Val) {
|
||||||
@@ -56,66 +51,63 @@ struct isa_impl {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename To, typename From, typename SimpleType>
|
template <typename To, typename From> struct isa_impl_cl {
|
||||||
|
static inline bool doit(const From &Val) {
|
||||||
|
return isa_impl<To, From>::doit(Val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename To, typename From> struct isa_impl_cl<To, const From> {
|
||||||
|
static inline bool doit(const From &Val) {
|
||||||
|
return isa_impl<To, From>::doit(Val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename To, typename From> struct isa_impl_cl<To, From*> {
|
||||||
|
static inline bool doit(const From *Val) {
|
||||||
|
return isa_impl<To, From>::doit(*Val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename To, typename From> struct isa_impl_cl<To, const From*> {
|
||||||
|
static inline bool doit(const From *Val) {
|
||||||
|
return isa_impl<To, From>::doit(*Val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename To, typename From> struct isa_impl_cl<To, const From*const> {
|
||||||
|
static inline bool doit(const From *Val) {
|
||||||
|
return isa_impl<To, From>::doit(*Val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename To, typename From, typename SimpleFrom>
|
||||||
struct isa_impl_wrap {
|
struct isa_impl_wrap {
|
||||||
// When From != SimplifiedType, we can simplify the type some more by using
|
// When From != SimplifiedType, we can simplify the type some more by using
|
||||||
// the simplify_type template.
|
// the simplify_type template.
|
||||||
static bool doit(const From &Val) {
|
static bool doit(const From &Val) {
|
||||||
return isa_impl_cl<const SimpleType>::template
|
return isa_impl_wrap<To, SimpleFrom,
|
||||||
isa<To>(simplify_type<const From>::getSimplifiedValue(Val));
|
typename simplify_type<SimpleFrom>::SimpleType>::doit(
|
||||||
|
simplify_type<From>::getSimplifiedValue(Val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename To, typename FromTy>
|
template<typename To, typename FromTy>
|
||||||
struct isa_impl_wrap<To, const FromTy, const FromTy> {
|
struct isa_impl_wrap<To, FromTy, FromTy> {
|
||||||
// When From == SimpleType, we are as simple as we are going to get.
|
// When From == SimpleType, we are as simple as we are going to get.
|
||||||
static bool doit(const FromTy &Val) {
|
static bool doit(const FromTy &Val) {
|
||||||
return isa_impl<To,FromTy>::doit(Val);
|
return isa_impl_cl<To,FromTy>::doit(Val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// isa_impl_cl - Use class partial specialization to transform types to a single
|
// isa<X> - Return true if the parameter to the template is an instance of the
|
||||||
// canonical form for isa_impl.
|
// template type argument. Used like this:
|
||||||
|
//
|
||||||
|
// if (isa<Type>(myVal)) { ... }
|
||||||
//
|
//
|
||||||
template<typename FromCl>
|
|
||||||
struct isa_impl_cl {
|
|
||||||
template<class ToCl>
|
|
||||||
static bool isa(const FromCl &Val) {
|
|
||||||
return isa_impl_wrap<ToCl,const FromCl,
|
|
||||||
typename simplify_type<const FromCl>::SimpleType>::doit(Val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Specialization used to strip const qualifiers off of the FromCl type...
|
|
||||||
template<typename FromCl>
|
|
||||||
struct isa_impl_cl<const FromCl> {
|
|
||||||
template<class ToCl>
|
|
||||||
static bool isa(const FromCl &Val) {
|
|
||||||
return isa_impl_cl<FromCl>::template isa<ToCl>(Val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Define pointer traits in terms of base traits...
|
|
||||||
template<class FromCl>
|
|
||||||
struct isa_impl_cl<FromCl*> {
|
|
||||||
template<class ToCl>
|
|
||||||
static bool isa(FromCl *Val) {
|
|
||||||
return isa_impl_cl<FromCl>::template isa<ToCl>(*Val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Define reference traits in terms of base traits...
|
|
||||||
template<class FromCl>
|
|
||||||
struct isa_impl_cl<FromCl&> {
|
|
||||||
template<class ToCl>
|
|
||||||
static bool isa(FromCl &Val) {
|
|
||||||
return isa_impl_cl<FromCl>::template isa<ToCl>(&Val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class X, class Y>
|
template <class X, class Y>
|
||||||
inline bool isa(const Y &Val) {
|
inline bool isa(const Y &Val) {
|
||||||
return isa_impl_cl<Y>::template isa<X>(Val);
|
return isa_impl_wrap<X, Y, typename simplify_type<Y>::SimpleType>::doit(Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@@ -655,7 +655,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
|
|||||||
|
|
||||||
// Just mark all destinations executable!
|
// Just mark all destinations executable!
|
||||||
// TODO: This could be improved if the operand is a [cast of a] BlockAddress.
|
// TODO: This could be improved if the operand is a [cast of a] BlockAddress.
|
||||||
if (isa<IndirectBrInst>(&TI))
|
if (isa<IndirectBrInst>(TI))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
Reference in New Issue
Block a user