diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2010-07-18 16:45:46 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2010-07-18 16:45:46 +0000 |
commit | 8a6c0f1a48b8167ca1457c9f05288fa637033dc9 (patch) | |
tree | 0c29b2c4ef3a07e767d75ffb13ce6bcd562f329a /lib | |
parent | 59f1ed2836ae0dbdade5579323c58ec229bb9453 (diff) |
When instantiating function definitions set parameter names to those used in template
The rationale is that we are copying the entire definition including
parameter names which may differ between the declaration and the
definition.
This is particularly important if any parameters are unnamed in the
declaration, as a DeclRef to an unnamed ParmVarDecl would cause the
pretty printer to produce invalid output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2fd3528532..79b5532aef 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2118,10 +2118,14 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, LocalInstantiationScope Scope(*this, MergeWithParentScope); // Introduce the instantiated function parameters into the local - // instantiation scope. - for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) - Scope.InstantiatedLocal(PatternDecl->getParamDecl(I), - Function->getParamDecl(I)); + // instantiation scope, and set the parameter names to those used + // in the template. + for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) { + const ParmVarDecl *PatternParam = PatternDecl->getParamDecl(I); + ParmVarDecl *FunctionParam = Function->getParamDecl(I); + FunctionParam->setDeclName(PatternParam->getDeclName()); + Scope.InstantiatedLocal(PatternParam, FunctionParam); + } // Enter the scope of this instantiation. We don't use // PushDeclContext because we don't have a scope. |