[llvm-commits] [llvm] r79023 - /llvm/trunk/include/llvm/Support/Casting.h

Argiris Kirtzidis akyrtzi at gmail.com
Fri Aug 14 12:01:38 PDT 2009


Author: akirtzidis
Date: Fri Aug 14 14:01:37 2009
New Revision: 79023

URL: http://llvm.org/viewvc/llvm-project?rev=79023&view=rev
Log:
Revert r78424.

In order for the changes in r78424 to work properly, cast_retty<X,Y> should return an object instead of a reference, and it's not clear that this approach has real advantages.

Modified:
    llvm/trunk/include/llvm/Support/Casting.h

Modified: llvm/trunk/include/llvm/Support/Casting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Casting.h?rev=79023&r1=79022&r2=79023&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Casting.h (original)
+++ llvm/trunk/include/llvm/Support/Casting.h Fri Aug 14 14:01:37 2009
@@ -205,9 +205,8 @@
 // accepted.
 //
 template <class X, class Y>
-inline typename cast_retty<X, Y>::ret_type cast_or_null(const Y &Val) {
-  typedef typename cast_retty<X, Y>::ret_type ret_type;
-  if (!Val) return ret_type();
+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 incompatible type!");
   return cast<X>(Val);
 }
@@ -223,8 +222,7 @@
 
 template <class X, class Y>
 inline typename cast_retty<X, Y>::ret_type dyn_cast(const Y &Val) {
-  typedef typename cast_retty<X, Y>::ret_type ret_type;
-  return isa<X>(Val) ? cast<X, Y>(Val) : (ret_type)ret_type();
+  return isa<X>(Val) ? cast<X, Y>(Val) : 0;
 }
 
 // dyn_cast_or_null<X> - Functionally identical to dyn_cast, except that a null
@@ -232,8 +230,7 @@
 //
 template <class X, class Y>
 inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(const Y &Val) {
-  typedef typename cast_retty<X, Y>::ret_type ret_type;
-  return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : (ret_type)ret_type();
+  return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0;
 }
 
 





More information about the llvm-commits mailing list