mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
14 lines
292 B
Objective-C
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
|