-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] NFC: rename MatchedPackOnParmToNonPackOnArg to StrictPackMatch #125418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] NFC: rename MatchedPackOnParmToNonPackOnArg to StrictPackMatch #125418
Conversation
@llvm/pr-subscribers-lldb @llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesThis rename follows the proposed wording in P3310R5, which introduces the term 'strict pack match' to refer to the same thing. Patch is 33.18 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125418.diff 15 Files Affected:
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 03c43765206b18..87406b0e030df1 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1842,11 +1842,11 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
unsigned SpecializationKind : 3;
/// Indicate that we have matched a parameter pack with a non pack
- /// argument, when the opposite match is also allowed (strict pack match).
+ /// argument, when the opposite match is also allowed.
/// This needs to be cached as deduction is performed during declaration,
/// and we need the information to be preserved so that it is consistent
/// during instantiation.
- bool MatchedPackOnParmToNonPackOnArg : 1;
+ bool StrictPackMatch : 1;
protected:
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
@@ -1854,7 +1854,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
ArrayRef<TemplateArgument> Args,
- bool MatchedPackOnParmToNonPackOnArg,
+ bool StrictPackMatch,
ClassTemplateSpecializationDecl *PrevDecl);
ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
@@ -1867,7 +1867,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
Create(ASTContext &Context, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
- ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
+ ArrayRef<TemplateArgument> Args, bool StrictPackMatch,
ClassTemplateSpecializationDecl *PrevDecl);
static ClassTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
GlobalDeclID ID);
@@ -1938,9 +1938,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
SpecializationKind = TSK;
}
- bool hasMatchedPackOnParmToNonPackOnArg() const {
- return MatchedPackOnParmToNonPackOnArg;
- }
+ bool hasStrictPackMatch() const { return StrictPackMatch; }
/// Get the point of instantiation (if any), or null if none.
SourceLocation getPointOfInstantiation() const {
diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h
index c7f2422b542dd1..c03ec00d03dc50 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -933,7 +933,7 @@ class Sema;
/// Have we matched any packs on the parameter side, versus any non-packs on
/// the argument side, in a context where the opposite matching is also
/// allowed?
- bool HasMatchedPackOnParmToNonPackOnArg : 1;
+ bool StrictPackMatch : 1;
/// True if the candidate was found using ADL.
LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
@@ -1010,8 +1010,7 @@ class Sema;
friend class OverloadCandidateSet;
OverloadCandidate()
: IsSurrogate(false), IgnoreObjectArgument(false),
- TookAddressOfOverload(false),
- HasMatchedPackOnParmToNonPackOnArg(false),
+ TookAddressOfOverload(false), StrictPackMatch(false),
IsADLCandidate(llvm::to_underlying(CallExpr::NotADL)),
RewriteKind(CRK_None) {}
};
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 79bf6c04ee4969..9fae6bfa58d254 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10174,18 +10174,15 @@ class Sema final : public SemaBase {
/// \param PartialOverloading true if we are performing "partial" overloading
/// based on an incomplete set of function arguments. This feature is used by
/// code completion.
- void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl,
- ArrayRef<Expr *> Args,
- OverloadCandidateSet &CandidateSet,
- bool SuppressUserConversions = false,
- bool PartialOverloading = false,
- bool AllowExplicit = true,
- bool AllowExplicitConversion = false,
- ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
- ConversionSequenceList EarlyConversions = {},
- OverloadCandidateParamOrder PO = {},
- bool AggregateCandidateDeduction = false,
- bool HasMatchedPackOnParmToNonPackOnArg = false);
+ void AddOverloadCandidate(
+ FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef<Expr *> Args,
+ OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
+ bool PartialOverloading = false, bool AllowExplicit = true,
+ bool AllowExplicitConversion = false,
+ ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
+ ConversionSequenceList EarlyConversions = {},
+ OverloadCandidateParamOrder PO = {},
+ bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
/// Add all of the function declarations in the given function set to
/// the overload candidate set.
@@ -10221,7 +10218,7 @@ class Sema final : public SemaBase {
bool PartialOverloading = false,
ConversionSequenceList EarlyConversions = {},
OverloadCandidateParamOrder PO = {},
- bool HasMatchedPackOnParmToNonPackOnArg = false);
+ bool StrictPackMatch = false);
/// Add a C++ member function template as a candidate to the candidate
/// set, using template argument deduction to produce an appropriate member
@@ -10268,7 +10265,7 @@ class Sema final : public SemaBase {
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
bool AllowExplicit, bool AllowResultConversion = true,
- bool HasMatchedPackOnParmToNonPackOnArg = false);
+ bool StrictPackMatch = false);
/// Adds a conversion function template specialization
/// candidate to the overload set, using template argument deduction
@@ -11688,7 +11685,7 @@ class Sema final : public SemaBase {
/// Is set to true when, in the context of TTP matching, a pack parameter
/// matches non-pack arguments.
- bool MatchedPackOnParmToNonPackOnArg = false;
+ bool StrictPackMatch = false;
};
/// Check that the given template argument corresponds to the given
@@ -11797,7 +11794,7 @@ class Sema final : public SemaBase {
TemplateParameterList *Params,
TemplateArgumentLoc &Arg,
bool PartialOrdering,
- bool *MatchedPackOnParmToNonPackOnArg);
+ bool *StrictPackMatch);
void NoteTemplateLocation(const NamedDecl &Decl,
std::optional<SourceRange> ParamRange = {});
@@ -12491,7 +12488,7 @@ class Sema final : public SemaBase {
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
- bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
+ bool PartialOrdering, bool *StrictPackMatch);
/// Mark which template parameters are used in a given expression.
///
@@ -13494,7 +13491,7 @@ class Sema final : public SemaBase {
SourceLocation PointOfInstantiation,
ClassTemplateSpecializationDecl *ClassTemplateSpec,
TemplateSpecializationKind TSK, bool Complain,
- bool PrimaryHasMatchedPackOnParmToNonPackOnArg);
+ bool PrimaryStrictPackMatch);
/// Instantiates the definitions of all of the member
/// of the given class, which is an instantiation of a class template
diff --git a/clang/include/clang/Sema/TemplateDeduction.h b/clang/include/clang/Sema/TemplateDeduction.h
index 9c12eef5c42a06..020e19bc7a6089 100644
--- a/clang/include/clang/Sema/TemplateDeduction.h
+++ b/clang/include/clang/Sema/TemplateDeduction.h
@@ -54,7 +54,7 @@ class TemplateDeductionInfo {
/// Have we matched any packs on the parameter side, versus any non-packs on
/// the argument side, in a context where the opposite matching is also
/// allowed?
- bool MatchedPackOnParmToNonPackOnArg = false;
+ bool StrictPackMatch = false;
/// The template parameter depth for which we're performing deduction.
unsigned DeducedDepth;
@@ -92,13 +92,9 @@ class TemplateDeductionInfo {
return DeducedDepth;
}
- bool hasMatchedPackOnParmToNonPackOnArg() const {
- return MatchedPackOnParmToNonPackOnArg;
- }
+ bool hasStrictPackMatch() const { return StrictPackMatch; }
- void setMatchedPackOnParmToNonPackOnArg() {
- MatchedPackOnParmToNonPackOnArg = true;
- }
+ void setStrictPackMatch() { StrictPackMatch = true; }
/// Get the number of explicitly-specified arguments.
unsigned getNumExplicitArgs() const {
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 1057f09deda073..c27ebbf838ad16 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -6320,10 +6320,10 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
updateLookupTableForTemplateParameters(*ToTPList);
} else { // Not a partial specialization.
- if (GetImportedOrCreateDecl(
- D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr,
- *IdLocOrErr, ClassTemplate, TemplateArgs,
- D->hasMatchedPackOnParmToNonPackOnArg(), PrevDecl))
+ if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->getTagKind(),
+ DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
+ TemplateArgs, D->hasStrictPackMatch(),
+ PrevDecl))
return D2;
// Update InsertPos, because preceding import calls may have invalidated
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index fe8734d262a961..7fb89bf5b499fa 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -961,16 +961,13 @@ ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(
ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
- bool MatchedPackOnParmToNonPackOnArg,
- ClassTemplateSpecializationDecl *PrevDecl)
+ bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
: CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
SpecializedTemplate->getIdentifier(), PrevDecl),
SpecializedTemplate(SpecializedTemplate),
TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
- SpecializationKind(TSK_Undeclared),
- MatchedPackOnParmToNonPackOnArg(MatchedPackOnParmToNonPackOnArg) {
- assert(DK == Kind::ClassTemplateSpecialization ||
- MatchedPackOnParmToNonPackOnArg == false);
+ SpecializationKind(TSK_Undeclared), StrictPackMatch(StrictPackMatch) {
+ assert(DK == Kind::ClassTemplateSpecialization || StrictPackMatch == false);
}
ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
@@ -982,11 +979,11 @@ ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
ClassTemplateSpecializationDecl *ClassTemplateSpecializationDecl::Create(
ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate,
- ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
+ ArrayRef<TemplateArgument> Args, bool StrictPackMatch,
ClassTemplateSpecializationDecl *PrevDecl) {
auto *Result = new (Context, DC) ClassTemplateSpecializationDecl(
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
- SpecializedTemplate, Args, MatchedPackOnParmToNonPackOnArg, PrevDecl);
+ SpecializedTemplate, Args, StrictPackMatch, PrevDecl);
Result->setMayHaveOutOfDateDef(false);
// If the template decl is incomplete, copy the external lexical storage from
@@ -1173,10 +1170,9 @@ ClassTemplatePartialSpecializationDecl::ClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *PrevDecl)
: ClassTemplateSpecializationDecl(
Context, ClassTemplatePartialSpecialization, TK, DC, StartLoc, IdLoc,
- // Tracking MatchedPackOnParmToNonPackOnArg for Partial
+ // Tracking StrictPackMatch for Partial
// Specializations is not needed.
- SpecializedTemplate, Args, /*MatchedPackOnParmToNonPackOnArg=*/false,
- PrevDecl),
+ SpecializedTemplate, Args, /*StrictPackMatch=*/false, PrevDecl),
TemplateParams(Params), InstantiatedFromMember(nullptr, false) {
if (AdoptTemplateParameterList(Params, this))
setInvalidDecl();
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index f3ee50f4cf600c..0dba297101f5a4 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -2527,7 +2527,7 @@ void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
}
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
dumpTemplateSpecializationKind(CTSD->getSpecializationKind());
- if (CTSD->hasMatchedPackOnParmToNonPackOnArg())
+ if (CTSD->hasStrictPackMatch())
OS << " strict_pack_match";
}
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 16ecea67aea972..8d5b5ac190b5bf 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6927,7 +6927,7 @@ void Sema::AddOverloadCandidate(
bool PartialOverloading, bool AllowExplicit, bool AllowExplicitConversions,
ADLCallKind IsADLCandidate, ConversionSequenceList EarlyConversions,
OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction,
- bool HasMatchedPackOnParmToNonPackOnArg) {
+ bool StrictPackMatch) {
const FunctionProtoType *Proto
= dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
assert(Proto && "Functions without a prototype cannot be overloaded");
@@ -6947,7 +6947,7 @@ void Sema::AddOverloadCandidate(
Expr::Classification::makeSimpleLValue(), Args,
CandidateSet, SuppressUserConversions,
PartialOverloading, EarlyConversions, PO,
- HasMatchedPackOnParmToNonPackOnArg);
+ StrictPackMatch);
return;
}
// We treat a constructor like a non-member function, since its object
@@ -6990,8 +6990,7 @@ void Sema::AddOverloadCandidate(
CandidateSet.getRewriteInfo().getRewriteKind(Function, PO);
Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
Candidate.ExplicitCallArguments = Args.size();
- Candidate.HasMatchedPackOnParmToNonPackOnArg =
- HasMatchedPackOnParmToNonPackOnArg;
+ Candidate.StrictPackMatch = StrictPackMatch;
// Explicit functions are not actually candidates at all if we're not
// allowing them in this context, but keep them around so we can point
@@ -7563,7 +7562,7 @@ void Sema::AddMethodCandidate(
Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
OverloadCandidateSet &CandidateSet, bool SuppressUserConversions,
bool PartialOverloading, ConversionSequenceList EarlyConversions,
- OverloadCandidateParamOrder PO, bool HasMatchedPackOnParmToNonPackOnArg) {
+ OverloadCandidateParamOrder PO, bool StrictPackMatch) {
const FunctionProtoType *Proto
= dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
assert(Proto && "Methods without a prototype cannot be overloaded");
@@ -7594,8 +7593,7 @@ void Sema::AddMethodCandidate(
Candidate.TookAddressOfOverload =
CandidateSet.getKind() == OverloadCandidateSet::CSK_AddressOfOverloadSet;
Candidate.ExplicitCallArguments = Args.size();
- Candidate.HasMatchedPackOnParmToNonPackOnArg =
- HasMatchedPackOnParmToNonPackOnArg;
+ Candidate.StrictPackMatch = StrictPackMatch;
bool IgnoreExplicitObject =
(Method->isExplicitObjectMemberFunction() &&
@@ -7805,8 +7803,7 @@ void Sema::AddMethodTemplateCandidate(
AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
ActingContext, ObjectType, ObjectClassification, Args,
CandidateSet, SuppressUserConversions, PartialOverloading,
- Conversions, PO,
- Info.hasMatchedPackOnParmToNonPackOnArg());
+ Conversions, PO, Info.hasStrictPackMatch());
}
/// Determine whether a given function template has a simple explicit specifier
@@ -7894,7 +7891,7 @@ void Sema::AddTemplateOverloadCandidate(
PartialOverloading, AllowExplicit,
/*AllowExplicitConversions=*/false, IsADLCandidate, Conversions, PO,
Info.AggregateDeductionCandidateHasMismatchedArity,
- Info.hasMatchedPackOnParmToNonPackOnArg());
+ Info.hasStrictPackMatch());
}
bool Sema::CheckNonDependentConversions(
@@ -8016,8 +8013,7 @@ void Sema::AddConversionCandidate(
CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
- bool AllowExplicit, bool AllowResultConversion,
- bool HasMatchedPackOnParmToNonPackOnArg) {
+ bool AllowExplicit, bool AllowResultConversion, bool StrictPackMatch) {
assert(!Conversion->getDescribedFunctionTemplate() &&
"Conversion function templates use AddTemplateConversionCandidate");
QualType ConvType = Conversion->getConversionType().getNonReferenceType();
@@ -8062,8 +8058,7 @@ void Sema::AddConversionCandidate(
Candidate.FinalConversion.setAllToTypes(ToType);
Candidate.Viable = true;
Candidate.ExplicitCallArguments = 1;
- Candidate.HasMatchedPackOnParmToNonPackOnArg =
- HasMatchedPackOnParmToNonPackOnArg;
+ Candidate.StrictPackMatch = StrictPackMatch;
// Explicit functions are not actually candidates at all if we're not
// allowing them in this context, but keep them around so we can point
@@ -8266,7 +8261,7 @@ void Sema::AddTemplateConversionCandidate(
AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
CandidateSet, AllowObjCConversionOnExplicit,
AllowExplicit, AllowResultConversion,
- Info.hasMatchedPackOnParmToNonPackOnArg());
+ Info.hasStrictPackMatch());
}
void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
@@ -10618,9 +10613,8 @@ bool clang::isBetterOverloadCandidate(
isa<CXXConstructorDecl>(Cand2.Function))
return isa<CXXConstructorDecl>(Cand1.Function);
- if (Cand1.HasMatchedPackOnParmToNonPackOnArg !=
- Cand2.HasMatchedPackOnParmToNonPackOnArg)
- return Cand2.HasMatchedPackOnParmToNonPackOnArg;
+ if (Cand1.StrictPackMatch != Cand2.StrictPackMatch)
+ return Cand2.StrictPackMatch;
// -- F1 is a non-template function and F2 is a function template
// specialization, or, if not that,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index f180be2c1a5e15..9e68972b33f0a0 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3651,7 +3651,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
ClassTemplate->getDeclContext(),
ClassTemplate->getTemplatedDecl()->getBeginLoc(),
ClassTemplate->getLocation(), ClassTemplate, CTAI.CanonicalConverted,
- CTAI.MatchedPackOnParmToNonPackOnArg, nullptr);
+ CTAI.StrictPackMatch, nullptr);
ClassTemplate->AddSpecialization(Decl, InsertPos);
if (ClassTemplate->isOutOfLine()...
[truncated]
|
a5f78da
to
360176c
Compare
772973a
to
f558c58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erich and Aaron are happy with the name, lets go with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "NFC" from the title; this changes behavior of code and updates tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not appropriate to label this NFC is code changes whether is valid or not that is clearly a functional change.
@shafik Thanks for noticing. |
Yeah this is just a bad automatic rebase by GitHub, only the top commit is relevant. |
f558c58
to
03dadd7
Compare
All rebased, it's back to being a god-fearing all around NFC PR :) |
This rename follows the proposed wording in P3310R5, which introduces the term 'strict pack match' to refer to the same thing.
03dadd7
to
29c48b0
Compare
llvm#125418) This rename follows the proposed wording in P3310R5, which introduces the term 'strict pack match' to refer to the same thing.
This rename follows the proposed wording in P3310R5, which introduces the term 'strict pack match' to refer to the same thing.