[clang] [CIR] Upstream support for switch statements case kinds (PR #138003)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 08:39:29 PDT 2025


================
@@ -455,7 +456,8 @@ CIRGenFunction::emitCaseDefaultCascade(const T *stmt, mlir::Type condType,
     if (isa<DefaultStmt>(sub) && isa<CaseStmt>(stmt)) {
       subStmtKind = SubStmtKind::Default;
       builder.createYield(loc);
-    } else if (isa<CaseStmt>(sub) && isa<DefaultStmt>(stmt)) {
+    } else if ((isa<CaseStmt>(sub) && isa<DefaultStmt>(stmt)) ||
----------------
Andres-Salamanca wrote:

The same goes for `case -> default`. When we find a cascading case like `case -> case` or `case -> default`, we emit a `yield` to indicate fallthrough.
Here's an example of that case:
https://github.com/llvm/llvm-project/blob/44856d957e3a878e1f15d5ab0009bff9c4d87e6d/clang/lib/CIR/CodeGen/CIRGenStmt.cpp#L480

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


More information about the cfe-commits mailing list