File tree 5 files changed +41
-4
lines changed
5 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -2605,7 +2605,10 @@ class SyncCallEmission final : public CallEmission {
2605
2605
if (fnConv.getNumDirectSILResults () == 1
2606
2606
&& (fnConv.getDirectSILResults ().begin ()->getConvention ()
2607
2607
== ResultConvention::Autoreleased)) {
2608
- result = emitObjCRetainAutoreleasedReturnValue (IGF, result);
2608
+ if (IGF.IGM .Context .LangOpts .EnableObjCInterop )
2609
+ result = emitObjCRetainAutoreleasedReturnValue (IGF, result);
2610
+ else
2611
+ IGF.emitNativeStrongRetain (result, IGF.getDefaultAtomicity ());
2609
2612
}
2610
2613
2611
2614
auto origFnType = getCallee ().getOrigFunctionType ();
Original file line number Diff line number Diff line change
1
+ #define CF_BRIDGED_TYPE (T ) __attribute__((objc_bridge(T)))
2
+
3
+ typedef struct CF_BRIDGED_TYPE (id ) __CFBridgedType * CFBridgedTypeRef ;
4
+
5
+ __attribute__((cf_audited_transfer ))
6
+ CFBridgedTypeRef returnsACFBridgedType (void );
Original file line number Diff line number Diff line change @@ -33,5 +33,9 @@ module SynthesizedProtocol {
33
33
}
34
34
35
35
module PointerAuth {
36
- header "ptrauth_field_fptr_import.h"
37
- }
36
+ header "ptrauth_field_fptr_import.h"
37
+ }
38
+
39
+ module CFBridgedType {
40
+ header "CFBridgedType.h"
41
+ }
Original file line number Diff line number Diff line change 1
- // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-ptrsize -check-prefix %target-cpu -DINT=i%target-ptrsize %s
1
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -enable-objc-interop - emit-ir | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-ptrsize -check-prefix %target-cpu -DINT=i%target-ptrsize %s
2
2
3
3
// rdar://16565958
4
4
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -module-name cf_objc_retainAutoreleasedReturnValue -I %S/Inputs %s -enable-objc-interop -emit-ir | %FileCheck %s
2
+ // RUN: %target-swift-frontend -module-name cf_objc_retainAutoreleasedReturnValue -I %S/Inputs %s -emit-ir | %FileCheck %s --check-prefix=NO_INTEROP
3
+
4
+ import CFBridgedType
5
+
6
+ @inline ( never)
7
+ public func foo( ) {
8
+ let _ = returnsACFBridgedType ( )
9
+ }
10
+
11
+ // With interop enabled, this should use objc_retainAutoreleasedReturnValue()
12
+
13
+ // CHECK-LABEL: define protected swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
14
+ // CHECK: entry:
15
+ // CHECK: %0 = call {{.*}}@returnsACFBridgedType()
16
+ // CHECK: %1 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %0)
17
+
18
+ // Without interop, it should call swift_retain() instead.
19
+
20
+ // NO_INTEROP-LABEL: define protected swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
21
+ // NO_INTEROP: entry:
22
+ // NO_INTEROP: %0 = call {{.*}}@returnsACFBridgedType()
23
+ // NO_INTEROP: %1 = call ptr @swift_retain(ptr returned %0)
24
+
You can’t perform that action at this time.
0 commit comments