Files
swift-mirror/test/Interpreter/Inputs/ObjCException.m
Arnold Schwaighofer b9728151df SILGen: Fix no escape verification if the closure throws an exception
It is safe to omit the retain/release dance in the reabstraction thunk
because we know we have an aditional reference outstanding for the
is_escaping verification.

The problem with throwing an objc exception inside a noescape closure is
that we verify the reference count of the closure sentinel. The
reabstraction thunk would increase the reference count call the
implementation function that then throws skipping the decrement.

rdar://40857699
2018-06-08 13:04:52 -07:00

14 lines
292 B
Objective-C

#import "ObjCException.h"
@implementation ExceptionCatcher
- (NSException* _Nullable) tryBlock:(__attribute__((noescape)) void(^_Nonnull)(void))unsafeBlock {
@try {
unsafeBlock();
}
@catch (NSException *exception) {
return exception;
}
return nil;
}
@end