[cfe-commits] r89654 - in /cfe/trunk: lib/AST/TemplateBase.cpp test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp

Douglas Gregor dgregor at apple.com
Mon Nov 23 04:52:48 PST 2009


Author: dgregor
Date: Mon Nov 23 06:52:47 2009
New Revision: 89654

URL: http://llvm.org/viewvc/llvm-project?rev=89654&view=rev
Log:
Canonical template arguments that are template template parameters by
their template parameter depth and position, so that we can match
redeclarations appropriately. Fixes PR5527 and PR5528.

Modified:
    cfe/trunk/lib/AST/TemplateBase.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp

Modified: cfe/trunk/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateBase.cpp?rev=89654&r1=89653&r2=89654&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TemplateBase.cpp (original)
+++ cfe/trunk/lib/AST/TemplateBase.cpp Mon Nov 23 06:52:47 2009
@@ -15,6 +15,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/TypeLoc.h"
 
@@ -59,8 +60,17 @@
     break;
 
   case Template:
-    ID.AddPointer(Context.getCanonicalTemplateName(getAsTemplate())
-                    .getAsVoidPointer());
+    if (TemplateTemplateParmDecl *TTP
+          = dyn_cast_or_null<TemplateTemplateParmDecl>(
+                                       getAsTemplate().getAsTemplateDecl())) {
+      ID.AddBoolean(true);
+      ID.AddInteger(TTP->getDepth());
+      ID.AddInteger(TTP->getPosition());
+    } else {
+      ID.AddBoolean(false);
+      ID.AddPointer(Context.getCanonicalTemplateName(getAsTemplate())
+                      .getAsVoidPointer());
+    }
     break;
       
   case Integral:

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp?rev=89654&r1=89653&r2=89654&view=diff

==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp Mon Nov 23 06:52:47 2009
@@ -1,5 +1,4 @@
 // RUN: clang-cc -fsyntax-only -verify %s
-
 template<typename T, typename U> // expected-note{{previous template}}
 class X0 {
 public:
@@ -77,3 +76,25 @@
 template<typename T>
 template<typename U>
 void X1<T>::template B<U>::f() { }
+
+// PR5527
+template <template <class> class T>
+class X2 {
+  template <class F>
+  class Bar {
+    void Func();
+  };
+};
+
+template <template <class> class T>
+template <class F>
+void X2<T>::Bar<F>::Func() {}
+
+// PR5528
+template <template <class> class T>
+class X3 {
+  void F();
+};
+
+template <template <class> class T>
+void X3<T>::F() {}





More information about the cfe-commits mailing list