]> granicus.if.org Git - clang/commitdiff
PR12438: Profile a reference to a type template parameter by depth and index,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 2 Apr 2012 18:53:24 +0000 (18:53 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 2 Apr 2012 18:53:24 +0000 (18:53 +0000)
not by canonical decl. This only matters for sizeof...(Pack) expressions; in
all other cases, we'd profile it as a type instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153884 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtProfile.cpp
test/SemaTemplate/canonical-expr-type-0x.cpp

index c999ed452605d73fc3d5613f591895f2c3f0b44f..e5526cea74afa4bfa68ae4f5640d468f79d55500 100644 (file)
@@ -1083,6 +1083,14 @@ void StmtProfiler::VisitDecl(const Decl *D) {
       return;
     }
 
+    if (const TemplateTypeParmDecl *TTP =
+          dyn_cast<TemplateTypeParmDecl>(D)) {
+      ID.AddInteger(TTP->getDepth());
+      ID.AddInteger(TTP->getIndex());
+      ID.AddBoolean(TTP->isParameterPack());
+      return;
+    }
+
     if (const TemplateTemplateParmDecl *TTP =
           dyn_cast<TemplateTemplateParmDecl>(D)) {
       ID.AddInteger(TTP->getDepth());
index 94ae360b43ef044f3d4ba2eb531211050d44f82f..d7379eadab1a52871e9d51ad96cea8397876e5fb 100644 (file)
@@ -2,15 +2,24 @@
 
 void f();
 
-// FIXME: would like to refer to the first function parameter in these test,
-// but that won't work (yet).
-
 // Test typeof(expr) canonicalization
 template<typename T, T N>
-void f0(T x, decltype(f(N)) y) { } // expected-note{{previous}}
+void f0(T x, decltype(f(N, x)) y) { } // expected-note{{previous}}
 
 template<typename T, T N>
-void f0(T x, decltype((f)(N)) y) { }
+void f0(T x, decltype((f)(N, x)) y) { }
 
 template<typename U, U M>
-void f0(U u, decltype(f(M))) { } // expected-error{{redefinition}}
+void f0(U u, decltype(f(M, u))) { } // expected-error{{redefinition}}
+
+// PR12438: Test sizeof...() canonicalization
+template<int> struct N {};
+
+template<typename...T>
+N<sizeof...(T)> f1() {} // expected-note{{previous}}
+
+template<typename, typename...T>
+N<sizeof...(T)> f1() {}
+
+template<class...U>
+N<sizeof...(U)> f1() {} // expected-error{{redefinition}}