Clarify the difference between substitution and instantiation by renaming

functions that don't instantiate definitions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80037 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2009-08-25 22:02:44 +00:00
Родитель 3ac6a0b8a3
Коммит ce3ff2bd3a
6 изменённых файлов: 118 добавлений и 119 удалений

Просмотреть файл

@ -2858,22 +2858,20 @@ public:
void PerformPendingImplicitInstantiations();
QualType InstantiateType(QualType T, const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity);
QualType SubstType(QualType T, const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity);
OwningExprResult InstantiateExpr(Expr *E,
const TemplateArgumentList &TemplateArgs);
OwningExprResult SubstExpr(Expr *E, const TemplateArgumentList &TemplateArgs);
OwningStmtResult InstantiateStmt(Stmt *S,
const TemplateArgumentList &TemplateArgs);
OwningStmtResult SubstStmt(Stmt *S, const TemplateArgumentList &TemplateArgs);
Decl *InstantiateDecl(Decl *D, DeclContext *Owner,
const TemplateArgumentList &TemplateArgs);
Decl *SubstDecl(Decl *D, DeclContext *Owner,
const TemplateArgumentList &TemplateArgs);
bool
InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const TemplateArgumentList &TemplateArgs);
SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const TemplateArgumentList &TemplateArgs);
bool
InstantiateTemplatePattern(SourceLocation PointOfInstantiation,
@ -2900,25 +2898,25 @@ public:
ClassTemplateSpecializationDecl *ClassTemplateSpec);
NestedNameSpecifier *
InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
const TemplateArgumentList &TemplateArgs);
SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
const TemplateArgumentList &TemplateArgs);
TemplateName
InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
const TemplateArgumentList &TemplateArgs);
TemplateArgument Instantiate(TemplateArgument Arg,
const TemplateArgumentList &TemplateArgs);
SubstTemplateName(TemplateName Name, SourceLocation Loc,
const TemplateArgumentList &TemplateArgs);
TemplateArgument Subst(TemplateArgument Arg,
const TemplateArgumentList &TemplateArgs);
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
FunctionDecl *Function,
bool Recursive = false);
void InstantiateStaticDataMemberDefinition(
SourceLocation PointOfInstantiation,
VarDecl *Var,
bool Recursive = false);
SourceLocation PointOfInstantiation,
VarDecl *Var,
bool Recursive = false);
NamedDecl *InstantiateCurrentDeclRef(NamedDecl *D);
NamedDecl *FindInstantiatedDecl(NamedDecl *D);
// Objective-C declarations.
virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,

Просмотреть файл

@ -2452,7 +2452,7 @@ Sema::OwningExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
ArgList.getFlatArgumentList(),
ArgList.flat_size());
OwningExprResult Result = InstantiateExpr(UninstExpr, ArgList);
OwningExprResult Result = SubstExpr(UninstExpr, ArgList);
if (Result.isInvalid())
return ExprError();

Просмотреть файл

@ -1234,9 +1234,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
ArgType = InstantiateType(ArgType, TemplateArgs,
TTP->getDefaultArgumentLoc(),
TTP->getDeclName());
ArgType = SubstType(ArgType, TemplateArgs,
TTP->getDefaultArgumentLoc(),
TTP->getDeclName());
}
if (ArgType.isNull())
@ -1256,8 +1256,8 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
Sema::OwningExprResult E = InstantiateExpr(NTTP->getDefaultArgument(),
TemplateArgs);
Sema::OwningExprResult E = SubstExpr(NTTP->getDefaultArgument(),
TemplateArgs);
if (E.isInvalid())
return true;
@ -1269,7 +1269,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
if (!TempParm->hasDefaultArgument())
break;
// FIXME: Instantiate default argument
// FIXME: Subst default argument
Arg = TemplateArgument(TempParm->getDefaultArgument());
}
} else {
@ -1296,11 +1296,11 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
= dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
// Check non-type template parameters.
// Instantiate the type of the non-type template parameter with
// the template arguments we've seen thus far.
// Do substitution on the type of the non-type template parameter
// with the template arguments we've seen thus far.
QualType NTTPType = NTTP->getType();
if (NTTPType->isDependentType()) {
// Instantiate the type of the non-type template parameter.
// Do substitution on the type of the non-type template parameter.
InstantiatingTemplate Inst(*this, TemplateLoc,
Template, Converted.getFlatArguments(),
Converted.flatSize(),
@ -1308,9 +1308,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
NTTPType = InstantiateType(NTTPType, TemplateArgs,
NTTP->getLocation(),
NTTP->getDeclName());
NTTPType = SubstType(NTTPType, TemplateArgs,
NTTP->getLocation(),
NTTP->getDeclName());
// If that worked, check the non-type template parameter type
// for validity.
if (!NTTPType.isNull())
@ -2931,7 +2931,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc,
getTemplateInstantiationArgs(Record),
/*ExplicitInstantiation=*/true))
return true;
} else // Instantiate all of the members of class.
} else // Instantiate all of the members of the class.
InstantiateClassMembers(TemplateLoc, Record,
getTemplateInstantiationArgs(Record));

Просмотреть файл

@ -967,8 +967,8 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
for (unsigned I = 0, N = PartialTemplateArgs.flat_size(); I != N; ++I) {
Decl *Param = const_cast<Decl *>(
ClassTemplate->getTemplateParameters()->getParam(I));
TemplateArgument InstArg = Instantiate(PartialTemplateArgs[I],
*DeducedArgumentList);
TemplateArgument InstArg = Subst(PartialTemplateArgs[I],
*DeducedArgumentList);
if (InstArg.isNull()) {
Info.Param = makeTemplateParameter(Param);
Info.FirstArg = PartialTemplateArgs[I];
@ -1118,10 +1118,10 @@ Sema::SubstituteExplicitTemplateArguments(
PEnd = Function->param_end();
P != PEnd;
++P) {
QualType ParamType = InstantiateType((*P)->getType(),
*ExplicitArgumentList,
(*P)->getLocation(),
(*P)->getDeclName());
QualType ParamType = SubstType((*P)->getType(),
*ExplicitArgumentList,
(*P)->getLocation(),
(*P)->getDeclName());
if (ParamType.isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
@ -1136,10 +1136,10 @@ Sema::SubstituteExplicitTemplateArguments(
= Function->getType()->getAsFunctionProtoType();
assert(Proto && "Function template does not have a prototype?");
QualType ResultType = InstantiateType(Proto->getResultType(),
*ExplicitArgumentList,
Function->getTypeSpecStartLoc(),
Function->getDeclName());
QualType ResultType = SubstType(Proto->getResultType(),
*ExplicitArgumentList,
Function->getTypeSpecStartLoc(),
Function->getDeclName());
if (ResultType.isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
@ -1213,9 +1213,9 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
// Substitute the deduced template arguments into the function template
// declaration to produce the function template specialization.
Specialization = cast_or_null<FunctionDecl>(
InstantiateDecl(FunctionTemplate->getTemplatedDecl(),
FunctionTemplate->getDeclContext(),
*DeducedArgumentList));
SubstDecl(FunctionTemplate->getTemplatedDecl(),
FunctionTemplate->getDeclContext(),
*DeducedArgumentList));
if (!Specialization)
return TDK_SubstitutionFailure;

Просмотреть файл

@ -355,11 +355,11 @@ Decl *TemplateInstantiator::TransformDecl(Decl *D) {
return Template;
}
return SemaRef.InstantiateCurrentDeclRef(cast_or_null<NamedDecl>(D));
return SemaRef.FindInstantiatedDecl(cast_or_null<NamedDecl>(D));
}
Decl *TemplateInstantiator::TransformDefinition(Decl *D) {
Decl *Inst = getSema().InstantiateDecl(D, getSema().CurContext, TemplateArgs);
Decl *Inst = getSema().SubstDecl(D, getSema().CurContext, TemplateArgs);
if (!Inst)
return 0;
@ -441,7 +441,7 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
false, false));
}
NamedDecl *InstD = SemaRef.InstantiateCurrentDeclRef(D);
NamedDecl *InstD = SemaRef.FindInstantiatedDecl(D);
if (!InstD)
return SemaRef.ExprError();
@ -485,7 +485,8 @@ TemplateInstantiator::TransformTemplateTypeParmType(
T->getName());
}
/// \brief Instantiate the type T with a given set of template arguments.
/// \brief Perform substitution on the type T with a given set of template
/// arguments.
///
/// This routine substitutes the given template arguments into the
/// type T and produces the instantiated type.
@ -511,9 +512,9 @@ TemplateInstantiator::TransformTemplateTypeParmType(
///
/// \returns If the instantiation succeeds, the instantiated
/// type. Otherwise, produces diagnostics and returns a NULL type.
QualType Sema::InstantiateType(QualType T,
const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity) {
QualType Sema::SubstType(QualType T,
const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity) {
assert(!ActiveTemplateInstantiations.empty() &&
"Cannot perform an instantiation without some context on the "
"instantiation stack");
@ -526,16 +527,16 @@ QualType Sema::InstantiateType(QualType T,
return Instantiator.TransformType(T);
}
/// \brief Instantiate the base class specifiers of the given class
/// template specialization.
/// \brief Perform substitution on the base class specifiers of the
/// given class template specialization.
///
/// Produces a diagnostic and returns true on error, returns false and
/// attaches the instantiated base classes to the class template
/// specialization if successful.
bool
Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const TemplateArgumentList &TemplateArgs) {
Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const TemplateArgumentList &TemplateArgs) {
bool Invalid = false;
llvm::SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
for (ClassTemplateSpecializationDecl::base_class_iterator
@ -546,10 +547,10 @@ Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
continue;
}
QualType BaseType = InstantiateType(Base->getType(),
TemplateArgs,
Base->getSourceRange().getBegin(),
DeclarationName());
QualType BaseType = SubstType(Base->getType(),
TemplateArgs,
Base->getSourceRange().getBegin(),
DeclarationName());
if (BaseType.isNull()) {
Invalid = true;
continue;
@ -675,15 +676,15 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
// Start the definition of this instantiation.
Instantiation->startDefinition();
// Instantiate the base class specifiers.
if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
// Do substitution on the base class specifiers.
if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
Invalid = true;
llvm::SmallVector<DeclPtrTy, 4> Fields;
for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
MemberEnd = Pattern->decls_end();
Member != MemberEnd; ++Member) {
Decl *NewMember = InstantiateDecl(*Member, Instantiation, TemplateArgs);
Decl *NewMember = SubstDecl(*Member, Instantiation, TemplateArgs);
if (NewMember) {
if (NewMember->isInvalidDecl())
Invalid = true;
@ -813,13 +814,13 @@ Sema::InstantiateClassTemplateSpecialization(
return Result;
}
/// \brief Instantiate the definitions of all of the member of the
/// given class, which is an instantiation of a class template or a
/// member class of a template.
/// \brief Instantiates the definitions of all of the member
/// of the given class, which is an instantiation of a class template
/// or a member class of a template.
void
Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
CXXRecordDecl *Instantiation,
const TemplateArgumentList &TemplateArgs) {
CXXRecordDecl *Instantiation,
const TemplateArgumentList &TemplateArgs) {
for (DeclContext::decl_iterator D = Instantiation->decls_begin(),
DEnd = Instantiation->decls_end();
D != DEnd; ++D) {
@ -860,7 +861,7 @@ void Sema::InstantiateClassTemplateSpecializationMembers(
}
Sema::OwningStmtResult
Sema::InstantiateStmt(Stmt *S, const TemplateArgumentList &TemplateArgs) {
Sema::SubstStmt(Stmt *S, const TemplateArgumentList &TemplateArgs) {
if (!S)
return Owned(S);
@ -871,7 +872,7 @@ Sema::InstantiateStmt(Stmt *S, const TemplateArgumentList &TemplateArgs) {
}
Sema::OwningExprResult
Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
Sema::SubstExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
if (!E)
return Owned(E);
@ -881,9 +882,9 @@ Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
return Instantiator.TransformExpr(E);
}
/// \brief Instantiate a nested-name-specifier.
/// \brief Do template substitution on a nested-name-specifier.
NestedNameSpecifier *
Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
Sema::SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
const TemplateArgumentList &TemplateArgs) {
TemplateInstantiator Instantiator(*this, TemplateArgs, Range.getBegin(),
@ -892,15 +893,15 @@ Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
}
TemplateName
Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
const TemplateArgumentList &TemplateArgs) {
Sema::SubstTemplateName(TemplateName Name, SourceLocation Loc,
const TemplateArgumentList &TemplateArgs) {
TemplateInstantiator Instantiator(*this, TemplateArgs, Loc,
DeclarationName());
return Instantiator.TransformTemplateName(Name);
}
TemplateArgument Sema::Instantiate(TemplateArgument Arg,
const TemplateArgumentList &TemplateArgs) {
TemplateArgument Sema::Subst(TemplateArgument Arg,
const TemplateArgumentList &TemplateArgs) {
TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
DeclarationName());
return Instantiator.TransformTemplateArgument(Arg);

Просмотреть файл

@ -67,13 +67,13 @@ namespace {
}
// Helper functions for instantiating methods.
QualType InstantiateFunctionType(FunctionDecl *D,
QualType SubstFunctionType(FunctionDecl *D,
llvm::SmallVectorImpl<ParmVarDecl *> &Params);
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl);
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl);
TemplateParameterList *
InstantiateTemplateParams(TemplateParameterList *List);
SubstTemplateParams(TemplateParameterList *List);
};
}
@ -93,8 +93,8 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
bool Invalid = false;
QualType T = D->getUnderlyingType();
if (T->isDependentType()) {
T = SemaRef.InstantiateType(T, TemplateArgs,
D->getLocation(), D->getDeclName());
T = SemaRef.SubstType(T, TemplateArgs,
D->getLocation(), D->getDeclName());
if (T.isNull()) {
Invalid = true;
T = SemaRef.Context.IntTy;
@ -114,10 +114,10 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
}
Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
// Instantiate the type of the declaration
QualType T = SemaRef.InstantiateType(D->getType(), TemplateArgs,
D->getTypeSpecStartLoc(),
D->getDeclName());
// Do substitution on the type of the declaration
QualType T = SemaRef.SubstType(D->getType(), TemplateArgs,
D->getTypeSpecStartLoc(),
D->getDeclName());
if (T.isNull())
return 0;
@ -150,7 +150,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
if (D->getInit()) {
OwningExprResult Init
= SemaRef.InstantiateExpr(D->getInit(), TemplateArgs);
= SemaRef.SubstExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
Var->setInvalidDecl();
else
@ -171,8 +171,8 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
bool Invalid = false;
QualType T = D->getType();
if (T->isDependentType()) {
T = SemaRef.InstantiateType(T, TemplateArgs,
D->getLocation(), D->getDeclName());
T = SemaRef.SubstType(T, TemplateArgs,
D->getLocation(), D->getDeclName());
if (!T.isNull() && T->isFunctionType()) {
// C++ [temp.arg.type]p3:
// If a declaration acquires a function type through a type
@ -195,7 +195,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
OwningExprResult InstantiatedBitWidth
= SemaRef.InstantiateExpr(BitWidth, TemplateArgs);
= SemaRef.SubstExpr(BitWidth, TemplateArgs);
if (InstantiatedBitWidth.isInvalid()) {
Invalid = true;
BitWidth = 0;
@ -225,8 +225,8 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
Decl *TemplateDeclInstantiator::VisitFriendClassDecl(FriendClassDecl *D) {
QualType T = D->getFriendType();
if (T->isDependentType()) {
T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(),
DeclarationName());
T = SemaRef.SubstType(T, TemplateArgs, D->getLocation(),
DeclarationName());
assert(T.isNull() || getLangOptions().CPlusPlus0x || T->isRecordType());
}
@ -248,7 +248,7 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
OwningExprResult InstantiatedAssertExpr
= SemaRef.InstantiateExpr(AssertExpr, TemplateArgs);
= SemaRef.SubstExpr(AssertExpr, TemplateArgs);
if (InstantiatedAssertExpr.isInvalid())
return 0;
@ -284,7 +284,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
EnterExpressionEvaluationContext Unevaluated(SemaRef,
Action::Unevaluated);
Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs);
Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
}
// Drop the initial value and continue.
@ -329,7 +329,7 @@ Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
TemplateParameterList *TempParams = D->getTemplateParameters();
TemplateParameterList *InstParams = InstantiateTemplateParams(TempParams);
TemplateParameterList *InstParams = SubstTemplateParams(TempParams);
if (!InstParams) return NULL;
CXXRecordDecl *Pattern = D->getTemplatedDecl();
@ -391,7 +391,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
QualType T = SubstFunctionType(D, Params);
if (T.isNull())
return 0;
@ -479,7 +479,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
Sema::LocalInstantiationScope Scope(SemaRef);
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = InstantiateFunctionType(D, Params);
QualType T = SubstFunctionType(D, Params);
if (T.isNull())
return 0;
@ -584,7 +584,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
}
ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
QualType OrigT = SemaRef.SubstType(D->getOriginalType(), TemplateArgs,
D->getLocation(), D->getDeclName());
if (OrigT.isNull())
return 0;
@ -640,9 +640,9 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
if (D->hasDefaultArgument()) {
QualType DefaultPattern = D->getDefaultArgument();
QualType DefaultInst
= SemaRef.InstantiateType(DefaultPattern, TemplateArgs,
D->getDefaultArgumentLoc(),
D->getDeclName());
= SemaRef.SubstType(DefaultPattern, TemplateArgs,
D->getDefaultArgumentLoc(),
D->getDeclName());
Inst->setDefaultArgument(DefaultInst,
D->getDefaultArgumentLoc(),
@ -652,8 +652,8 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
return Inst;
}
Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner,
const TemplateArgumentList &TemplateArgs) {
Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
const TemplateArgumentList &TemplateArgs) {
TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
return Instantiator.Visit(D);
}
@ -665,7 +665,7 @@ Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner,
///
/// \returns NULL if there was an error
TemplateParameterList *
TemplateDeclInstantiator::InstantiateTemplateParams(TemplateParameterList *L) {
TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {
// Get errors for all the parameters before bailing out.
bool Invalid = false;
@ -696,21 +696,21 @@ TemplateDeclInstantiator::InstantiateTemplateParams(TemplateParameterList *L) {
return InstL;
}
/// \brief Instantiates the type of the given function, including
/// instantiating all of the function parameters.
/// \brief Does substitution on the type of the given function, including
/// all of the function parameters.
///
/// \param D The function that we will be instantiated
/// \param D The function whose type will be the basis of the substitution
///
/// \param Params the instantiated parameter declarations
/// \returns the instantiated function's type if successfull, a NULL
/// \returns the instantiated function's type if successful, a NULL
/// type if there was an error.
QualType
TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
llvm::SmallVectorImpl<ParmVarDecl *> &Params) {
bool InvalidDecl = false;
// Instantiate the function parameters
// Substitute all of the function's formal parameter types.
TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
llvm::SmallVector<QualType, 4> ParamTys;
for (FunctionDecl::param_iterator P = D->param_begin(),
@ -742,8 +742,8 @@ TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
assert(Proto && "Missing prototype?");
QualType ResultType
= SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs,
D->getLocation(), D->getDeclName());
= SemaRef.SubstType(Proto->getResultType(), TemplateArgs,
D->getLocation(), D->getDeclName());
if (ResultType.isNull())
return QualType();
@ -881,7 +881,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
// Instantiate the function body.
OwningStmtResult Body
= InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function));
= SubstStmt(Pattern, getTemplateInstantiationArgs(Function));
ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body),
/*IsInstantiation=*/true);
@ -982,7 +982,7 @@ void Sema::InstantiateStaticDataMemberDefinition(
else
ActOnUninitializedDecl(DeclPtrTy::make(Var), false);
#else
Var = cast_or_null<VarDecl>(InstantiateDecl(Def, Var->getDeclContext(),
Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->getDeclContext(),
getTemplateInstantiationArgs(Var)));
#endif
@ -1068,7 +1068,7 @@ static NamedDecl *findInstantiationOf(ASTContext &Ctx,
/// X<T>::<Kind>::KnownValue) to its instantiation
/// (X<int>::<Kind>::KnownValue). InstantiateCurrentDeclRef() performs
/// this mapping from within the instantiation of X<int>.
NamedDecl * Sema::InstantiateCurrentDeclRef(NamedDecl *D) {
NamedDecl * Sema::FindInstantiatedDecl(NamedDecl *D) {
DeclContext *ParentDC = D->getDeclContext();
if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) {
// D is a local of some kind. Look into the map of local
@ -1077,7 +1077,7 @@ NamedDecl * Sema::InstantiateCurrentDeclRef(NamedDecl *D) {
}
if (NamedDecl *ParentDecl = dyn_cast<NamedDecl>(ParentDC)) {
ParentDecl = InstantiateCurrentDeclRef(ParentDecl);
ParentDecl = FindInstantiatedDecl(ParentDecl);
if (!ParentDecl)
return 0;