[cfe-commits] r77676 - in /cfe/trunk: lib/AST/StmtProfile.cpp test/SemaTemplate/canonical-expr-type.cpp
Douglas Gregor
dgregor at apple.com
Fri Jul 31 08:45:03 PDT 2009
Author: dgregor
Date: Fri Jul 31 10:45:02 2009
New Revision: 77676
URL: http://llvm.org/viewvc/llvm-project?rev=77676&view=rev
Log:
Canonicalize function parameters
Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/SemaTemplate/canonical-expr-type.cpp
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=77676&r1=77675&r2=77676&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Jul 31 10:45:02 2009
@@ -602,6 +602,8 @@
}
void StmtProfiler::VisitDecl(Decl *D) {
+ ID.AddInteger(D? D->getKind() : 0);
+
if (Canonical && D) {
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
ID.AddInteger(NTTP->getDepth());
@@ -610,6 +612,16 @@
return;
}
+ if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
+ // The Itanium C++ ABI uses the type of a parameter when mangling
+ // expressions that involve function parameters, so we will use the
+ // parameter's type for establishing function parameter identity. That
+ // way, our definition of "equivalent" (per C++ [temp.over.link])
+ // matches the definition of "equivalent" used for name mangling.
+ VisitType(Parm->getType());
+ return;
+ }
+
// FIXME: Template template parameters?
if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
Modified: cfe/trunk/test/SemaTemplate/canonical-expr-type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/canonical-expr-type.cpp?rev=77676&r1=77675&r2=77676&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/canonical-expr-type.cpp (original)
+++ cfe/trunk/test/SemaTemplate/canonical-expr-type.cpp Fri Jul 31 10:45:02 2009
@@ -2,18 +2,15 @@
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, __typeof__(f(N)) y) { } // expected-note{{previous}}
+template<typename T>
+void f0(T x, __typeof__(f(x)) y) { } // expected-note{{previous}}
-template<typename T, T N>
-void f0(T x, __typeof__((f)(N)) y) { }
+template<typename T>
+void f0(T x, __typeof__((f)(x)) y) { }
-template<typename U, U M>
-void f0(U u, __typeof__(f(M))) { } // expected-error{{redefinition}}
+template<typename U>
+void f0(U u, __typeof__(f(u))) { } // expected-error{{redefinition}}
// Test insane typeof(expr) overload set canonicalization
void f(int);
More information about the cfe-commits
mailing list