[clang] [CIR] Add if statement support (PR #134333)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 6 11:12:48 PDT 2025
================
@@ -316,6 +316,106 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
emitLValue(e);
}
+/// Emit an `if` on a boolean condition, filling `then` and `else` into
+/// appropriated regions.
+mlir::LogicalResult CIRGenFunction::emitIfOnBoolExpr(const Expr *cond,
+ const Stmt *thenS,
+ const Stmt *elseS) {
+ // Attempt to be more accurate as possible with IfOp location, generate
+ // one fused location that has either 2 or 4 total locations, depending
+ // on else's availability.
+ auto getStmtLoc = [this](const Stmt &s) {
+ return mlir::FusedLoc::get(&getMLIRContext(),
----------------
Andres-Salamanca wrote:
Changes applied Let me know if it looks good now
https://github.com/llvm/llvm-project/pull/134333
More information about the cfe-commits
mailing list