2009-03-31 22:11:05 +00:00
|
|
|
//===- llvm/Support/ValueHandle.h - Value Smart Pointer classes -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the ValueHandle class and its sub-classes.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_SUPPORT_VALUEHANDLE_H
|
|
|
|
#define LLVM_SUPPORT_VALUEHANDLE_H
|
|
|
|
|
2009-07-31 18:20:18 +00:00
|
|
|
#include "llvm/ADT/DenseMapInfo.h"
|
2009-03-31 22:11:05 +00:00
|
|
|
#include "llvm/ADT/PointerIntPair.h"
|
|
|
|
#include "llvm/Value.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2009-04-03 00:26:01 +00:00
|
|
|
class ValueHandleBase;
|
|
|
|
|
|
|
|
// ValueHandleBase** is only 4-byte aligned.
|
|
|
|
template<>
|
|
|
|
class PointerLikeTypeTraits<ValueHandleBase**> {
|
|
|
|
public:
|
|
|
|
static inline void *getAsVoidPointer(ValueHandleBase** P) { return P; }
|
|
|
|
static inline ValueHandleBase **getFromVoidPointer(void *P) {
|
|
|
|
return static_cast<ValueHandleBase**>(P);
|
|
|
|
}
|
|
|
|
enum { NumLowBitsAvailable = 2 };
|
|
|
|
};
|
2009-03-31 22:11:05 +00:00
|
|
|
|
|
|
|
/// ValueHandleBase - This is the common base class of value handles.
|
|
|
|
/// ValueHandle's are smart pointers to Value's that have special behavior when
|
|
|
|
/// the value is deleted or ReplaceAllUsesWith'd. See the specific handles
|
|
|
|
/// below for details.
|
|
|
|
///
|
|
|
|
class ValueHandleBase {
|
|
|
|
friend class Value;
|
|
|
|
protected:
|
2009-04-27 20:32:07 +00:00
|
|
|
/// HandleBaseKind - This indicates what sub class the handle actually is.
|
2009-03-31 22:11:05 +00:00
|
|
|
/// This is to avoid having a vtable for the light-weight handle pointers. The
|
2009-05-02 21:10:48 +00:00
|
|
|
/// fully general Callback version does have a vtable.
|
2009-03-31 22:11:05 +00:00
|
|
|
enum HandleBaseKind {
|
|
|
|
Assert,
|
2009-09-22 02:02:33 +00:00
|
|
|
Callback,
|
|
|
|
Tracking,
|
|
|
|
Weak
|
2009-03-31 22:11:05 +00:00
|
|
|
};
|
|
|
|
private:
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
PointerIntPair<ValueHandleBase**, 2, HandleBaseKind> PrevPair;
|
|
|
|
ValueHandleBase *Next;
|
|
|
|
Value *VP;
|
2009-10-10 08:27:29 +00:00
|
|
|
|
|
|
|
explicit ValueHandleBase(const ValueHandleBase&); // DO NOT IMPLEMENT.
|
2009-03-31 22:11:05 +00:00
|
|
|
public:
|
2009-05-05 21:23:20 +00:00
|
|
|
explicit ValueHandleBase(HandleBaseKind Kind)
|
|
|
|
: PrevPair(0, Kind), Next(0), VP(0) {}
|
2009-03-31 22:11:05 +00:00
|
|
|
ValueHandleBase(HandleBaseKind Kind, Value *V)
|
|
|
|
: PrevPair(0, Kind), Next(0), VP(V) {
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP))
|
2009-03-31 22:11:05 +00:00
|
|
|
AddToUseList();
|
|
|
|
}
|
|
|
|
ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
|
|
|
|
: PrevPair(0, Kind), Next(0), VP(RHS.VP) {
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP))
|
2009-03-31 22:11:05 +00:00
|
|
|
AddToExistingUseList(RHS.getPrevPtr());
|
|
|
|
}
|
|
|
|
~ValueHandleBase() {
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP))
|
2009-09-19 20:40:05 +00:00
|
|
|
RemoveFromUseList();
|
2009-03-31 22:11:05 +00:00
|
|
|
}
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
Value *operator=(Value *RHS) {
|
|
|
|
if (VP == RHS) return RHS;
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP)) RemoveFromUseList();
|
2009-03-31 22:11:05 +00:00
|
|
|
VP = RHS;
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP)) AddToUseList();
|
2009-03-31 22:11:05 +00:00
|
|
|
return RHS;
|
|
|
|
}
|
|
|
|
|
|
|
|
Value *operator=(const ValueHandleBase &RHS) {
|
|
|
|
if (VP == RHS.VP) return RHS.VP;
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP)) RemoveFromUseList();
|
2009-03-31 22:11:05 +00:00
|
|
|
VP = RHS.VP;
|
2009-07-31 18:20:18 +00:00
|
|
|
if (isValid(VP)) AddToExistingUseList(RHS.getPrevPtr());
|
2009-03-31 22:11:05 +00:00
|
|
|
return VP;
|
|
|
|
}
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
Value *operator->() const { return getValPtr(); }
|
|
|
|
Value &operator*() const { return *getValPtr(); }
|
2009-04-27 20:32:07 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
protected:
|
|
|
|
Value *getValPtr() const { return VP; }
|
2009-07-31 18:20:18 +00:00
|
|
|
static bool isValid(Value *V) {
|
|
|
|
return V &&
|
|
|
|
V != DenseMapInfo<Value *>::getEmptyKey() &&
|
|
|
|
V != DenseMapInfo<Value *>::getTombstoneKey();
|
|
|
|
}
|
|
|
|
|
2009-09-22 02:02:33 +00:00
|
|
|
private:
|
2009-03-31 22:11:05 +00:00
|
|
|
// Callbacks made from Value.
|
|
|
|
static void ValueIsDeleted(Value *V);
|
|
|
|
static void ValueIsRAUWd(Value *Old, Value *New);
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
// Internal implementation details.
|
|
|
|
ValueHandleBase **getPrevPtr() const { return PrevPair.getPointer(); }
|
|
|
|
HandleBaseKind getKind() const { return PrevPair.getInt(); }
|
|
|
|
void setPrevPtr(ValueHandleBase **Ptr) { PrevPair.setPointer(Ptr); }
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-10-12 17:43:32 +00:00
|
|
|
/// AddToExistingUseList - Add this ValueHandle to the use list for VP, where
|
|
|
|
/// List is the address of either the head of the list or a Next node within
|
|
|
|
/// the existing use list.
|
2009-03-31 22:11:05 +00:00
|
|
|
void AddToExistingUseList(ValueHandleBase **List);
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-10-12 17:43:32 +00:00
|
|
|
/// AddToExistingUseListAfter - Add this ValueHandle to the use list after
|
|
|
|
/// Node.
|
|
|
|
void AddToExistingUseListAfter(ValueHandleBase *Node);
|
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
/// AddToUseList - Add this ValueHandle to the use list for VP.
|
|
|
|
void AddToUseList();
|
|
|
|
/// RemoveFromUseList - Remove this ValueHandle from its current use list.
|
|
|
|
void RemoveFromUseList();
|
|
|
|
};
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
/// WeakVH - This is a value handle that tries hard to point to a Value, even
|
|
|
|
/// across RAUW operations, but will null itself out if the value is destroyed.
|
|
|
|
/// this is useful for advisory sorts of information, but should not be used as
|
|
|
|
/// the key of a map (since the map would have to rearrange itself when the
|
|
|
|
/// pointer changes).
|
|
|
|
class WeakVH : public ValueHandleBase {
|
|
|
|
public:
|
|
|
|
WeakVH() : ValueHandleBase(Weak) {}
|
|
|
|
WeakVH(Value *P) : ValueHandleBase(Weak, P) {}
|
|
|
|
WeakVH(const WeakVH &RHS)
|
|
|
|
: ValueHandleBase(Weak, RHS) {}
|
|
|
|
|
2009-10-10 08:27:29 +00:00
|
|
|
Value *operator=(Value *RHS) {
|
|
|
|
return ValueHandleBase::operator=(RHS);
|
|
|
|
}
|
|
|
|
Value *operator=(const ValueHandleBase &RHS) {
|
|
|
|
return ValueHandleBase::operator=(RHS);
|
|
|
|
}
|
|
|
|
|
2009-03-31 23:09:51 +00:00
|
|
|
operator Value*() const {
|
|
|
|
return getValPtr();
|
|
|
|
}
|
2009-05-06 17:12:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Specialize simplify_type to allow WeakVH to participate in
|
|
|
|
// dyn_cast, isa, etc.
|
|
|
|
template<typename From> struct simplify_type;
|
|
|
|
template<> struct simplify_type<const WeakVH> {
|
|
|
|
typedef Value* SimpleType;
|
|
|
|
static SimpleType getSimplifiedValue(const WeakVH &WVH) {
|
|
|
|
return static_cast<Value *>(WVH);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<> struct simplify_type<WeakVH> : public simplify_type<const WeakVH> {};
|
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
/// AssertingVH - This is a Value Handle that points to a value and asserts out
|
|
|
|
/// if the value is destroyed while the handle is still live. This is very
|
|
|
|
/// useful for catching dangling pointer bugs and other things which can be
|
|
|
|
/// non-obvious. One particularly useful place to use this is as the Key of a
|
|
|
|
/// map. Dangling pointer bugs often lead to really subtle bugs that only occur
|
|
|
|
/// if another object happens to get allocated to the same address as the old
|
|
|
|
/// one. Using an AssertingVH ensures that an assert is triggered as soon as
|
|
|
|
/// the bad delete occurs.
|
|
|
|
///
|
|
|
|
/// Note that an AssertingVH handle does *not* follow values across RAUW
|
|
|
|
/// operations. This means that RAUW's need to explicitly update the
|
|
|
|
/// AssertingVH's as it moves. This is required because in non-assert mode this
|
2009-04-19 18:20:21 +00:00
|
|
|
/// class turns into a trivial wrapper around a pointer.
|
2009-04-02 23:53:03 +00:00
|
|
|
template <typename ValueTy>
|
2009-09-19 20:40:05 +00:00
|
|
|
class AssertingVH
|
2009-03-31 22:11:05 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
: public ValueHandleBase
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
ValueTy *getValPtr() const {
|
|
|
|
return static_cast<ValueTy*>(ValueHandleBase::getValPtr());
|
|
|
|
}
|
|
|
|
void setValPtr(ValueTy *P) {
|
2009-08-07 19:54:29 +00:00
|
|
|
ValueHandleBase::operator=(GetAsValue(P));
|
2009-03-31 22:11:05 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
ValueTy *ThePtr;
|
|
|
|
ValueTy *getValPtr() const { return ThePtr; }
|
|
|
|
void setValPtr(ValueTy *P) { ThePtr = P; }
|
|
|
|
#endif
|
|
|
|
|
2009-08-07 19:54:29 +00:00
|
|
|
// Convert a ValueTy*, which may be const, to the type the base
|
|
|
|
// class expects.
|
|
|
|
static Value *GetAsValue(Value *V) { return V; }
|
|
|
|
static Value *GetAsValue(const Value *V) { return const_cast<Value*>(V); }
|
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
public:
|
|
|
|
#ifndef NDEBUG
|
|
|
|
AssertingVH() : ValueHandleBase(Assert) {}
|
2009-08-07 19:54:29 +00:00
|
|
|
AssertingVH(ValueTy *P) : ValueHandleBase(Assert, GetAsValue(P)) {}
|
2009-03-31 22:11:05 +00:00
|
|
|
AssertingVH(const AssertingVH &RHS) : ValueHandleBase(Assert, RHS) {}
|
|
|
|
#else
|
|
|
|
AssertingVH() : ThePtr(0) {}
|
|
|
|
AssertingVH(ValueTy *P) : ThePtr(P) {}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
operator ValueTy*() const {
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueTy *operator=(ValueTy *RHS) {
|
|
|
|
setValPtr(RHS);
|
|
|
|
return getValPtr();
|
|
|
|
}
|
2009-09-19 20:39:50 +00:00
|
|
|
ValueTy *operator=(const AssertingVH<ValueTy> &RHS) {
|
2009-03-31 22:11:05 +00:00
|
|
|
setValPtr(RHS.getValPtr());
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueTy *operator->() const { return getValPtr(); }
|
2009-04-02 23:53:03 +00:00
|
|
|
ValueTy &operator*() const { return *getValPtr(); }
|
2009-03-31 22:11:05 +00:00
|
|
|
};
|
|
|
|
|
2009-05-06 17:12:48 +00:00
|
|
|
// Specialize simplify_type to allow AssertingVH to participate in
|
|
|
|
// dyn_cast, isa, etc.
|
|
|
|
template<typename From> struct simplify_type;
|
|
|
|
template<> struct simplify_type<const AssertingVH<Value> > {
|
|
|
|
typedef Value* SimpleType;
|
|
|
|
static SimpleType getSimplifiedValue(const AssertingVH<Value> &AVH) {
|
|
|
|
return static_cast<Value *>(AVH);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<> struct simplify_type<AssertingVH<Value> >
|
|
|
|
: public simplify_type<const AssertingVH<Value> > {};
|
|
|
|
|
2009-10-19 18:49:59 +00:00
|
|
|
// Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap.
|
|
|
|
template<typename T>
|
|
|
|
struct DenseMapInfo<AssertingVH<T> > {
|
|
|
|
typedef DenseMapInfo<T*> PointerInfo;
|
|
|
|
static inline AssertingVH<T> getEmptyKey() {
|
|
|
|
return AssertingVH<T>(PointerInfo::getEmptyKey());
|
|
|
|
}
|
|
|
|
static inline T* getTombstoneKey() {
|
|
|
|
return AssertingVH<T>(PointerInfo::getTombstoneKey());
|
|
|
|
}
|
|
|
|
static unsigned getHashValue(const AssertingVH<T> &Val) {
|
|
|
|
return PointerInfo::getHashValue(Val);
|
|
|
|
}
|
|
|
|
static bool isEqual(const AssertingVH<T> &LHS, const AssertingVH<T> &RHS) {
|
|
|
|
return LHS == RHS;
|
|
|
|
}
|
2009-12-15 07:26:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct isPodLike<AssertingVH<T> > {
|
2009-10-19 18:49:59 +00:00
|
|
|
#ifdef NDEBUG
|
2009-12-15 07:26:43 +00:00
|
|
|
static const bool value = true;
|
2009-10-19 18:49:59 +00:00
|
|
|
#else
|
2009-12-15 07:26:43 +00:00
|
|
|
static const bool value = false;
|
2009-10-19 18:49:59 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2009-12-15 07:26:43 +00:00
|
|
|
|
2009-09-22 02:02:33 +00:00
|
|
|
/// TrackingVH - This is a value handle that tracks a Value (or Value subclass),
|
|
|
|
/// even across RAUW operations.
|
|
|
|
///
|
|
|
|
/// TrackingVH is designed for situations where a client needs to hold a handle
|
|
|
|
/// to a Value (or subclass) across some operations which may move that value,
|
|
|
|
/// but should never destroy it or replace it with some unacceptable type.
|
|
|
|
///
|
|
|
|
/// It is an error to do anything with a TrackingVH whose value has been
|
|
|
|
/// destroyed, except to destruct it.
|
|
|
|
///
|
|
|
|
/// It is an error to attempt to replace a value with one of a type which is
|
|
|
|
/// incompatible with any of its outstanding TrackingVHs.
|
|
|
|
template<typename ValueTy>
|
|
|
|
class TrackingVH : public ValueHandleBase {
|
|
|
|
void CheckValidity() const {
|
|
|
|
Value *VP = ValueHandleBase::getValPtr();
|
|
|
|
|
|
|
|
// Null is always ok.
|
2010-03-31 03:34:40 +00:00
|
|
|
if (!VP) return;
|
2009-09-22 02:02:33 +00:00
|
|
|
|
|
|
|
// Check that this value is valid (i.e., it hasn't been deleted). We
|
|
|
|
// explicitly delay this check until access to avoid requiring clients to be
|
|
|
|
// unnecessarily careful w.r.t. destruction.
|
|
|
|
assert(ValueHandleBase::isValid(VP) && "Tracked Value was deleted!");
|
|
|
|
|
|
|
|
// Check that the value is a member of the correct subclass. We would like
|
|
|
|
// to check this property on assignment for better debugging, but we don't
|
|
|
|
// want to require a virtual interface on this VH. Instead we allow RAUW to
|
|
|
|
// replace this value with a value of an invalid type, and check it here.
|
|
|
|
assert(isa<ValueTy>(VP) &&
|
|
|
|
"Tracked Value was replaced by one with an invalid type!");
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueTy *getValPtr() const {
|
|
|
|
CheckValidity();
|
2010-03-30 23:03:27 +00:00
|
|
|
return (ValueTy*)ValueHandleBase::getValPtr();
|
2009-09-22 02:02:33 +00:00
|
|
|
}
|
|
|
|
void setValPtr(ValueTy *P) {
|
|
|
|
CheckValidity();
|
|
|
|
ValueHandleBase::operator=(GetAsValue(P));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a ValueTy*, which may be const, to the type the base
|
|
|
|
// class expects.
|
|
|
|
static Value *GetAsValue(Value *V) { return V; }
|
|
|
|
static Value *GetAsValue(const Value *V) { return const_cast<Value*>(V); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
TrackingVH() : ValueHandleBase(Tracking) {}
|
2010-04-14 22:24:25 +00:00
|
|
|
TrackingVH(ValueTy *P) : ValueHandleBase(Tracking, GetAsValue(P)) {}
|
2009-09-22 02:02:33 +00:00
|
|
|
TrackingVH(const TrackingVH &RHS) : ValueHandleBase(Tracking, RHS) {}
|
|
|
|
|
|
|
|
operator ValueTy*() const {
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueTy *operator=(ValueTy *RHS) {
|
|
|
|
setValPtr(RHS);
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
ValueTy *operator=(const TrackingVH<ValueTy> &RHS) {
|
|
|
|
setValPtr(RHS.getValPtr());
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueTy *operator->() const { return getValPtr(); }
|
|
|
|
ValueTy &operator*() const { return *getValPtr(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialize simplify_type to allow TrackingVH to participate in
|
|
|
|
// dyn_cast, isa, etc.
|
|
|
|
template<typename From> struct simplify_type;
|
|
|
|
template<> struct simplify_type<const TrackingVH<Value> > {
|
|
|
|
typedef Value* SimpleType;
|
|
|
|
static SimpleType getSimplifiedValue(const TrackingVH<Value> &AVH) {
|
|
|
|
return static_cast<Value *>(AVH);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<> struct simplify_type<TrackingVH<Value> >
|
|
|
|
: public simplify_type<const TrackingVH<Value> > {};
|
|
|
|
|
2009-05-02 21:10:48 +00:00
|
|
|
/// CallbackVH - This is a value handle that allows subclasses to define
|
|
|
|
/// callbacks that run when the underlying Value has RAUW called on it or is
|
|
|
|
/// destroyed. This class can be used as the key of a map, as long as the user
|
|
|
|
/// takes it out of the map before calling setValPtr() (since the map has to
|
|
|
|
/// rearrange itself when the pointer changes). Unlike ValueHandleBase, this
|
|
|
|
/// class has a vtable and a virtual destructor.
|
|
|
|
class CallbackVH : public ValueHandleBase {
|
|
|
|
protected:
|
|
|
|
CallbackVH(const CallbackVH &RHS)
|
|
|
|
: ValueHandleBase(Callback, RHS) {}
|
|
|
|
|
|
|
|
virtual ~CallbackVH();
|
|
|
|
|
|
|
|
void setValPtr(Value *P) {
|
|
|
|
ValueHandleBase::operator=(P);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
CallbackVH() : ValueHandleBase(Callback) {}
|
|
|
|
CallbackVH(Value *P) : ValueHandleBase(Callback, P) {}
|
|
|
|
|
|
|
|
operator Value*() const {
|
|
|
|
return getValPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Called when this->getValPtr() is destroyed, inside ~Value(), so you may
|
|
|
|
/// call any non-virtual Value method on getValPtr(), but no subclass methods.
|
|
|
|
/// If WeakVH were implemented as a CallbackVH, it would use this method to
|
|
|
|
/// call setValPtr(NULL). AssertingVH would use this method to cause an
|
|
|
|
/// assertion failure.
|
|
|
|
///
|
|
|
|
/// All implementations must remove the reference from this object to the
|
|
|
|
/// Value that's being destroyed.
|
|
|
|
virtual void deleted() {
|
|
|
|
setValPtr(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called,
|
|
|
|
/// _before_ any of the uses have actually been replaced. If WeakVH were
|
|
|
|
/// implemented as a CallbackVH, it would use this method to call
|
|
|
|
/// setValPtr(new_value). AssertingVH would do nothing in this method.
|
2009-10-17 23:56:18 +00:00
|
|
|
virtual void allUsesReplacedWith(Value *) {}
|
2009-05-02 21:10:48 +00:00
|
|
|
};
|
|
|
|
|
2009-05-06 17:12:48 +00:00
|
|
|
// Specialize simplify_type to allow CallbackVH to participate in
|
|
|
|
// dyn_cast, isa, etc.
|
|
|
|
template<typename From> struct simplify_type;
|
|
|
|
template<> struct simplify_type<const CallbackVH> {
|
|
|
|
typedef Value* SimpleType;
|
|
|
|
static SimpleType getSimplifiedValue(const CallbackVH &CVH) {
|
|
|
|
return static_cast<Value *>(CVH);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<> struct simplify_type<CallbackVH>
|
|
|
|
: public simplify_type<const CallbackVH> {};
|
|
|
|
|
2009-03-31 22:11:05 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|