[cfe-commits] r109583 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/current-instantiation.cpp

Douglas Gregor dgregor at apple.com
Wed Jul 28 08:14:14 PDT 2010


Author: dgregor
Date: Wed Jul 28 10:14:14 2010
New Revision: 109583

URL: http://llvm.org/viewvc/llvm-project?rev=109583&view=rev
Log:
Enable expression transformations in the current-instantiation
rebuilder, i.e., remove a silly short-sighted hack from long
ago. Thanks to Abramo Bagnara for the test case/bug report!

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/current-instantiation.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=109583&r1=109582&r2=109583&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jul 28 10:14:14 2010
@@ -5427,15 +5427,6 @@
       this->Loc = Loc;
       this->Entity = Entity;
     }
-      
-    /// \brief Transforms an expression by returning the expression itself
-    /// (an identity function).
-    ///
-    /// FIXME: This is completely unsafe; we will need to actually clone the
-    /// expressions.
-    Sema::OwningExprResult TransformExpr(Expr *E) {
-      return getSema().Owned(E->Retain());
-    }
   };
 }
 

Modified: cfe/trunk/test/SemaTemplate/current-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/current-instantiation.cpp?rev=109583&r1=109582&r2=109583&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/current-instantiation.cpp (original)
+++ cfe/trunk/test/SemaTemplate/current-instantiation.cpp Wed Jul 28 10:14:14 2010
@@ -164,3 +164,38 @@
   template<typename T>
   int X<T>::array[X<T>::value] = { 1, 2 };
 }
+
+namespace Expressions {
+  template <bool b>
+  struct Bool {
+    enum anonymous_enum { value = b };
+  };
+  struct True : public Bool<true> {};
+  struct False : public Bool<false> {};
+
+  template <typename T1, typename T2>
+  struct Is_Same : public False {};
+  template <typename T>
+  struct Is_Same<T, T> : public True {};
+
+  template <bool b, typename T = void>
+  struct Enable_If {};
+  template <typename T>
+  struct Enable_If<true, T>  {
+    typedef T type;
+  };
+
+  template <typename T>
+  class Class {
+  public:
+    template <typename U>
+    typename Enable_If<Is_Same<U, Class>::value, void>::type
+    foo();
+  };
+
+
+  template <typename T>
+  template <typename U>
+  typename Enable_If<Is_Same<U, Class<T> >::value, void>::type
+  Class<T>::foo() {}
+}





More information about the cfe-commits mailing list