[clang] [CIR] Upstream initial for-loop support (PR #132266)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 20 11:24:47 PDT 2025


================
@@ -280,3 +313,77 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const ReturnStmt &s) {
 
   return mlir::success();
 }
+
+mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
+  cir::ForOp forOp;
+
+  // TODO: pass in an array of attributes.
+  auto forStmtBuilder = [&]() -> mlir::LogicalResult {
+    mlir::LogicalResult loopRes = mlir::success();
+    // Evaluate the first part before the loop.
+    if (s.getInit())
----------------
erichkeane wrote:

Oh interesting... hrmph.  This is supposed to be in scope with the for IIRC, do we need to create a lexical scope here?

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


More information about the cfe-commits mailing list