[clang] [CIR] Add if statement support (PR #134333)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 09:47:49 PDT 2025
================
@@ -135,6 +135,55 @@ mlir::Location CIRGenFunction::getLoc(mlir::Location lhs, mlir::Location rhs) {
return mlir::FusedLoc::get(locs, metadata, &getMLIRContext());
}
+bool CIRGenFunction::ContainsLabel(const Stmt *s, bool ignoreCaseStmts) {
+ // Null statement, not a label!
+ if (!s)
+ return false;
+
+ // If this is a label, we have to emit the code, consider something like:
+ // if (0) { ... foo: bar(); } goto foo;
+ //
+ // TODO: If anyone cared, we could track __label__'s, since we know that you
+ // can't jump to one from outside their declared region.
+ if (isa<LabelStmt>(s))
+ return true;
+
+ // If this is a case/default statement, and we haven't seen a switch, we
+ // have to emit the code.
+ if (isa<SwitchCase>(s) && !ignoreCaseStmts)
+ return true;
+
+ // If this is a switch statement, we want to ignore cases below it.
+ if (isa<SwitchStmt>(s))
----------------
erichkeane wrote:
I don't think this is necessary? `SwitchStmt` we probably still want the lables for (since you can jump into them), but `CaseStmt` are the ones we want to ignore.
So the comment isn't really accurate
https://github.com/llvm/llvm-project/pull/134333
More information about the cfe-commits
mailing list