Skip to content

Commit c94d930

Browse files
authored
[clang] NFC: rename MatchedPackOnParmToNonPackOnArg to StrictPackMatch (#125418)
This rename follows the proposed wording in P3310R5, which introduces the term 'strict pack match' to refer to the same thing.
1 parent a0d3d69 commit c94d930

17 files changed

+86
-111
lines changed

clang/include/clang/AST/DeclTemplate.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,19 +1842,19 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
18421842
unsigned SpecializationKind : 3;
18431843

18441844
/// Indicate that we have matched a parameter pack with a non pack
1845-
/// argument, when the opposite match is also allowed (strict pack match).
1845+
/// argument, when the opposite match is also allowed.
18461846
/// This needs to be cached as deduction is performed during declaration,
18471847
/// and we need the information to be preserved so that it is consistent
18481848
/// during instantiation.
1849-
bool MatchedPackOnParmToNonPackOnArg : 1;
1849+
bool StrictPackMatch : 1;
18501850

18511851
protected:
18521852
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
18531853
DeclContext *DC, SourceLocation StartLoc,
18541854
SourceLocation IdLoc,
18551855
ClassTemplateDecl *SpecializedTemplate,
18561856
ArrayRef<TemplateArgument> Args,
1857-
bool MatchedPackOnParmToNonPackOnArg,
1857+
bool StrictPackMatch,
18581858
ClassTemplateSpecializationDecl *PrevDecl);
18591859

18601860
ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
@@ -1867,7 +1867,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
18671867
Create(ASTContext &Context, TagKind TK, DeclContext *DC,
18681868
SourceLocation StartLoc, SourceLocation IdLoc,
18691869
ClassTemplateDecl *SpecializedTemplate,
1870-
ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
1870+
ArrayRef<TemplateArgument> Args, bool StrictPackMatch,
18711871
ClassTemplateSpecializationDecl *PrevDecl);
18721872
static ClassTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
18731873
GlobalDeclID ID);
@@ -1938,9 +1938,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19381938
SpecializationKind = TSK;
19391939
}
19401940

1941-
bool hasMatchedPackOnParmToNonPackOnArg() const {
1942-
return MatchedPackOnParmToNonPackOnArg;
1943-
}
1941+
bool hasStrictPackMatch() const { return StrictPackMatch; }
19441942

19451943
/// Get the point of instantiation (if any), or null if none.
19461944
SourceLocation getPointOfInstantiation() const {

clang/include/clang/Sema/Overload.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class Sema;
933933
/// Have we matched any packs on the parameter side, versus any non-packs on
934934
/// the argument side, in a context where the opposite matching is also
935935
/// allowed?
936-
bool HasMatchedPackOnParmToNonPackOnArg : 1;
936+
bool StrictPackMatch : 1;
937937

938938
/// True if the candidate was found using ADL.
939939
LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
@@ -1010,8 +1010,7 @@ class Sema;
10101010
friend class OverloadCandidateSet;
10111011
OverloadCandidate()
10121012
: IsSurrogate(false), IgnoreObjectArgument(false),
1013-
TookAddressOfOverload(false),
1014-
HasMatchedPackOnParmToNonPackOnArg(false),
1013+
TookAddressOfOverload(false), StrictPackMatch(false),
10151014
IsADLCandidate(llvm::to_underlying(CallExpr::NotADL)),
10161015
RewriteKind(CRK_None) {}
10171016
};

clang/include/clang/Sema/Sema.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10180,18 +10180,15 @@ class Sema final : public SemaBase {
1018010180
/// \param PartialOverloading true if we are performing "partial" overloading
1018110181
/// based on an incomplete set of function arguments. This feature is used by
1018210182
/// code completion.
10183-
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl,
10184-
ArrayRef<Expr *> Args,
10185-
OverloadCandidateSet &CandidateSet,
10186-
bool SuppressUserConversions = false,
10187-
bool PartialOverloading = false,
10188-
bool AllowExplicit = true,
10189-
bool AllowExplicitConversion = false,
10190-
ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10191-
ConversionSequenceList EarlyConversions = {},
10192-
OverloadCandidateParamOrder PO = {},
10193-
bool AggregateCandidateDeduction = false,
10194-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10183+
void AddOverloadCandidate(
10184+
FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef<Expr *> Args,
10185+
OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10186+
bool PartialOverloading = false, bool AllowExplicit = true,
10187+
bool AllowExplicitConversion = false,
10188+
ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10189+
ConversionSequenceList EarlyConversions = {},
10190+
OverloadCandidateParamOrder PO = {},
10191+
bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
1019510192

1019610193
/// Add all of the function declarations in the given function set to
1019710194
/// the overload candidate set.
@@ -10227,7 +10224,7 @@ class Sema final : public SemaBase {
1022710224
bool PartialOverloading = false,
1022810225
ConversionSequenceList EarlyConversions = {},
1022910226
OverloadCandidateParamOrder PO = {},
10230-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10227+
bool StrictPackMatch = false);
1023110228

1023210229
/// Add a C++ member function template as a candidate to the candidate
1023310230
/// set, using template argument deduction to produce an appropriate member
@@ -10274,7 +10271,7 @@ class Sema final : public SemaBase {
1027410271
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
1027510272
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
1027610273
bool AllowExplicit, bool AllowResultConversion = true,
10277-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10274+
bool StrictPackMatch = false);
1027810275

1027910276
/// Adds a conversion function template specialization
1028010277
/// candidate to the overload set, using template argument deduction
@@ -11694,7 +11691,7 @@ class Sema final : public SemaBase {
1169411691

1169511692
/// Is set to true when, in the context of TTP matching, a pack parameter
1169611693
/// matches non-pack arguments.
11697-
bool MatchedPackOnParmToNonPackOnArg = false;
11694+
bool StrictPackMatch = false;
1169811695
};
1169911696

1170011697
/// Check that the given template argument corresponds to the given
@@ -11803,7 +11800,7 @@ class Sema final : public SemaBase {
1180311800
TemplateParameterList *Params,
1180411801
TemplateArgumentLoc &Arg,
1180511802
bool PartialOrdering,
11806-
bool *MatchedPackOnParmToNonPackOnArg);
11803+
bool *StrictPackMatch);
1180711804

1180811805
void NoteTemplateLocation(const NamedDecl &Decl,
1180911806
std::optional<SourceRange> ParamRange = {});
@@ -12497,7 +12494,7 @@ class Sema final : public SemaBase {
1249712494
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
1249812495
TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
1249912496
const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12500-
bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
12497+
bool PartialOrdering, bool *StrictPackMatch);
1250112498

1250212499
/// Mark which template parameters are used in a given expression.
1250312500
///
@@ -13500,7 +13497,7 @@ class Sema final : public SemaBase {
1350013497
SourceLocation PointOfInstantiation,
1350113498
ClassTemplateSpecializationDecl *ClassTemplateSpec,
1350213499
TemplateSpecializationKind TSK, bool Complain,
13503-
bool PrimaryHasMatchedPackOnParmToNonPackOnArg);
13500+
bool PrimaryStrictPackMatch);
1350413501

1350513502
/// Instantiates the definitions of all of the member
1350613503
/// of the given class, which is an instantiation of a class template

clang/include/clang/Sema/TemplateDeduction.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TemplateDeductionInfo {
5454
/// Have we matched any packs on the parameter side, versus any non-packs on
5555
/// the argument side, in a context where the opposite matching is also
5656
/// allowed?
57-
bool MatchedPackOnParmToNonPackOnArg = false;
57+
bool StrictPackMatch = false;
5858

5959
/// The template parameter depth for which we're performing deduction.
6060
unsigned DeducedDepth;
@@ -92,13 +92,9 @@ class TemplateDeductionInfo {
9292
return DeducedDepth;
9393
}
9494

95-
bool hasMatchedPackOnParmToNonPackOnArg() const {
96-
return MatchedPackOnParmToNonPackOnArg;
97-
}
95+
bool hasStrictPackMatch() const { return StrictPackMatch; }
9896

99-
void setMatchedPackOnParmToNonPackOnArg() {
100-
MatchedPackOnParmToNonPackOnArg = true;
101-
}
97+
void setStrictPackMatch() { StrictPackMatch = true; }
10298

10399
/// Get the number of explicitly-specified arguments.
104100
unsigned getNumExplicitArgs() const {

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6320,10 +6320,10 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
63206320

63216321
updateLookupTableForTemplateParameters(*ToTPList);
63226322
} else { // Not a partial specialization.
6323-
if (GetImportedOrCreateDecl(
6324-
D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr,
6325-
*IdLocOrErr, ClassTemplate, TemplateArgs,
6326-
D->hasMatchedPackOnParmToNonPackOnArg(), PrevDecl))
6323+
if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->getTagKind(),
6324+
DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6325+
TemplateArgs, D->hasStrictPackMatch(),
6326+
PrevDecl))
63276327
return D2;
63286328

63296329
// Update InsertPos, because preceding import calls may have invalidated

clang/lib/AST/DeclTemplate.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,13 @@ ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(
961961
ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC,
962962
SourceLocation StartLoc, SourceLocation IdLoc,
963963
ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
964-
bool MatchedPackOnParmToNonPackOnArg,
965-
ClassTemplateSpecializationDecl *PrevDecl)
964+
bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
966965
: CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
967966
SpecializedTemplate->getIdentifier(), PrevDecl),
968967
SpecializedTemplate(SpecializedTemplate),
969968
TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
970-
SpecializationKind(TSK_Undeclared),
971-
MatchedPackOnParmToNonPackOnArg(MatchedPackOnParmToNonPackOnArg) {
972-
assert(DK == Kind::ClassTemplateSpecialization ||
973-
MatchedPackOnParmToNonPackOnArg == false);
969+
SpecializationKind(TSK_Undeclared), StrictPackMatch(StrictPackMatch) {
970+
assert(DK == Kind::ClassTemplateSpecialization || StrictPackMatch == false);
974971
}
975972

976973
ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
@@ -982,11 +979,11 @@ ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
982979
ClassTemplateSpecializationDecl *ClassTemplateSpecializationDecl::Create(
983980
ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc,
984981
SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate,
985-
ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
982+
ArrayRef<TemplateArgument> Args, bool StrictPackMatch,
986983
ClassTemplateSpecializationDecl *PrevDecl) {
987984
auto *Result = new (Context, DC) ClassTemplateSpecializationDecl(
988985
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
989-
SpecializedTemplate, Args, MatchedPackOnParmToNonPackOnArg, PrevDecl);
986+
SpecializedTemplate, Args, StrictPackMatch, PrevDecl);
990987
Result->setMayHaveOutOfDateDef(false);
991988

992989
// If the template decl is incomplete, copy the external lexical storage from
@@ -1173,10 +1170,9 @@ ClassTemplatePartialSpecializationDecl::ClassTemplatePartialSpecializationDecl(
11731170
ClassTemplatePartialSpecializationDecl *PrevDecl)
11741171
: ClassTemplateSpecializationDecl(
11751172
Context, ClassTemplatePartialSpecialization, TK, DC, StartLoc, IdLoc,
1176-
// Tracking MatchedPackOnParmToNonPackOnArg for Partial
1173+
// Tracking StrictPackMatch for Partial
11771174
// Specializations is not needed.
1178-
SpecializedTemplate, Args, /*MatchedPackOnParmToNonPackOnArg=*/false,
1179-
PrevDecl),
1175+
SpecializedTemplate, Args, /*StrictPackMatch=*/false, PrevDecl),
11801176
TemplateParams(Params), InstantiatedFromMember(nullptr, false) {
11811177
if (AdoptTemplateParameterList(Params, this))
11821178
setInvalidDecl();

clang/lib/AST/JSONNodeDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ void JSONNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *RD) {
10041004
VisitRecordDecl(RD);
10051005

10061006
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
1007-
if (CTSD->hasMatchedPackOnParmToNonPackOnArg())
1007+
if (CTSD->hasStrictPackMatch())
10081008
JOS.attribute("strict-pack-match", true);
10091009
}
10101010

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
25272527
}
25282528
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
25292529
dumpTemplateSpecializationKind(CTSD->getSpecializationKind());
2530-
if (CTSD->hasMatchedPackOnParmToNonPackOnArg())
2530+
if (CTSD->hasStrictPackMatch())
25312531
OS << " strict-pack-match";
25322532
}
25332533

clang/lib/Sema/SemaOverload.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6927,7 +6927,7 @@ void Sema::AddOverloadCandidate(
69276927
bool PartialOverloading, bool AllowExplicit, bool AllowExplicitConversions,
69286928
ADLCallKind IsADLCandidate, ConversionSequenceList EarlyConversions,
69296929
OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction,
6930-
bool HasMatchedPackOnParmToNonPackOnArg) {
6930+
bool StrictPackMatch) {
69316931
const FunctionProtoType *Proto
69326932
= dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
69336933
assert(Proto && "Functions without a prototype cannot be overloaded");
@@ -6947,7 +6947,7 @@ void Sema::AddOverloadCandidate(
69476947
Expr::Classification::makeSimpleLValue(), Args,
69486948
CandidateSet, SuppressUserConversions,
69496949
PartialOverloading, EarlyConversions, PO,
6950-
HasMatchedPackOnParmToNonPackOnArg);
6950+
StrictPackMatch);
69516951
return;
69526952
}
69536953
// We treat a constructor like a non-member function, since its object
@@ -6990,8 +6990,7 @@ void Sema::AddOverloadCandidate(
69906990
CandidateSet.getRewriteInfo().getRewriteKind(Function, PO);
69916991
Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
69926992
Candidate.ExplicitCallArguments = Args.size();
6993-
Candidate.HasMatchedPackOnParmToNonPackOnArg =
6994-
HasMatchedPackOnParmToNonPackOnArg;
6993+
Candidate.StrictPackMatch = StrictPackMatch;
69956994

69966995
// Explicit functions are not actually candidates at all if we're not
69976996
// allowing them in this context, but keep them around so we can point
@@ -7563,7 +7562,7 @@ void Sema::AddMethodCandidate(
75637562
Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
75647563
OverloadCandidateSet &CandidateSet, bool SuppressUserConversions,
75657564
bool PartialOverloading, ConversionSequenceList EarlyConversions,
7566-
OverloadCandidateParamOrder PO, bool HasMatchedPackOnParmToNonPackOnArg) {
7565+
OverloadCandidateParamOrder PO, bool StrictPackMatch) {
75677566
const FunctionProtoType *Proto
75687567
= dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
75697568
assert(Proto && "Methods without a prototype cannot be overloaded");
@@ -7594,8 +7593,7 @@ void Sema::AddMethodCandidate(
75947593
Candidate.TookAddressOfOverload =
75957594
CandidateSet.getKind() == OverloadCandidateSet::CSK_AddressOfOverloadSet;
75967595
Candidate.ExplicitCallArguments = Args.size();
7597-
Candidate.HasMatchedPackOnParmToNonPackOnArg =
7598-
HasMatchedPackOnParmToNonPackOnArg;
7596+
Candidate.StrictPackMatch = StrictPackMatch;
75997597

76007598
bool IgnoreExplicitObject =
76017599
(Method->isExplicitObjectMemberFunction() &&
@@ -7805,8 +7803,7 @@ void Sema::AddMethodTemplateCandidate(
78057803
AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
78067804
ActingContext, ObjectType, ObjectClassification, Args,
78077805
CandidateSet, SuppressUserConversions, PartialOverloading,
7808-
Conversions, PO,
7809-
Info.hasMatchedPackOnParmToNonPackOnArg());
7806+
Conversions, PO, Info.hasStrictPackMatch());
78107807
}
78117808

78127809
/// Determine whether a given function template has a simple explicit specifier
@@ -7894,7 +7891,7 @@ void Sema::AddTemplateOverloadCandidate(
78947891
PartialOverloading, AllowExplicit,
78957892
/*AllowExplicitConversions=*/false, IsADLCandidate, Conversions, PO,
78967893
Info.AggregateDeductionCandidateHasMismatchedArity,
7897-
Info.hasMatchedPackOnParmToNonPackOnArg());
7894+
Info.hasStrictPackMatch());
78987895
}
78997896

79007897
bool Sema::CheckNonDependentConversions(
@@ -8016,8 +8013,7 @@ void Sema::AddConversionCandidate(
80168013
CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
80178014
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
80188015
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
8019-
bool AllowExplicit, bool AllowResultConversion,
8020-
bool HasMatchedPackOnParmToNonPackOnArg) {
8016+
bool AllowExplicit, bool AllowResultConversion, bool StrictPackMatch) {
80218017
assert(!Conversion->getDescribedFunctionTemplate() &&
80228018
"Conversion function templates use AddTemplateConversionCandidate");
80238019
QualType ConvType = Conversion->getConversionType().getNonReferenceType();
@@ -8062,8 +8058,7 @@ void Sema::AddConversionCandidate(
80628058
Candidate.FinalConversion.setAllToTypes(ToType);
80638059
Candidate.Viable = true;
80648060
Candidate.ExplicitCallArguments = 1;
8065-
Candidate.HasMatchedPackOnParmToNonPackOnArg =
8066-
HasMatchedPackOnParmToNonPackOnArg;
8061+
Candidate.StrictPackMatch = StrictPackMatch;
80678062

80688063
// Explicit functions are not actually candidates at all if we're not
80698064
// allowing them in this context, but keep them around so we can point
@@ -8266,7 +8261,7 @@ void Sema::AddTemplateConversionCandidate(
82668261
AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
82678262
CandidateSet, AllowObjCConversionOnExplicit,
82688263
AllowExplicit, AllowResultConversion,
8269-
Info.hasMatchedPackOnParmToNonPackOnArg());
8264+
Info.hasStrictPackMatch());
82708265
}
82718266

82728267
void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
@@ -10618,9 +10613,8 @@ bool clang::isBetterOverloadCandidate(
1061810613
isa<CXXConstructorDecl>(Cand2.Function))
1061910614
return isa<CXXConstructorDecl>(Cand1.Function);
1062010615

10621-
if (Cand1.HasMatchedPackOnParmToNonPackOnArg !=
10622-
Cand2.HasMatchedPackOnParmToNonPackOnArg)
10623-
return Cand2.HasMatchedPackOnParmToNonPackOnArg;
10616+
if (Cand1.StrictPackMatch != Cand2.StrictPackMatch)
10617+
return Cand2.StrictPackMatch;
1062410618

1062510619
// -- F1 is a non-template function and F2 is a function template
1062610620
// specialization, or, if not that,

0 commit comments

Comments
 (0)