From: Douglas Gregor Date: Fri, 31 Jul 2009 15:45:02 +0000 (+0000) Subject: Canonicalize function parameters X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a3f780f4f74a80f9b4bc42e38ad60170d5ebd0c;p=clang Canonicalize function parameters git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77676 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 5714c682a2..791c4398fb 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -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(D)) { ID.AddInteger(NTTP->getDepth()); @@ -610,6 +612,16 @@ void StmtProfiler::VisitDecl(Decl *D) { return; } + if (ParmVarDecl *Parm = dyn_cast(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(D)) { diff --git a/test/SemaTemplate/canonical-expr-type.cpp b/test/SemaTemplate/canonical-expr-type.cpp index f8cc57bc1a..fec03c6076 100644 --- a/test/SemaTemplate/canonical-expr-type.cpp +++ b/test/SemaTemplate/canonical-expr-type.cpp @@ -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 -void f0(T x, __typeof__(f(N)) y) { } // expected-note{{previous}} +template +void f0(T x, __typeof__(f(x)) y) { } // expected-note{{previous}} -template -void f0(T x, __typeof__((f)(N)) y) { } +template +void f0(T x, __typeof__((f)(x)) y) { } -template -void f0(U u, __typeof__(f(M))) { } // expected-error{{redefinition}} +template +void f0(U u, __typeof__(f(u))) { } // expected-error{{redefinition}} // Test insane typeof(expr) overload set canonicalization void f(int);