[clang] [Clang][Sema] Avoid pack expansion for expanded empty PackIndexingExprs (PR #92385)

via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 05:53:25 PDT 2024


================
@@ -4381,11 +4381,13 @@ class PackIndexingExpr final
 
   PackIndexingExpr(QualType Type, SourceLocation EllipsisLoc,
                    SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr,
-                   ArrayRef<Expr *> SubstitutedExprs = {})
+                   ArrayRef<Expr *> SubstitutedExprs = {},
+                   bool EmptyPack = false)
       : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
         EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
         SubExprs{PackIdExpr, IndexExpr},
-        TransformedExpressions(SubstitutedExprs.size()) {
+        TransformedExpressions(EmptyPack ? size_t(-1)
----------------
cor3ntin wrote:

I would much prefer we would do something like

```cpp
unsigned ExpandedToEmptyPack : 1;
size_t TransformedExpressions : sizeof(size_t) -1;
```
To avoid the magic value

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


More information about the cfe-commits mailing list