@@ -1824,6 +1824,15 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T,
1824
1824
T->setQualifierInfo (SS.getWithLocInContext (S.Context ));
1825
1825
}
1826
1826
1827
+ // Returns the template parameter list with all default template argument
1828
+ // information.
1829
+ static TemplateParameterList *GetTemplateParameterList (TemplateDecl *TD) {
1830
+ // Make sure we get the template parameter list from the most
1831
+ // recent declaration, since that is the only one that is guaranteed to
1832
+ // have all the default template argument information.
1833
+ return cast<TemplateDecl>(TD->getMostRecentDecl ())->getTemplateParameters ();
1834
+ }
1835
+
1827
1836
DeclResult Sema::CheckClassTemplate (
1828
1837
Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1829
1838
CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -2061,13 +2070,13 @@ DeclResult Sema::CheckClassTemplate(
2061
2070
if (!(TUK == TUK_Friend && CurContext->isDependentContext ()) &&
2062
2071
CheckTemplateParameterList (
2063
2072
TemplateParams,
2064
- PrevClassTemplate
2065
- ? PrevClassTemplate->getMostRecentDecl ()->getTemplateParameters ()
2066
- : nullptr ,
2073
+ PrevClassTemplate ? GetTemplateParameterList (PrevClassTemplate)
2074
+ : nullptr ,
2067
2075
(SS.isSet () && SemanticContext && SemanticContext->isRecord () &&
2068
2076
SemanticContext->isDependentContext ())
2069
2077
? TPC_ClassTemplateMember
2070
- : TUK == TUK_Friend ? TPC_FriendClassTemplate : TPC_ClassTemplate,
2078
+ : TUK == TUK_Friend ? TPC_FriendClassTemplate
2079
+ : TPC_ClassTemplate,
2071
2080
SkipBody))
2072
2081
Invalid = true ;
2073
2082
@@ -2298,7 +2307,7 @@ struct ConvertConstructorToDeductionGuideTransform {
2298
2307
// -- The template parameters are the template parameters of the class
2299
2308
// template followed by the template parameters (including default
2300
2309
// template arguments) of the constructor, if any.
2301
- TemplateParameterList *TemplateParams = Template-> getTemplateParameters ( );
2310
+ TemplateParameterList *TemplateParams = GetTemplateParameterList (Template );
2302
2311
if (FTD) {
2303
2312
TemplateParameterList *InnerParams = FTD->getTemplateParameters ();
2304
2313
SmallVector<NamedDecl *, 16 > AllParams;
@@ -2424,7 +2433,7 @@ struct ConvertConstructorToDeductionGuideTransform {
2424
2433
Params.push_back (NewParam);
2425
2434
}
2426
2435
2427
- return buildDeductionGuide (Template-> getTemplateParameters ( ), nullptr ,
2436
+ return buildDeductionGuide (GetTemplateParameterList (Template ), nullptr ,
2428
2437
ExplicitSpecifier (), TSI, Loc, Loc, Loc);
2429
2438
}
2430
2439
@@ -5956,12 +5965,7 @@ bool Sema::CheckTemplateArgumentList(
5956
5965
// template.
5957
5966
TemplateArgumentListInfo NewArgs = TemplateArgs;
5958
5967
5959
- // Make sure we get the template parameter list from the most
5960
- // recent declaration, since that is the only one that is guaranteed to
5961
- // have all the default template argument information.
5962
- TemplateParameterList *Params =
5963
- cast<TemplateDecl>(Template->getMostRecentDecl ())
5964
- ->getTemplateParameters ();
5968
+ TemplateParameterList *Params = GetTemplateParameterList (Template);
5965
5969
5966
5970
SourceLocation RAngleLoc = NewArgs.getRAngleLoc ();
5967
5971
0 commit comments