[clang] [CIR] Call std::terminate when __cxa_end_catch throws during unwinding (PR #245085)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 23 11:54:55 PST 2026
================
@@ -642,11 +652,22 @@ mlir::LogicalResult ItaniumEHLowering::lowerEhInitiate(
llvm::make_early_inc_range(op.getCatchToken().getUses())) {
if (auto endOp =
mlir::dyn_cast<cir::EndCatchOp>(tokenUsers.getOwner())) {
+ bool onUnwindPath = unwindEndCatches.contains(endOp);
builder.setInsertionPoint(endOp);
- cir::CallOp::create(builder, endOp.getLoc(),
- mlir::FlatSymbolRefAttr::get(endCatchFunc),
- voidType, mlir::ValueRange{});
+ auto call =
+ cir::CallOp::create(builder, endOp.getLoc(),
+ mlir::FlatSymbolRefAttr::get(endCatchFunc),
+ voidType, mlir::ValueRange{});
+ mlir::Location endLoc = endOp.getLoc();
endOp.erase();
+ if (onUnwindPath) {
+ ensureClangCallTerminate(endLoc);
+ mlir::Block *terminateBlock = buildTerminateBlock(
+ call->getParentOfType<cir::FuncOp>(), endLoc);
+ mlir::IRRewriter rewriter(builder);
+ cir::replaceCallWithTryCall(call, terminateBlock, endLoc,
----------------
andykaylor wrote:
Why are you replacing the call that was just created rather than creating a `TryCall` to begin with?
https://github.com/llvm/llvm-project/pull/245085
More information about the cfe-commits
mailing list