forked from OSchip/llvm-project
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
This commit is contained in:
parent
8ff89f5c02
commit
9e73cae25e
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue