Canonicalize function parameters

llvm-svn: 77676
This commit is contained in:
Douglas Gregor 2009-07-31 15:45:02 +00:00
parent 7e7617edf8
commit 70317123c9
2 changed files with 18 additions and 9 deletions

View File

@ -602,6 +602,8 @@ void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
}
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 @@ void StmtProfiler::VisitDecl(Decl *D) {
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)) {

View File

@ -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);