File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
clang/include/clang/CIR/Dialect/IR Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -4310,24 +4310,26 @@ def CIR_TryOp : CIR_Op<"try",[
43104310 clauses are usually allocated in the same parent as `cir.try`.
43114311
43124312 `synthetic`: use `cir.try` to represent try/catches not originally
4313- present in the source code (e.g. `g = new Class` under `-fexceptions`).
4313+ present in the source code. For example, a synthetic `cir.try` region
4314+ is created around the constructor call when `operator new` is used
4315+ so that the memory allocated will be freed if the constructor throws
4316+ an exception.
43144317
4315- `cleanup`: signal to targets (LLVM for now) that this try/catch, needs
4316- to specially tag their landing pads as needing "cleanup".
4318+ `cleanup`: indicates that there are cleanups that must be performed
4319+ when exiting the try region via exception, even if the exception is not
4320+ caught.
43174321
43184322 Example:
43194323
43204324 ```mlir
4321- %0 = cir.alloc.exception 16 -> !cir.ptr<!some_record>
4322- %1 = cir.get_global @d2 : !cir.ptr<!some_record>
4323- cir.try synthetic cleanup {
4324- cir.call exception @_ZN7test2_DC1ERKS_(%0, %1)
4325- : (!cir.ptr<!some_record>, !cir.ptr<!some_record>) -> () cleanup {
4326- %2 = cir.cast bitcast %0 : !cir.ptr<!some_record> -> !cir.ptr<!void>
4327- cir.free.exception %2
4328- cir.yield
4329- }
4325+ cir.try {
4326+ cir.call exception @function() : () -> ()
4327+ cir.yield
4328+ } catch [type #cir.global_view<@_ZTIPf> : !cir.ptr<!u8i>] {
43304329 ...
4330+ cir.yield
4331+ } unwind {
4332+ cir.resume
43314333 }
43324334 ```
43334335 }];
You can’t perform that action at this time.
0 commit comments