================ @@ -177,6 +185,11 @@ def CoyieldExpr : StmtNode<CoroutineSuspendExpr>; def ConceptSpecializationExpr : StmtNode<Expr>; def RequiresExpr : StmtNode<Expr>; +// C++26 Expansion statement support expressions +def CXXExpansionInitListExpr : StmtNode<Expr>; +def CXXExpansionInitListSelectExpr : StmtNode<Expr>; +def CXXDestructuringExpansionSelectExpr : StmtNode<Expr>; ---------------- Sirraide wrote:
‘impressive’ is definitely one way to describe it; 8 new AST nodes is... not great. I considered merging all the `CXX...ExpansionStmt` nodes into just `CXXExpansionStmt`, but then that one node would have all of the accessors for all the different variants (even though e.g. `getDecompositionDecl()` doesn’t make sense for an enumerating expansion statement), and you’d have to rely on another enum to figure out what kind of expansion statement you’re dealing with, at which point I felt it made more sense to just make it a separate AST mode. I can try refactoring it to where everything is just in `CXXExpansionStmt` if you think that would simplify things (figuring out an AST representation that is somewhat usable was kind of a headache for me with this feature...) > merging the SelectExpr nodes - to the extent we need these, the index is > implicit from the expansion order. And these things are always expanded, when > they are created, when do we need an index? > For the initializer, can we maybe use a template argument, or a super set > thereof? I agree they are pretty awkward. I was thinking of refactoring this to be similar to how we do pack expansion (i.e. have a global index variable somewhere in Sema that’s managed by some RAII object when we perform expansion). I have two questions about this part though: 1. As I see it, we still need the index as an expression for iterating expansion statements because we need to evaluate `begin + i`. Is there a good way to do that w/o making `i` a DRE to a template parameter? 2. For enumerating and destructuring expansion statements, we really don’t need the index, but I presume the `ExpansionStmtDecl` would still have to have *some* template parameter? Do we support creating or instantiating a template that has no template parameters? Also, even if we do, we don’t know what kind of expansion statement we’re dealing with when we create the `ExpansionStmtDecl`, though we might be able to create the template parameter list and attach it to the declaration once we know that we need it and set it to `nullptr` before that. https://github.com/llvm/llvm-project/pull/165195 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
