Skip to content

Commit 83b51b9

Browse files
martinboehmezoecarver
authored andcommitted
Add SILGen and IRGen tests for passing Objective-C types to C++
constructors.
1 parent faca489 commit 83b51b9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs -enable-cxx-interop -emit-ir %s | %FileCheck %s
2+
3+
// REQUIRES: CPU=x86_64
4+
// REQUIRES: objc_interop
5+
6+
import ConstructorsObjC
7+
8+
public func createConstructorWithNSArrayParam() -> ConstructorWithNSArrayParam {
9+
// CHECK: define swiftcc void @"$s4main33createConstructorWithNSArrayParamSo0cdeF0VyF"()
10+
// CHECK-NOT: define
11+
// CHECK: [[VAR:%[0-9]+]] = alloca %TSo27ConstructorWithNSArrayParamV, align 1
12+
// CHECK: %{{[0-9]+}} = call swiftcc %TSo7NSArrayC* @"$sSa10FoundationE19_bridgeToObjectiveCSo7NSArrayCyF"(%swift.bridge* %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$sypN", i32 0, i32 1))
13+
// CHECK: [[CAST_VAR:%[0-9]+]] = bitcast %TSo27ConstructorWithNSArrayParamV* [[VAR]] to %struct.ConstructorWithNSArrayParam*
14+
// CHECK: call void @_ZN27ConstructorWithNSArrayParamC1EP7NSArray(%struct.ConstructorWithNSArrayParam* noalias [[CAST_VAR]], [[VAR]]* %{{[0-9]+}})
15+
return ConstructorWithNSArrayParam([])
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs -enable-cxx-interop -emit-sil %s | %FileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
5+
import ConstructorsObjC
6+
7+
// CHECK: [[VAR:%[0-9]+]] = alloc_stack $ConstructorWithNSArrayParam
8+
// CHECK: [[TYPE:%[0-9]+]] = metatype $@thin ConstructorWithNSArrayParam.Type
9+
// CHECK: [[OPT_ARRAY:%[0-9]+]] = enum $Optional<NSArray>, #Optional.some!enumelt, %{{[0-9]+}} : $NSArray
10+
// CHECK: [[FUNC:%[0-9]+]] = function_ref @_ZN27ConstructorWithNSArrayParamC1EP7NSArray : $@convention(c) (Optional<NSArray>, @thin ConstructorWithNSArrayParam.Type) -> @out ConstructorWithNSArrayParam
11+
// CHECK: %{{[0-9]+}} = apply [[FUNC]]([[VAR]], [[OPT_ARRAY]], [[TYPE]]) : $@convention(c) (Optional<NSArray>, @thin ConstructorWithNSArrayParam.Type) -> @out ConstructorWithNSArrayParam
12+
let _ = ConstructorWithNSArrayParam([])

0 commit comments

Comments
 (0)