================
@@ -524,6 +525,479 @@ class CoreturnStmt : public Stmt {
   }
 };
 
+/// CXXExpansionStmt - Base class for an unexpanded C++ expansion statement.
+///
+/// The main purpose for this class is to store the AST nodes common to all
+/// variants of expansion statements; it also provides storage for additional
+/// subexpressions required by its derived classes. This is to simplify the
+/// implementation of 'children()' and friends.
+///
+/// \see ExpansionStmtDecl
+/// \see CXXEnumeratingExpansionStmt
+/// \see CXXIteratingExpansionStmt
+/// \see CXXDestructuringExpansionStmt
+/// \see CXXDependentExpansionStmt
+class CXXExpansionStmt : public Stmt {
+  friend class ASTStmtReader;
+
+  ExpansionStmtDecl *ParentDecl;
+  SourceLocation ForLoc;
+  SourceLocation LParenLoc;
+  SourceLocation ColonLoc;
+  SourceLocation RParenLoc;
+
+protected:
+  enum SubStmt {
+    INIT,
+    VAR,
+    BODY,
+    FIRST_CHILD_STMT,
+
+    // CXXDependentExpansionStmt
+    EXPANSION_INITIALIZER = FIRST_CHILD_STMT,
+    COUNT_CXXDependentExpansionStmt,
+
+    // CXXDestructuringExpansionStmt
+    DECOMP_DECL = FIRST_CHILD_STMT,
+    COUNT_CXXDestructuringExpansionStmt,
+
+    // CXXIteratingExpansionStmt
+    RANGE = FIRST_CHILD_STMT,
+    BEGIN,
+    END,
+    COUNT_CXXIteratingExpansionStmt,
+
+    MAX_COUNT = COUNT_CXXIteratingExpansionStmt,
+  };
+
+  // Managing the memory for this properly would be rather complicated, and
+  // expansion statements are fairly uncommon, so just allocate space for the
----------------
Sirraide wrote:

Sure, but I don’t have a good idea how else to implement the subexpression 
storage for this without it either wasting at least 8 bytes of memory or 
turning into a terrible mess (specifically, implementing `children()` and the 
child iterators becomes rather horrible).

https://github.com/llvm/llvm-project/pull/165195
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to