[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 10:15:58 PDT 2025


================
@@ -55,10 +55,154 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s,
   if (mlir::succeeded(emitSimpleStmt(s, useCurrentScope)))
     return mlir::success();
 
-  // Only a subset of simple statements are supported at the moment.  When more
-  // kinds of statements are supported, a
-  //     switch (s->getStmtClass()) {
-  // will be added here.
+  switch (s->getStmtClass()) {
+
+#define STMT(Type, Base)
+#define ABSTRACT_STMT(Op)
+#define EXPR(Type, Base) case Stmt::Type##Class:
+#include "clang/AST/StmtNodes.inc"
+    {
+      // Remember the block we came in on.
+      mlir::Block *incoming = builder.getInsertionBlock();
+      assert(incoming && "expression emission must have an insertion point");
+
+      emitIgnoredExpr(cast<Expr>(s));
----------------
erichkeane wrote:

StmtNodes.inc makes anything that inherits from `Expr` fall to this too.  So it looks to me that `UnaryOperator` would hit this, plus just about everything else there.  Perhaps we do a good job making sure we don't call `EmitStmt` with any other sort of expression?  

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


More information about the cfe-commits mailing list