================
@@ -1650,6 +1665,23 @@ namespace {
return inherited::TransformTemplateArgument(Input, Output, Uneval);
}
+ std::optional<unsigned> ComputeSizeOfPackExprWithoutSubstitution(
+ ArrayRef<TemplateArgument> PackArgs) {
+ // Don't do this when rewriting template parameters for CTAD:
+ // 1) The heuristic needs the unpacked Subst* nodes to figure out the
+ // expanded size, but this never applies since Subst* nodes are not
+ // created in rewrite scenarios.
+ //
+ // 2) The heuristic substitutes into the pattern with pack expansion
+ // suppressed, which does not meet the requirements for argument
+ // rewriting when template arguments include a non-pack matching
against
+ // a pack, particularly when rewriting an alias CTAD.
+ if (TemplateArgs.isRewrite())
+ return std::nullopt;
----------------
zyn0217 wrote:
I'm not sure I understand what 'dependent template arguments' means here. Did
you mean we should run the heuristic if any of the arguments is
`TA->isDependent()`? Note that the rewrite template arguments are basically
dependent, so I have no idea if that would work.
The underlying issue is that the heuristic doesn't expand the template
arguments, so we end up without a valid index for rewrite substitution. It used
to assume the packs in the rewrite arguments contained only a single
PackExpansionType, but that no longer holds in this scenario because the
template arguments we have now are deduced arguments - not those injected
template parameters. So I’m a bit worried it might be overkill to skip the
heuristic in any conditions other than rewrite - chances are that we'll have
Subst* nodes otherwise, right?
https://github.com/llvm/llvm-project/pull/132061
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits