diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-03-27 16:43:11 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-03-27 16:43:11 +0000 |
commit | 7fe65d691dcce550d53ec9310913aab67ab6d654 (patch) | |
tree | 50611d2f2aefa633c6eff80dab109c6a15e27a6a /include/llvm/Support/ValueHandle.h | |
parent | 00b3b5fbf4d07cd4c846daebda32686cbb1d9952 (diff) | |
download | llvm-7fe65d691dcce550d53ec9310913aab67ab6d654.tar.gz llvm-7fe65d691dcce550d53ec9310913aab67ab6d654.tar.bz2 llvm-7fe65d691dcce550d53ec9310913aab67ab6d654.tar.xz |
Cleanup the simplify_type implementation.
As far as simplify_type is concerned, there are 3 kinds of smart pointers:
* const correct: A 'const MyPtr<int> &' produces a 'const int*'. A
'MyPtr<int> &' produces a 'int *'.
* always const: Even a 'MyPtr<int> &' produces a 'const int*'.
* no const: Even a 'const MyPtr<int> &' produces a 'int*'.
This patch then does the following:
* Removes the unused specializations. Since they are unused, it is hard
to know which kind should be implemented.
* Make sure we don't drop const.
* Fix the default forwarding so that const correct pointer only need
one specialization.
* Simplifies the existing specializations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ValueHandle.h')
-rw-r--r-- | include/llvm/Support/ValueHandle.h | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index db44995d95..b49341c3ff 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -20,6 +20,7 @@ namespace llvm { class ValueHandleBase; +template<typename From> struct simplify_type; // ValueHandleBase** is only 4-byte aligned. template<> @@ -162,14 +163,12 @@ public: // 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> { +template<> struct simplify_type<WeakVH> { typedef Value* SimpleType; - static SimpleType getSimplifiedValue(const WeakVH &WVH) { - return static_cast<Value *>(WVH); + static SimpleType getSimplifiedValue(WeakVH &WVH) { + return WVH; } }; -template<> struct simplify_type<WeakVH> : public simplify_type<const WeakVH> {}; /// 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 @@ -236,18 +235,6 @@ public: ValueTy &operator*() const { return *getValPtr(); } }; -// 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> > {}; - // Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap. template<typename T> struct DenseMapInfo<AssertingVH<T> > { @@ -345,18 +332,6 @@ public: 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> > {}; - /// 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 @@ -399,18 +374,6 @@ public: virtual void allUsesReplacedWith(Value *); }; -// 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> {}; - } // End llvm namespace #endif |