@@ -3041,8 +3041,13 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
3041
3041
if (Trap.hasErrorOccurred ())
3042
3042
return Sema::TDK_SubstitutionFailure;
3043
3043
3044
- return ::FinishTemplateArgumentDeduction (
3045
- *this , Partial, /* IsPartialOrdering=*/ false , TemplateArgs, Deduced, Info);
3044
+ TemplateDeductionResult Result;
3045
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
3046
+ Result = ::FinishTemplateArgumentDeduction (*this , Partial,
3047
+ /* IsPartialOrdering=*/ false ,
3048
+ TemplateArgs, Deduced, Info);
3049
+ });
3050
+ return Result;
3046
3051
}
3047
3052
3048
3053
// / Perform template argument deduction to determine whether
@@ -3082,8 +3087,13 @@ Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
3082
3087
if (Trap.hasErrorOccurred ())
3083
3088
return Sema::TDK_SubstitutionFailure;
3084
3089
3085
- return ::FinishTemplateArgumentDeduction (
3086
- *this , Partial, /* IsPartialOrdering=*/ false , TemplateArgs, Deduced, Info);
3090
+ TemplateDeductionResult Result;
3091
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
3092
+ Result = ::FinishTemplateArgumentDeduction (*this , Partial,
3093
+ /* IsPartialOrdering=*/ false ,
3094
+ TemplateArgs, Deduced, Info);
3095
+ });
3096
+ return Result;
3087
3097
}
3088
3098
3089
3099
// / Determine whether the given type T is a simple-template-id type.
@@ -4032,13 +4042,12 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
4032
4042
SmallVector<QualType, 8 > ParamTypes;
4033
4043
unsigned NumExplicitlySpecified = 0 ;
4034
4044
if (ExplicitTemplateArgs) {
4035
- TemplateDeductionResult Result =
4036
- SubstituteExplicitTemplateArguments (FunctionTemplate,
4037
- *ExplicitTemplateArgs,
4038
- Deduced,
4039
- ParamTypes,
4040
- nullptr ,
4041
- Info);
4045
+ TemplateDeductionResult Result;
4046
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
4047
+ Result = SubstituteExplicitTemplateArguments (
4048
+ FunctionTemplate, *ExplicitTemplateArgs, Deduced, ParamTypes, nullptr ,
4049
+ Info);
4050
+ });
4042
4051
if (Result)
4043
4052
return Result;
4044
4053
@@ -4140,12 +4149,16 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
4140
4149
// that is needed when the accessibility of template arguments is checked.
4141
4150
DeclContext *CallingCtx = CurContext;
4142
4151
4143
- return FinishTemplateArgumentDeduction (
4144
- FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
4145
- &OriginalCallArgs, PartialOverloading, [&, CallingCtx]() {
4146
- ContextRAII SavedContext (*this , CallingCtx);
4147
- return CheckNonDependent (ParamTypesForArgChecking);
4148
- });
4152
+ TemplateDeductionResult Result;
4153
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
4154
+ Result = FinishTemplateArgumentDeduction (
4155
+ FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
4156
+ &OriginalCallArgs, PartialOverloading, [&, CallingCtx]() {
4157
+ ContextRAII SavedContext (*this , CallingCtx);
4158
+ return CheckNonDependent (ParamTypesForArgChecking);
4159
+ });
4160
+ });
4161
+ return Result;
4149
4162
}
4150
4163
4151
4164
QualType Sema::adjustCCAndNoReturn (QualType ArgFunctionType,
@@ -4231,11 +4244,13 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
4231
4244
unsigned NumExplicitlySpecified = 0 ;
4232
4245
SmallVector<QualType, 4 > ParamTypes;
4233
4246
if (ExplicitTemplateArgs) {
4234
- if (TemplateDeductionResult Result
4235
- = SubstituteExplicitTemplateArguments (FunctionTemplate,
4236
- *ExplicitTemplateArgs,
4237
- Deduced, ParamTypes,
4238
- &FunctionType, Info))
4247
+ TemplateDeductionResult Result;
4248
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
4249
+ Result = SubstituteExplicitTemplateArguments (
4250
+ FunctionTemplate, *ExplicitTemplateArgs, Deduced, ParamTypes,
4251
+ &FunctionType, Info);
4252
+ });
4253
+ if (Result)
4239
4254
return Result;
4240
4255
4241
4256
NumExplicitlySpecified = Deduced.size ();
@@ -4277,10 +4292,13 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
4277
4292
return Result;
4278
4293
}
4279
4294
4280
- if (TemplateDeductionResult Result
4281
- = FinishTemplateArgumentDeduction (FunctionTemplate, Deduced,
4282
- NumExplicitlySpecified,
4283
- Specialization, Info))
4295
+ TemplateDeductionResult Result;
4296
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
4297
+ Result = FinishTemplateArgumentDeduction (FunctionTemplate, Deduced,
4298
+ NumExplicitlySpecified,
4299
+ Specialization, Info);
4300
+ });
4301
+ if (Result)
4284
4302
return Result;
4285
4303
4286
4304
// If the function has a deduced return type, deduce it now, so we can check
@@ -4437,9 +4455,11 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *ConversionTemplate,
4437
4455
LocalInstantiationScope InstScope (*this );
4438
4456
// Finish template argument deduction.
4439
4457
FunctionDecl *ConversionSpecialized = nullptr ;
4440
- TemplateDeductionResult Result
4441
- = FinishTemplateArgumentDeduction (ConversionTemplate, Deduced, 0 ,
4442
- ConversionSpecialized, Info);
4458
+ TemplateDeductionResult Result;
4459
+ runWithSufficientStackSpace (Info.getLocation (), [&] {
4460
+ Result = FinishTemplateArgumentDeduction (ConversionTemplate, Deduced, 0 ,
4461
+ ConversionSpecialized, Info);
4462
+ });
4443
4463
Specialization = cast_or_null<CXXConversionDecl>(ConversionSpecialized);
4444
4464
return Result;
4445
4465
}
@@ -5379,14 +5399,15 @@ static bool isAtLeastAsSpecializedAs(Sema &S, QualType T1, QualType T2,
5379
5399
Sema::InstantiatingTemplate Inst (S, Info.getLocation (), P2, DeducedArgs,
5380
5400
Info);
5381
5401
auto *TST1 = T1->castAs <TemplateSpecializationType>();
5382
- if (FinishTemplateArgumentDeduction (
5383
- S, P2, /* IsPartialOrdering=*/ true ,
5384
- TemplateArgumentList (TemplateArgumentList::OnStack,
5385
- TST1->template_arguments ()),
5386
- Deduced, Info))
5387
- return false ;
5388
-
5389
- return true ;
5402
+ bool AtLeastAsSpecialized;
5403
+ S.runWithSufficientStackSpace (Info.getLocation (), [&] {
5404
+ AtLeastAsSpecialized = !FinishTemplateArgumentDeduction (
5405
+ S, P2, /* IsPartialOrdering=*/ true ,
5406
+ TemplateArgumentList (TemplateArgumentList::OnStack,
5407
+ TST1->template_arguments ()),
5408
+ Deduced, Info);
5409
+ });
5410
+ return AtLeastAsSpecialized;
5390
5411
}
5391
5412
5392
5413
// / Returns the more specialized class template partial specialization
0 commit comments