[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu May 1 17:47:06 PDT 2025
================
@@ -642,12 +798,97 @@ class CIRGenFunction : public CIRGenTypeCache {
void emitNullabilityCheck(LValue lhs, mlir::Value rhs,
clang::SourceLocation loc);
+ /// An object to manage conditionally-evaluated expressions.
+ class ConditionalEvaluation {
+ mlir::OpBuilder::InsertPoint insertPt;
+
+ public:
+ ConditionalEvaluation(CIRGenFunction &cgf)
+ : insertPt(cgf.builder.saveInsertionPoint()) {}
+ ConditionalEvaluation(mlir::OpBuilder::InsertPoint ip) : insertPt(ip) {}
+
+ void begin(CIRGenFunction &cgf) {
----------------
andykaylor wrote:
If we saved a reference to `cgf` in the constructor, we wouldn't need to pass it to `begin()` and `end()`
https://github.com/llvm/llvm-project/pull/138156
More information about the cfe-commits
mailing list