Skip to content

Commit fd51c78

Browse files
authored
[clang] fix alias ctad producing function template with no template parameters (#195303)
1 parent 3823341 commit fd51c78

10 files changed

Lines changed: 82 additions & 62 deletions

File tree

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ Bug Fixes to C++ Support
569569
Bug Fixes to AST Handling
570570
^^^^^^^^^^^^^^^^^^^^^^^^^
571571
- Fixed a bug where explicit nullability property attributes were not stored in AST nodes in Objective-C. (#GH179703)
572+
- Fixed a bug where alias CTAD, or an invalid template template parameter, could create a template with an empty template
573+
parameter list. This also adds asserts to prevent this from happening again.
572574
- Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid declarations or non-function entities. (#GH182737)
573575
- Fixed the SourceLocation and SourceRange of reversed rewritten CXXOperatorCallExpr. (#GH192467)
574576

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13098,7 +13098,7 @@ class Sema final : public SemaBase {
1309813098
void DeclareImplicitDeductionGuides(TemplateDecl *Template,
1309913099
SourceLocation Loc);
1310013100

13101-
FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
13101+
CXXDeductionGuideDecl *DeclareAggregateDeductionGuideFromInitList(
1310213102
TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
1310313103
SourceLocation Loc);
1310413104

clang/lib/AST/DeclTemplate.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ FunctionTemplateDecl *
441441
FunctionTemplateDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
442442
DeclarationName Name,
443443
TemplateParameterList *Params, NamedDecl *Decl) {
444+
assert(!Params->empty() && "template with no template parameters");
444445
bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
445446
auto *TD = new (C, DC) FunctionTemplateDecl(C, DC, L, Name, Params, Decl);
446447
if (Invalid)
@@ -528,6 +529,7 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, DeclContext *DC,
528529
DeclarationName Name,
529530
TemplateParameterList *Params,
530531
NamedDecl *Decl) {
532+
assert(!Params->empty() && "template with no template parameters");
531533
bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
532534
auto *TD = new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
533535
if (Invalid)
@@ -877,6 +879,7 @@ TemplateTemplateParmDecl *TemplateTemplateParmDecl::Create(
877879
const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D,
878880
unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind Kind,
879881
bool Typename, TemplateParameterList *Params) {
882+
assert(!Params->empty() && "template with no template parameters");
880883
return new (C, DC) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id,
881884
Kind, Typename, Params);
882885
}
@@ -887,6 +890,7 @@ TemplateTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC,
887890
IdentifierInfo *Id, TemplateNameKind Kind,
888891
bool Typename, TemplateParameterList *Params,
889892
ArrayRef<TemplateParameterList *> Expansions) {
893+
assert(!Params->empty() && "template with no template parameters");
890894
return new (C, DC,
891895
additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
892896
TemplateTemplateParmDecl(DC, L, D, P, Id, Kind, Typename, Params,
@@ -1104,6 +1108,7 @@ ConceptDecl *ConceptDecl::Create(ASTContext &C, DeclContext *DC,
11041108
SourceLocation L, DeclarationName Name,
11051109
TemplateParameterList *Params,
11061110
Expr *ConstraintExpr) {
1111+
assert(!Params->empty() && "template with no template parameters");
11071112
bool Invalid = AdoptTemplateParameterList(Params, DC);
11081113
auto *TD = new (C, DC) ConceptDecl(DC, L, Name, Params, ConstraintExpr);
11091114
if (Invalid)
@@ -1185,6 +1190,7 @@ ClassTemplatePartialSpecializationDecl::Create(
11851190
ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
11861191
CanQualType CanonInjectedTST,
11871192
ClassTemplatePartialSpecializationDecl *PrevDecl) {
1193+
assert(!Params->empty() && "template with no template parameters");
11881194
auto *Result = new (Context, DC) ClassTemplatePartialSpecializationDecl(
11891195
Context, TK, DC, StartLoc, IdLoc, Params, SpecializedTemplate, Args,
11901196
CanonInjectedTST, PrevDecl);
@@ -1256,6 +1262,7 @@ TypeAliasTemplateDecl *
12561262
TypeAliasTemplateDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
12571263
DeclarationName Name,
12581264
TemplateParameterList *Params, NamedDecl *Decl) {
1265+
assert(!Params->empty() && "template with no template parameters");
12591266
bool Invalid = AdoptTemplateParameterList(Params, DC);
12601267
auto *TD = new (C, DC) TypeAliasTemplateDecl(C, DC, L, Name, Params, Decl);
12611268
if (Invalid)
@@ -1294,6 +1301,7 @@ VarTemplateDecl *VarTemplateDecl::Create(ASTContext &C, DeclContext *DC,
12941301
SourceLocation L, DeclarationName Name,
12951302
TemplateParameterList *Params,
12961303
VarDecl *Decl) {
1304+
assert(!Params->empty() && "template with no template parameters");
12971305
bool Invalid = AdoptTemplateParameterList(Params, DC);
12981306
auto *TD = new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
12991307
if (Invalid)
@@ -1551,6 +1559,7 @@ VarTemplatePartialSpecializationDecl::Create(
15511559
SourceLocation IdLoc, TemplateParameterList *Params,
15521560
VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
15531561
StorageClass S, ArrayRef<TemplateArgument> Args) {
1562+
assert(!Params->empty() && "template with no template parameters");
15541563
auto *Result = new (Context, DC) VarTemplatePartialSpecializationDecl(
15551564
Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo, S,
15561565
Args);

clang/lib/Sema/SemaInit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10337,11 +10337,11 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
1033710337
Context.getLValueReferenceType(ElementTypes[I].withConst());
1033810338
}
1033910339

10340-
if (FunctionTemplateDecl *TD =
10340+
if (CXXDeductionGuideDecl *GD =
1034110341
DeclareAggregateDeductionGuideFromInitList(
1034210342
LookupTemplateDecl, ElementTypes,
1034310343
TSInfo->getTypeLoc().getEndLoc())) {
10344-
auto *GD = cast<CXXDeductionGuideDecl>(TD->getTemplatedDecl());
10344+
auto *TD = GD->getDescribedFunctionTemplate();
1034510345
addDeductionCandidate(TD, GD, DeclAccessPair::make(TD, AS_public),
1034610346
OnlyListConstructors,
1034710347
/*AllowAggregateDeductionCandidate=*/true);
@@ -10492,7 +10492,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
1049210492

1049310493
// Make sure we didn't select an unusable deduction guide, and mark it
1049410494
// as referenced.
10495-
DiagnoseUseOfDecl(Best->FoundDecl, Kind.getLocation());
10495+
DiagnoseUseOfDecl(Best->Function, Kind.getLocation());
1049610496
MarkFunctionReferenced(Kind.getLocation(), Best->Function);
1049710497
break;
1049810498
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,22 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
16751675

16761676
bool IsParameterPack = EllipsisLoc.isValid();
16771677

1678+
SourceLocation Loc = NameLoc.isInvalid() ? TmpLoc : NameLoc;
1679+
if (Params->size() == 0) {
1680+
Diag(Loc, diag::err_template_template_parm_no_parms)
1681+
<< SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
1682+
1683+
// Recover as if there was a type template parameter pack.
1684+
SmallVector<NamedDecl *, 4> ParamDecls;
1685+
ParamDecls.push_back(TemplateTypeParmDecl::Create(
1686+
Context, Context.getTranslationUnitDecl(), Loc, SourceLocation(),
1687+
Depth + 1, 0, /*Id=*/nullptr,
1688+
/*Typename=*/false, /*ParameterPack=*/true));
1689+
Params = TemplateParameterList::Create(
1690+
Context, Params->getTemplateLoc(), Params->getLAngleLoc(), ParamDecls,
1691+
Params->getRAngleLoc(), Params->getRequiresClause());
1692+
}
1693+
16781694
bool Invalid = false;
16791695
if (CheckTemplateParameterList(
16801696
Params,
@@ -1684,9 +1700,8 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
16841700

16851701
// Construct the parameter object.
16861702
TemplateTemplateParmDecl *Param = TemplateTemplateParmDecl::Create(
1687-
Context, Context.getTranslationUnitDecl(),
1688-
NameLoc.isInvalid() ? TmpLoc : NameLoc, Depth, Position, IsParameterPack,
1689-
Name, Kind, Typename, Params);
1703+
Context, Context.getTranslationUnitDecl(), Loc, Depth, Position,
1704+
IsParameterPack, Name, Kind, Typename, Params);
16901705
Param->setAccess(AS_public);
16911706

16921707
if (Param->isParameterPack())
@@ -1702,12 +1717,6 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
17021717
IdResolver.AddDecl(Param);
17031718
}
17041719

1705-
if (Params->size() == 0) {
1706-
Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
1707-
<< SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
1708-
Invalid = true;
1709-
}
1710-
17111720
if (Invalid)
17121721
Param->setInvalidDecl();
17131722

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class ExtractTypeForDeductionGuide
220220
// A deduction guide can be either a template or a non-template function
221221
// declaration. If \p TemplateParams is null, a non-template function
222222
// declaration will be created.
223-
NamedDecl *
223+
CXXDeductionGuideDecl *
224224
buildDeductionGuide(Sema &SemaRef, TemplateDecl *OriginalTemplate,
225225
TemplateParameterList *TemplateParams,
226226
CXXConstructorDecl *Ctor, ExplicitSpecifier ES,
@@ -276,7 +276,7 @@ buildDeductionGuide(Sema &SemaRef, TemplateDecl *OriginalTemplate,
276276

277277
if (HaveSameAssociatedConstraints(SemaRef, ExistingCtor, ExistingACs,
278278
Ctor, NewACs))
279-
return Existing;
279+
return ExistingGuide;
280280
}
281281
}
282282

@@ -307,7 +307,7 @@ buildDeductionGuide(Sema &SemaRef, TemplateDecl *OriginalTemplate,
307307
GuideTemplate->setAccess(AS_public);
308308

309309
DC->addDecl(GuideTemplate);
310-
return GuideTemplate;
310+
return Guide;
311311
}
312312

313313
// Transform a given template type parameter `TTP`.
@@ -570,7 +570,8 @@ struct ConvertConstructorToDeductionGuideTransform {
570570
}
571571

572572
/// Build a deduction guide with the specified parameter types.
573-
NamedDecl *buildSimpleDeductionGuide(MutableArrayRef<QualType> ParamTypes) {
573+
CXXDeductionGuideDecl *
574+
buildSimpleDeductionGuide(MutableArrayRef<QualType> ParamTypes) {
574575
SourceLocation Loc = Template->getLocation();
575576

576577
// Build the requested type.
@@ -1081,11 +1082,14 @@ bool IsNonDeducedArgument(const TemplateArgument &TA) {
10811082
}
10821083

10831084
// Build deduction guides for a type alias template from the given underlying
1084-
// deduction guide F.
1085-
FunctionTemplateDecl *
1086-
BuildDeductionGuideForTypeAlias(Sema &SemaRef,
1087-
TypeAliasTemplateDecl *AliasTemplate,
1088-
FunctionTemplateDecl *F, SourceLocation Loc) {
1085+
// source deduction guide.
1086+
CXXDeductionGuideDecl *BuildDeductionGuideForTypeAlias(
1087+
Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate,
1088+
CXXDeductionGuideDecl *SourceDeductionGuide, SourceLocation Loc) {
1089+
FunctionTemplateDecl *F =
1090+
SourceDeductionGuide->getDescribedFunctionTemplate();
1091+
assert(F && "deduction guide for alias template must be a function template");
1092+
10891093
LocalInstantiationScope Scope(SemaRef);
10901094
Sema::NonSFINAEContext _1(SemaRef);
10911095
Sema::InstantiatingTemplate BuildingDeductionGuides(
@@ -1116,7 +1120,7 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
11161120
//
11171121
// Instead, we need to canonicalize both against A, i.e. A<A<T>> and A<A<U>>,
11181122
// such that T can be deduced as U.
1119-
auto RType = F->getTemplatedDecl()->getReturnType();
1123+
auto RType = SourceDeductionGuide->getReturnType();
11201124
// The (trailing) return type of the deduction guide.
11211125
const auto *FReturnType = RType->getAs<TemplateSpecializationType>();
11221126
if (const auto *ICNT = RType->getAsCanonical<InjectedClassNameType>())
@@ -1316,25 +1320,26 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
13161320
buildAssociatedConstraints(SemaRef, F, AliasTemplate, DeduceResults,
13171321
FirstUndeducedParamIdx, IsDeducible);
13181322

1319-
auto *FPrimeTemplateParamList = TemplateParameterList::Create(
1320-
Context, AliasTemplate->getTemplateParameters()->getTemplateLoc(),
1321-
AliasTemplate->getTemplateParameters()->getLAngleLoc(),
1322-
FPrimeTemplateParams,
1323-
AliasTemplate->getTemplateParameters()->getRAngleLoc(),
1324-
/*RequiresClause=*/RequiresClause);
1325-
auto *Result = cast<FunctionTemplateDecl>(buildDeductionGuide(
1323+
TemplateParameterList *FPrimeTemplateParamList = nullptr;
1324+
if (!FPrimeTemplateParams.empty())
1325+
FPrimeTemplateParamList = TemplateParameterList::Create(
1326+
Context, AliasTemplate->getTemplateParameters()->getTemplateLoc(),
1327+
AliasTemplate->getTemplateParameters()->getLAngleLoc(),
1328+
FPrimeTemplateParams,
1329+
AliasTemplate->getTemplateParameters()->getRAngleLoc(),
1330+
/*RequiresClause=*/RequiresClause);
1331+
1332+
auto *DGuide = buildDeductionGuide(
13261333
SemaRef, AliasTemplate, FPrimeTemplateParamList,
13271334
GG->getCorrespondingConstructor(), GG->getExplicitSpecifier(),
13281335
GG->getTypeSourceInfo(), AliasTemplate->getBeginLoc(),
13291336
AliasTemplate->getLocation(), AliasTemplate->getEndLoc(),
1330-
F->isImplicit()));
1331-
auto *DGuide = cast<CXXDeductionGuideDecl>(Result->getTemplatedDecl());
1337+
F->isImplicit());
13321338
DGuide->setDeductionCandidateKind(GG->getDeductionCandidateKind());
1333-
DGuide->setSourceDeductionGuide(
1334-
cast<CXXDeductionGuideDecl>(F->getTemplatedDecl()));
1339+
DGuide->setSourceDeductionGuide(SourceDeductionGuide);
13351340
DGuide->setSourceDeductionGuideKind(
13361341
CXXDeductionGuideDecl::SourceDeductionGuideKind::Alias);
1337-
return Result;
1342+
return DGuide;
13381343
}
13391344
return nullptr;
13401345
}
@@ -1412,16 +1417,16 @@ void DeclareImplicitDeductionGuidesForTypeAlias(
14121417
// The **aggregate** deduction guides are handled in a different code path
14131418
// (DeclareAggregateDeductionGuideFromInitList), which involves the tricky
14141419
// cache.
1415-
if (cast<CXXDeductionGuideDecl>(F->getTemplatedDecl())
1416-
->getDeductionCandidateKind() == DeductionCandidate::Aggregate)
1420+
auto *DGuide = cast<CXXDeductionGuideDecl>(F->getTemplatedDecl());
1421+
if (DGuide->getDeductionCandidateKind() == DeductionCandidate::Aggregate)
14171422
continue;
14181423

1419-
BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate, F, Loc);
1424+
BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate, DGuide, Loc);
14201425
}
14211426
}
14221427

14231428
// Build an aggregate deduction guide for a type alias template.
1424-
FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias(
1429+
CXXDeductionGuideDecl *DeclareAggregateDeductionGuideForTypeAlias(
14251430
Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate,
14261431
MutableArrayRef<QualType> ParamTypes, SourceLocation Loc) {
14271432
TemplateDecl *RHSTemplate =
@@ -1445,15 +1450,15 @@ FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias(
14451450
return nullptr;
14461451

14471452
for (TypedefNameDecl *TD : TypedefDecls)
1448-
TD->setDeclContext(RHSDeductionGuide->getTemplatedDecl());
1453+
TD->setDeclContext(RHSDeductionGuide);
14491454

14501455
return BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate,
14511456
RHSDeductionGuide, Loc);
14521457
}
14531458

14541459
} // namespace
14551460

1456-
FunctionTemplateDecl *Sema::DeclareAggregateDeductionGuideFromInitList(
1461+
CXXDeductionGuideDecl *Sema::DeclareAggregateDeductionGuideFromInitList(
14571462
TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
14581463
SourceLocation Loc) {
14591464
llvm::FoldingSetNodeID ID;
@@ -1463,18 +1468,15 @@ FunctionTemplateDecl *Sema::DeclareAggregateDeductionGuideFromInitList(
14631468
unsigned Hash = ID.ComputeHash();
14641469

14651470
auto Found = AggregateDeductionCandidates.find(Hash);
1466-
if (Found != AggregateDeductionCandidates.end()) {
1467-
CXXDeductionGuideDecl *GD = Found->getSecond();
1468-
return GD->getDescribedFunctionTemplate();
1469-
}
1471+
if (Found != AggregateDeductionCandidates.end())
1472+
return Found->getSecond();
14701473

14711474
if (auto *AliasTemplate = llvm::dyn_cast<TypeAliasTemplateDecl>(Template)) {
1472-
if (auto *FTD = DeclareAggregateDeductionGuideForTypeAlias(
1475+
if (auto *GD = DeclareAggregateDeductionGuideForTypeAlias(
14731476
*this, AliasTemplate, ParamTypes, Loc)) {
1474-
auto *GD = cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl());
14751477
GD->setDeductionCandidateKind(DeductionCandidate::Aggregate);
14761478
AggregateDeductionCandidates[Hash] = GD;
1477-
return FTD;
1479+
return GD;
14781480
}
14791481
}
14801482

@@ -1509,13 +1511,11 @@ FunctionTemplateDecl *Sema::DeclareAggregateDeductionGuideFromInitList(
15091511
Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
15101512
ContextRAII SavedContext(*this, Pattern->getTemplatedDecl());
15111513

1512-
auto *FTD = cast<FunctionTemplateDecl>(
1513-
Transform.buildSimpleDeductionGuide(ParamTypes));
1514+
CXXDeductionGuideDecl *GD = Transform.buildSimpleDeductionGuide(ParamTypes);
15141515
SavedContext.pop();
1515-
auto *GD = cast<CXXDeductionGuideDecl>(FTD->getTemplatedDecl());
15161516
GD->setDeductionCandidateKind(DeductionCandidate::Aggregate);
15171517
AggregateDeductionCandidates[Hash] = GD;
1518-
return FTD;
1518+
return GD;
15191519
}
15201520

15211521
void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
@@ -1607,10 +1607,7 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
16071607

16081608
// -- An additional function template derived as above from a hypothetical
16091609
// constructor C(C), called the copy deduction candidate.
1610-
cast<CXXDeductionGuideDecl>(
1611-
cast<FunctionTemplateDecl>(
1612-
Transform.buildSimpleDeductionGuide(Transform.DeducedType))
1613-
->getTemplatedDecl())
1610+
Transform.buildSimpleDeductionGuide(Transform.DeducedType)
16141611
->setDeductionCandidateKind(DeductionCandidate::Copy);
16151612

16161613
SavedContext.pop();

clang/test/SemaCXX/ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ template <int>
7474
using AstNode = variant<>;
7575
// expected-note@-1 {{couldn't infer template argument ''}} \
7676
// expected-note@-1 2{{implicit deduction guide declared as}} \
77-
// expected-note@-1 {{candidate function template not viable}}
77+
// expected-note@-1 {{candidate function not viable}}
7878

7979

8080
AstNode tree; // expected-error {{no viable constructor or deduction guide}}

clang/test/SemaCXX/cxx20-ctad-type-alias.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,10 @@ Alias b(42);
622622
namespace GH190517 {
623623
template <typename T> struct S1 {};
624624
template <typename T> using S2 = S1<char>;
625-
template <typename T> using S3 = S2<T>; // expected-note {{candidate function template not viable}} \
625+
template <typename T> using S3 = S2<T>; // expected-note {{candidate function not viable}} \
626626
// expected-note {{implicit deduction guide declared}} \
627-
// expected-note {{candidate function template not viable}} \
628-
// expected-note {{implicit deduction guide declared}}
627+
// expected-note {{candidate function not viable}} \
628+
// expected-note {{implicit deduction guide declared}} \
629+
// expected-note {{cannot deduce template arguments for 'GH190517::S3' from 'GH190517::S1<char>'}}
629630
S3 foo(42); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'S3'}}
630631
}

clang/test/SemaTemplate/deduction-guide.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ template <typename X = int>
267267
using BG = G<int>;
268268
BG bg(1.0);
269269
// CHECK-LABEL: Dumping <deduction guide for BG>
270-
// CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for BG>
271-
// CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' aggregate
270+
// CHECK-NOT: FunctionTemplateDecl
271+
// CHECK: CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' aggregate
272272

273273
template <typename D>
274274
requires (sizeof(D) == 4)

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,8 @@ TypeSystemClang::CreateTemplateTemplateParmDecl(const char *template_name) {
16321632
llvm::SmallVector<NamedDecl *, 8> template_param_decls;
16331633

16341634
TypeSystemClang::TemplateParameterInfos template_param_infos;
1635+
template_param_infos.SetParameterPack(
1636+
std::make_unique<TemplateParameterInfos>());
16351637
TemplateParameterList *template_param_list = CreateTemplateParameterList(
16361638
ast, template_param_infos, template_param_decls);
16371639

0 commit comments

Comments
 (0)