[clang] [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (PR #102131)

via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 25 22:23:28 PDT 2024


================
@@ -972,8 +972,30 @@ 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;
+      }
+      // This is hacky: we're mapping the parameter pack to a size-of-1 argument
+      // to avoid building SubstTemplateTypeParmPackTypes for
+      // PackExpansionTypes. The SubstTemplateTypeParmPackType node would
+      // otherwise reference the AssociatedDecl of the template arguments, which
+      // is, in this case, the template declaration.
+      //
+      // However, as we're also calculating the redeclarations of the template,
+      // the canonical declarations thereof are actually themselves at the
----------------
cor3ntin wrote:

```suggestion
      // However, as we are in the process of comparing potential re-declarations,
      // the canonical declaration is the declaration itself at this point.
```

https://github.com/llvm/llvm-project/pull/102131


More information about the cfe-commits mailing list