Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -4366,12 +4366,12 @@ def CIR_TryOp : CIR_Op<"try",[
let arguments = (ins
UnitAttr:$synthetic,
UnitAttr:$cleanup,
CIR_TryHandlerArrayAttr:$handler_types
DefaultValuedAttr<CIR_TryHandlerArrayAttr, "{}">:$handler_types
);

let regions = (region
AnyRegion:$try_region,
VariadicRegion<MinSizedRegion<1>>:$handler_regions
VariadicRegion<AnyRegion>:$handler_regions
);

let assemblyFormat = [{
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/CIR/Dialect/IR/CIRDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2977,8 +2977,11 @@ static mlir::ParseResult parseTryHandlerRegions(
return failure();
}

if (!currRegion.empty() && !(currRegion.back().mightHaveTerminator() &&
currRegion.back().getTerminator()))
if (currRegion.empty())
return parser.emitError(regionLoc, "handler region shall not be empty");

if (!(currRegion.back().mightHaveTerminator() &&
currRegion.back().getTerminator()))
return parser.emitError(
regionLoc, "blocks are expected to be explicitly terminated");

Expand Down
5 changes: 3 additions & 2 deletions clang/test/CIR/IR/invalid-try-catch.cir
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ module {

cir.func dso_local @invalid_catch_empty_block() {
cir.scope {
// expected-error @below {{'cir.try' op region #1 ('handler_regions') failed to verify constraint: region with at least 1 blocks}}
cir.try {
cir.yield
} catch all {
}
// expected-error @below {{'cir.try' handler region shall not be empty}}
catch all {
}
}
cir.return
Expand Down