[clang] [CIR] Upstream support for break and continue statements (PR #134181)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 4 11:38:45 PDT 2025


================
@@ -569,6 +569,36 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
   ];
 }
 
+//===----------------------------------------------------------------------===//
+// BreakOp
+//===----------------------------------------------------------------------===//
+
+def BreakOp : CIR_Op<"break", [Terminator]> {
+  let summary = "C/C++ `break` statement equivalent";
+  let description = [{
+    The `cir.break` operation is used to cease the execution of the current
+    loop or switch and transfer control to the parent operation. It is only
----------------
andykaylor wrote:

I don't think so. We're either breaking out of a loop or a switch operation. After breaking out of the loop or switch, we're transferring control to the parent operation. Would this be better?
```suggestion
    loop or switch operation and transfer control to the parent operation. It is only
```

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


More information about the cfe-commits mailing list