[clang] [CIR] Terminate conditional regions after creation; fix glvalue conditional with a throw arm (PR #210384)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 17 13:49:19 PDT 2026


================
@@ -3205,7 +3180,17 @@ LValue CIRGenFunction::emitConditionalOperatorLValue(
 
   assert((info.lhs || info.rhs) &&
          "both operands of glvalue conditional are throw-expressions?");
-  return info.lhs ? *info.lhs : *info.rhs;
+
+  // Only one arm produced an lvalue; the other was a throw-expression. The
+  // surviving arm's pointer was materialized inside the ternary's region and
+  // is not visible past the op, so address the result through the ternary's
+  // result value, which the region's cir.yield carries out.
+  LValue &survivingLV = info.lhs ? *info.lhs : *info.rhs;
+  Address survivingAddr = survivingLV.getAddress();
+  Address result(info.result, survivingAddr.getElementType(),
+                 survivingAddr.getAlignment());
+  assert(!cir::MissingFeatures::opTBAA());
+  return makeAddrLValue(result, expr->getType(), survivingLV.getBaseInfo());
----------------
andykaylor wrote:

Got it. That makes sense.

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


More information about the cfe-commits mailing list