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/IR | |
parent | 00b3b5fbf4d07cd4c846daebda32686cbb1d9952 (diff) |
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/IR')
-rw-r--r-- | include/llvm/IR/Use.h | 8 | ||||
-rw-r--r-- | include/llvm/IR/User.h | 20 |
2 files changed, 9 insertions, 19 deletions
diff --git a/include/llvm/IR/Use.h b/include/llvm/IR/Use.h index 33a69c4686..4bc7ce5000 100644 --- a/include/llvm/IR/Use.h +++ b/include/llvm/IR/Use.h @@ -149,14 +149,14 @@ private: // casting operators. template<> struct simplify_type<Use> { typedef Value* SimpleType; - static SimpleType getSimplifiedValue(const Use &Val) { - return static_cast<SimpleType>(Val.get()); + static SimpleType getSimplifiedValue(Use &Val) { + return Val.get(); } }; template<> struct simplify_type<const Use> { - typedef Value* SimpleType; + typedef /*const*/ Value* SimpleType; static SimpleType getSimplifiedValue(const Use &Val) { - return static_cast<SimpleType>(Val.get()); + return Val.get(); } }; diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h index a4d0a5d7df..505bdeb178 100644 --- a/include/llvm/IR/User.h +++ b/include/llvm/IR/User.h @@ -183,27 +183,17 @@ public: template<> struct simplify_type<User::op_iterator> { typedef Value* SimpleType; - - static SimpleType getSimplifiedValue(const User::op_iterator &Val) { - return static_cast<SimpleType>(Val->get()); + static SimpleType getSimplifiedValue(User::op_iterator &Val) { + return Val->get(); } }; - -template<> struct simplify_type<const User::op_iterator> - : public simplify_type<User::op_iterator> {}; - template<> struct simplify_type<User::const_op_iterator> { - typedef Value* SimpleType; - - static SimpleType getSimplifiedValue(const User::const_op_iterator &Val) { - return static_cast<SimpleType>(Val->get()); + typedef /*const*/ Value* SimpleType; + static SimpleType getSimplifiedValue(User::const_op_iterator &Val) { + return Val->get(); } }; -template<> struct simplify_type<const User::const_op_iterator> - : public simplify_type<User::const_op_iterator> {}; - - // value_use_iterator::getOperandNo - Requires the definition of the User class. template<typename UserTy> unsigned value_use_iterator<UserTy>::getOperandNo() const { |