[clang] [Clang] Treat the body of an expansion statement with expansion size 0 as discarded (PR #212319)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 4 22:22:28 PDT 2026


================
@@ -726,15 +739,19 @@ class CXXExpansionStmtPattern final
     COUNT_Iterating,
   };
 
-  CXXExpansionStmtPattern(ExpansionStmtKind PatternKind, EmptyShell Empty);
+  CXXExpansionStmtPattern(ExpansionStmtKind PatternKind, bool HasExpansionSize,
+                          EmptyShell Empty);
   CXXExpansionStmtPattern(ExpansionStmtKind PatternKind,
                           CXXExpansionStmtDecl *ESD, Stmt *Init,
                           DeclStmt *ExpansionVar, SourceLocation LParenLoc,
-                          SourceLocation ColonLoc, SourceLocation RParenLoc);
+                          SourceLocation ColonLoc, SourceLocation RParenLoc,
+                          ExpansionSize Size);
 
 public:
-  static CXXExpansionStmtPattern *
-  CreateEmpty(ASTContext &Context, EmptyShell Empty, ExpansionStmtKind Kind);
+  static CXXExpansionStmtPattern *CreateEmpty(ASTContext &Context,
+                                              EmptyShell Empty,
+                                              ExpansionStmtKind Kind,
+                                              bool HasExpansionSize);
----------------
ojhunt wrote:

Can `HasExpansionSize` be a `std::optional<unsigned>` as the expansion (as per usual I don't have anything like the understanding of template logic that you and others have).

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


More information about the cfe-commits mailing list