summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2010-07-18 16:45:46 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2010-07-18 16:45:46 +0000
commit9e73cae25ed0daabe163817938567e1159dc1283 (patch)
tree0dd4698474ff99253e2068f40128b37c999beefc /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent8ff89f5c025acd9e7ed2fed43ceadeaaf0951768 (diff)
downloadbcm5719-llvm-9e73cae25ed0daabe163817938567e1159dc1283.tar.gz
bcm5719-llvm-9e73cae25ed0daabe163817938567e1159dc1283.zip
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. llvm-svn: 108643
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 2fd35285324..79b5532aef7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud