Skip to content

Commit 77397f8

Browse files
committed
Address code review comments
1 parent 05e1171 commit 77397f8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,24 +4339,26 @@ def CIR_TryOp : CIR_Op<"try",[
43394339
clauses are usually allocated in the same parent as `cir.try`.
43404340

43414341
`synthetic`: use `cir.try` to represent try/catches not originally
4342-
present in the source code (e.g. `g = new Class` under `-fexceptions`).
4342+
present in the source code. For example, a synthetic `cir.try` region
4343+
is created around the constructor call when `operator new` is used
4344+
so that the memory allocated will be freed if the constructor throws
4345+
an exception.
43434346

4344-
`cleanup`: signal to targets (LLVM for now) that this try/catch, needs
4345-
to specially tag their landing pads as needing "cleanup".
4347+
`cleanup`: indicates that there are cleanups that must be performed
4348+
when exiting the try region via exception, even if the exception is not
4349+
caught.
43464350

43474351
Example:
43484352

43494353
```mlir
4350-
%0 = cir.alloc.exception 16 -> !cir.ptr<!some_record>
4351-
%1 = cir.get_global @d2 : !cir.ptr<!some_record>
4352-
cir.try synthetic cleanup {
4353-
cir.call exception @_ZN7test2_DC1ERKS_(%0, %1)
4354-
: (!cir.ptr<!some_record>, !cir.ptr<!some_record>) -> () cleanup {
4355-
%2 = cir.cast bitcast %0 : !cir.ptr<!some_record> -> !cir.ptr<!void>
4356-
cir.free.exception %2
4357-
cir.yield
4358-
}
4354+
cir.try {
4355+
cir.call exception @function() : () -> ()
4356+
cir.yield
4357+
} catch [type #cir.global_view<@_ZTIPf> : !cir.ptr<!u8i>] {
43594358
...
4359+
cir.yield
4360+
} unwind {
4361+
cir.resume
43604362
}
43614363
```
43624364
}];

0 commit comments

Comments
 (0)