[clang] [Clang] Fix the normalization of fold constraints (PR #177531)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 22 23:34:04 PST 2026
================
@@ -2239,16 +2253,39 @@ bool SubstituteParameterMappings::substitute(NormalizedConstraint &N) {
}
assert(!ArgsAsWritten);
const ConceptSpecializationExpr *CSE = CC.getConceptSpecializationExpr();
+ SmallVector<TemplateArgument> InnerArgs(CSE->getTemplateArguments());
ConceptDecl *Concept = CSE->getNamedConcept();
+ if (RemovePacksForFoldExpr) {
+ TemplateArgumentListInfo OutArgs;
+ ArrayRef<TemplateArgumentLoc> InputArgLoc =
+ CSE->getConceptReference()->getTemplateArgsAsWritten()->arguments();
+ if (AdjustConstraints(SemaRef, /*TemplateDepth=*/0,
+ /*RemoveNonPackExpansionPacks=*/true)
+ .TransformTemplateArguments(InputArgLoc.begin(),
+ InputArgLoc.end(), OutArgs))
+ return true;
+ Sema::CheckTemplateArgumentInfo CTAI;
+ // Repack the packs.
+ if (SemaRef.CheckTemplateArgumentList(
+ Concept, Concept->getTemplateParameters(), Concept->getBeginLoc(),
+ OutArgs,
+ /*DefaultArguments=*/{},
+ /*PartialTemplateArgs=*/false, CTAI))
+ return true;
+ InnerArgs = std::move(CTAI.SugaredConverted);
+ RemovePacksForFoldExpr = false;
----------------
zyn0217 wrote:
No it doesn't seem very useful ...
I thought we were collecting template arguments at each level of concept constraints, I was wrong :(
https://github.com/llvm/llvm-project/pull/177531
More information about the cfe-commits
mailing list