/// \param Converted the list of template arguments provided for template
/// parameters that precede \p Param in the template parameter list.
/// \returns the substituted template argument, or NULL if an error occurred.
-static TypeSourceInfo *
-SubstDefaultTemplateArgument(Sema &SemaRef,
- TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- TemplateTypeParmDecl *Param,
- SmallVectorImpl<TemplateArgument> &Converted) {
+static TypeSourceInfo *SubstDefaultTemplateArgument(
+ Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc,
+ SourceLocation RAngleLoc, TemplateTypeParmDecl *Param,
+ ArrayRef<TemplateArgument> SugaredConverted,
+ ArrayRef<TemplateArgument> CanonicalConverted) {
TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo();
// If the argument type is dependent, instantiate it now based
// on the previously-computed template arguments.
if (ArgType->getType()->isInstantiationDependentType()) {
- Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc,
- Param, Template, Converted,
+ Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Param, Template,
+ SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
if (Inst.isInvalid())
return nullptr;
// Only substitute for the innermost template argument list.
- MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted,
- /*Final=*/false);
+ MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
+ /*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
TemplateArgLists.addOuterTemplateArguments(None);
/// parameters that precede \p Param in the template parameter list.
///
/// \returns the substituted template argument, or NULL if an error occurred.
-static ExprResult
-SubstDefaultTemplateArgument(Sema &SemaRef,
- TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- NonTypeTemplateParmDecl *Param,
- SmallVectorImpl<TemplateArgument> &Converted) {
- Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc,
- Param, Template, Converted,
+static ExprResult SubstDefaultTemplateArgument(
+ Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc,
+ SourceLocation RAngleLoc, NonTypeTemplateParmDecl *Param,
+ ArrayRef<TemplateArgument> SugaredConverted,
+ ArrayRef<TemplateArgument> CanonicalConverted) {
+ Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Param, Template,
+ SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
if (Inst.isInvalid())
return ExprError();
// Only substitute for the innermost template argument list.
- MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted,
- /*Final=*/false);
+ MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
+ /*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
TemplateArgLists.addOuterTemplateArguments(None);
/// source-location information) that precedes the template name.
///
/// \returns the substituted template argument, or NULL if an error occurred.
-static TemplateName
-SubstDefaultTemplateArgument(Sema &SemaRef,
- TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- TemplateTemplateParmDecl *Param,
- SmallVectorImpl<TemplateArgument> &Converted,
- NestedNameSpecifierLoc &QualifierLoc) {
+static TemplateName SubstDefaultTemplateArgument(
+ Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc,
+ SourceLocation RAngleLoc, TemplateTemplateParmDecl *Param,
+ ArrayRef<TemplateArgument> SugaredConverted,
+ ArrayRef<TemplateArgument> CanonicalConverted,
+ NestedNameSpecifierLoc &QualifierLoc) {
Sema::InstantiatingTemplate Inst(
- SemaRef, TemplateLoc, TemplateParameter(Param), Template, Converted,
- SourceRange(TemplateLoc, RAngleLoc));
+ SemaRef, TemplateLoc, TemplateParameter(Param), Template,
+ SugaredConverted, SourceRange(TemplateLoc, RAngleLoc));
if (Inst.isInvalid())
return TemplateName();
// Only substitute for the innermost template argument list.
- MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted,
- /*Final=*/false);
+ MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted,
+ /*Final=*/true);
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
TemplateArgLists.addOuterTemplateArguments(None);
/// If the given template parameter has a default template
/// argument, substitute into that default template argument and
/// return the corresponding template argument.
-TemplateArgumentLoc
-Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- Decl *Param,
- SmallVectorImpl<TemplateArgument>
- &Converted,
- bool &HasDefaultArg) {
+TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(
+ TemplateDecl *Template, SourceLocation TemplateLoc,
+ SourceLocation RAngleLoc, Decl *Param,
+ ArrayRef<TemplateArgument> SugaredConverted,
+ ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg) {
HasDefaultArg = false;
if (TemplateTypeParmDecl *TypeParm = dyn_cast<TemplateTypeParmDecl>(Param)) {
return TemplateArgumentLoc();
HasDefaultArg = true;
- TypeSourceInfo *DI = SubstDefaultTemplateArgument(*this, Template,
- TemplateLoc,
- RAngleLoc,
- TypeParm,
- Converted);
+ TypeSourceInfo *DI = SubstDefaultTemplateArgument(
+ *this, Template, TemplateLoc, RAngleLoc, TypeParm, SugaredConverted,
+ CanonicalConverted);
if (DI)
return TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
return TemplateArgumentLoc();
HasDefaultArg = true;
- ExprResult Arg = SubstDefaultTemplateArgument(*this, Template,
- TemplateLoc,
- RAngleLoc,
- NonTypeParm,
- Converted);
+ ExprResult Arg = SubstDefaultTemplateArgument(
+ *this, Template, TemplateLoc, RAngleLoc, NonTypeParm, SugaredConverted,
+ CanonicalConverted);
if (Arg.isInvalid())
return TemplateArgumentLoc();
HasDefaultArg = true;
NestedNameSpecifierLoc QualifierLoc;
- TemplateName TName = SubstDefaultTemplateArgument(*this, Template,
- TemplateLoc,
- RAngleLoc,
- TempTempParm,
- Converted,
- QualifierLoc);
+ TemplateName TName = SubstDefaultTemplateArgument(
+ *this, Template, TemplateLoc, RAngleLoc, TempTempParm, SugaredConverted,
+ CanonicalConverted, QualifierLoc);
if (TName.isNull())
return TemplateArgumentLoc();
!Template->getDeclContext()->isDependentContext()) {
// Do substitution on the type of the non-type template parameter.
InstantiatingTemplate Inst(*this, TemplateLoc, Template, NTTP,
- CanonicalConverted,
+ SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
if (Inst.isInvalid())
return true;
- MultiLevelTemplateArgumentList MLTAL(Template, CanonicalConverted,
- /*Final=*/false);
+ MultiLevelTemplateArgumentList MLTAL(Template, SugaredConverted,
+ /*Final=*/true);
// If the parameter is a pack expansion, expand this slice of the pack.
if (auto *PET = NTTPType->getAs<PackExpansionType>()) {
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this,
Params =
SubstTemplateParams(Params, CurContext,
MultiLevelTemplateArgumentList(
- Template, CanonicalConverted, /*Final=*/false));
+ Template, SugaredConverted, /*Final=*/true));
if (!Params)
return true;
}
NewArgs);
TypeSourceInfo *ArgType = SubstDefaultTemplateArgument(
- *this, Template, TemplateLoc, RAngleLoc, TTP, CanonicalConverted);
+ *this, Template, TemplateLoc, RAngleLoc, TTP, SugaredConverted,
+ CanonicalConverted);
if (!ArgType)
return true;
NewArgs);
ExprResult E = SubstDefaultTemplateArgument(
- *this, Template, TemplateLoc, RAngleLoc, NTTP, CanonicalConverted);
+ *this, Template, TemplateLoc, RAngleLoc, NTTP, SugaredConverted,
+ CanonicalConverted);
if (E.isInvalid())
return true;
NestedNameSpecifierLoc QualifierLoc;
TemplateName Name = SubstDefaultTemplateArgument(
- *this, Template, TemplateLoc, RAngleLoc, TempParm, CanonicalConverted,
- QualifierLoc);
+ *this, Template, TemplateLoc, RAngleLoc, TempParm, SugaredConverted,
+ CanonicalConverted, QualifierLoc);
if (Name.isNull())
return true;
// template here, we just create this object to put a note into the
// context stack.
InstantiatingTemplate Inst(*this, RAngleLoc, Template, *Param,
- CanonicalConverted,
+ SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
if (Inst.isInvalid())
return true;
// itself, in case that substitution fails.
if (SugaredPackedArgsBuilder.empty()) {
LocalInstantiationScope Scope(S);
- MultiLevelTemplateArgumentList Args(Template, CanonicalOutput,
- /*Final=*/false);
+ MultiLevelTemplateArgumentList Args(Template, SugaredOutput,
+ /*Final=*/true);
if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
- NTTP, CanonicalOutput,
+ NTTP, SugaredOutput,
Template->getSourceRange());
if (Inst.isInvalid() ||
S.SubstType(NTTP->getType(), Args, NTTP->getLocation(),
return true;
} else if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
- TTP, CanonicalOutput,
+ TTP, SugaredOutput,
Template->getSourceRange());
if (Inst.isInvalid() || !S.SubstDecl(TTP, S.CurContext, Args))
return true;
DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param,
- CanonicalBuilder, HasDefaultArg);
+ SugaredBuilder, CanonicalBuilder, HasDefaultArg);
}
// If there was no default argument, deduction is incomplete.
PartialTemplArgInfo->RAngleLoc);
if (S.SubstTemplateArguments(PartialTemplArgInfo->arguments(),
- MultiLevelTemplateArgumentList(
- Partial,
- CanonicalDeducedArgumentList->asArray(),
- /*Final=*/false),
+ MultiLevelTemplateArgumentList(Partial,
+ SugaredBuilder,
+ /*Final=*/true),
InstArgs)) {
unsigned ArgIdx = InstArgs.size(), ParamIdx = ArgIdx;
if (ParamIdx >= Partial->getTemplateParameters()->size())
ExtParameterInfoBuilder ExtParamInfos;
MultiLevelTemplateArgumentList MLTAL(FunctionTemplate,
- CanonicalExplicitArgumentList->asArray(),
- /*Final=*/false);
+ SugaredExplicitArgumentList->asArray(),
+ /*Final=*/true);
// Instantiate the types of each of the function parameters given the
// explicitly-specified template arguments. If the function has a trailing