[llvm-branch-commits] [clang] [clang-tools-extra] [clang] support pack expansions for trailing requires clauses (PR #133190)

Erich Keane via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 1 16:39:19 PDT 2025


================
@@ -78,6 +78,22 @@ class UnresolvedSetImpl;
 class VarTemplateDecl;
 enum class ImplicitParamKind;
 
+// Holds a constraint expression along with a pack expansion index, if
+// expanded.
+struct AssociatedConstraint {
+  const Expr *ConstraintExpr = nullptr;
+  int ArgumentPackSubstitutionIndex = -1;
----------------
erichkeane wrote:

Honestly, this is something that I find myself re-learning EVERY SINGLE time.  It is unbelievably confusing and error-prone to figure out what the 'non-value' is here.  In reality it would be great if we had a std::optional for all of these (or, at least, a type to wrap the idea of 2^N-2 values and a sentinel).  

While I understand the consistency argument, I'd say we should 'do it right' this time (or at least more so), and clean up over time.

THAT SAID, if the -1 doesn't get 'outside' of this class (that is, the constructor ensure it doesn't take a -1, and that just be the 'has no pack' version-by-construction via an alternate constructor) other than for the purposes of serialization (perhaps via a ::CreateFromDeserialization esque method), than I think that at least limits the fallout of hte magic-number to only the internals of this, which is more acceptable.

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


More information about the llvm-branch-commits mailing list