[clang] [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (PR #102131)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 23:10:42 PDT 2024
================
@@ -972,8 +972,15 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
// equivalence.
LocalInstantiationScope ScopeForParameters(S);
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
- for (auto *PVD : FD->parameters())
- ScopeForParameters.InstantiatedLocal(PVD, PVD);
+ for (auto *PVD : FD->parameters()) {
+ if (!PVD->isParameterPack()) {
+ ScopeForParameters.InstantiatedLocal(PVD, PVD);
+ continue;
+ }
+ // Parameter packs should expand to a size-of-1 argument.
+ ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
+ ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
+ }
----------------
mizvekov wrote:
Also, this new comment should be clearer here.
We are trying to create a no-transformation scope, so in the end there is no actual pack expansion going on here: We are expanding an unexpanded pack into an expansion of one unexpanded pack, so we are back where we started and nothing was expanded. So this looks like a clever hack which avoided creating the SubstTemplateTypeParmPackType through a loophole.
Since concepts make this a valid use case, we could explore improving this abstraction, for example creating some sort of NonInstantiation scope where you just have to register which declarations are in scope, but shouldn't transform them.
https://github.com/llvm/llvm-project/pull/102131
More information about the cfe-commits
mailing list