[cfe-commits] r153884 - in /cfe/trunk: lib/AST/StmtProfile.cpp test/SemaTemplate/canonical-expr-type-0x.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Mon Apr 2 11:53:25 PDT 2012
Author: rsmith
Date: Mon Apr 2 13:53:24 2012
New Revision: 153884
URL: http://llvm.org/viewvc/llvm-project?rev=153884&view=rev
Log:
PR12438: Profile a reference to a type template parameter by depth and index,
not by canonical decl. This only matters for sizeof...(Pack) expressions; in
all other cases, we'd profile it as a type instead.
Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/SemaTemplate/canonical-expr-type-0x.cpp
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=153884&r1=153883&r2=153884&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Apr 2 13:53:24 2012
@@ -1083,6 +1083,14 @@
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());
Modified: cfe/trunk/test/SemaTemplate/canonical-expr-type-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/canonical-expr-type-0x.cpp?rev=153884&r1=153883&r2=153884&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/canonical-expr-type-0x.cpp (original)
+++ cfe/trunk/test/SemaTemplate/canonical-expr-type-0x.cpp Mon Apr 2 13:53:24 2012
@@ -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}}
More information about the cfe-commits
mailing list