[clang] [CIR] Fix destructor calls with temporary objects (PR #161922)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 4 05:36:30 PDT 2025


================
@@ -1151,7 +1153,9 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
           CIRGenFunction::LexicalScope lexScope{cgf, loc,
                                                 b.getInsertionBlock()};
           cgf.curLexScope->setAsTernary();
-          b.create<cir::YieldOp>(loc, cgf.evaluateExprAsBool(e->getRHS()));
+          mlir::Value res = cgf.evaluateExprAsBool(e->getRHS());
+          lexScope.forceCleanup();
+          b.create<cir::YieldOp>(loc, res);
----------------
xlauko wrote:

```suggestion
          cir::YieldOp::create(b, loc, res);
```

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


More information about the cfe-commits mailing list