|
| 1 | +// RUN: %target-swift-emit-sil %s -I %S/Inputs -enable-cxx-interop | %FileCheck %s |
| 2 | + |
| 3 | +// We can't yet call member functions correctly on Windows (SR-13129). |
| 4 | +// XFAIL: OS=windows-msvc |
| 5 | +// REQUIRES: fixing-after-30630 |
| 6 | + |
| 7 | +import MemberTemplates |
| 8 | + |
| 9 | +// CHECK-LABEL: sil hidden @$s4main9basicTestyyF : $@convention(thin) () -> () |
| 10 | + |
| 11 | +// CHECK: [[ADD:%.*]] = function_ref @_ZN18HasMemberTemplates3addIiEET_S1_S1_ : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 12 | +// CHECK: apply [[ADD]]({{.*}}) : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 13 | + |
| 14 | +// CHECK: [[ADD_TWO_TEMPLATES:%.*]] = function_ref @_ZN18HasMemberTemplates15addTwoTemplatesIiiEET_S1_T0_ : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 // user: %26 |
| 15 | +// CHECK: apply [[ADD_TWO_TEMPLATES]]({{.*}}) : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 16 | + |
| 17 | +// CHECK: [[ADD_ALL:%.*]] = function_ref @_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_ : $@convention(c) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 // user: %39 |
| 18 | +// CHECK: apply [[ADD_ALL]]({{.*}}) : $@convention(c) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 19 | + |
| 20 | +// CHECK: [[DO_NOTHING:%.*]] = function_ref @_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_ : $@convention(c) (UnsafePointer<Int32>, @inout HasMemberTemplates) -> () // user: %48 |
| 21 | +// CHECK: apply [[DO_NOTHING]]({{.*}}) : $@convention(c) (UnsafePointer<Int32>, @inout HasMemberTemplates) -> () |
| 22 | + |
| 23 | +// CHECK-LABEL: end sil function '$s4main9basicTestyyF' |
| 24 | +func basicTest() { |
| 25 | + var i: Int32 = 0 |
| 26 | + var obj = HasMemberTemplates() |
| 27 | + obj.add(i, i) |
| 28 | + obj.addTwoTemplates(i, i) |
| 29 | + obj.addAll(i, i, i) |
| 30 | + obj.doNothingConstRef(&i) |
| 31 | +} |
| 32 | + |
| 33 | +// CHECK-LABEL: sil hidden_external [clang HasMemberTemplates._ZN18HasMemberTemplates3addIiEET_S1_S1_] @_ZN18HasMemberTemplates3addIiEET_S1_S1_ : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 34 | + |
| 35 | +// CHECK-LABEL: sil hidden_external [clang HasMemberTemplates._ZN18HasMemberTemplates15addTwoTemplatesIiiEET_S1_T0_] @_ZN18HasMemberTemplates15addTwoTemplatesIiiEET_S1_T0_ : $@convention(c) (Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 36 | + |
| 37 | +// CHECK-LABEL: sil hidden_external [clang HasMemberTemplates._ZN18HasMemberTemplates6addAllIiiEEiiT_T0_] @_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_ : $@convention(c) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 |
| 38 | + |
| 39 | +// CHECK-LABEL: sil hidden_external [clang HasMemberTemplates._ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_] @_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_ : $@convention(c) (UnsafePointer<Int32>, @inout HasMemberTemplates) -> () |
| 40 | + |
| 41 | +// CHECK-LABEL: sil hidden @$s4main12testSetValueyyF : $@convention(thin) () -> () |
| 42 | + |
| 43 | +// CHECK: [[SET_VALUE:%.*]] = function_ref @_ZN32TemplateClassWithMemberTemplatesIiE8setValueIlEEvT_ : $@convention(c) (Int, @inout __CxxTemplateInst32TemplateClassWithMemberTemplatesIiE) -> () |
| 44 | +// CHECK: apply [[SET_VALUE]]({{.*}}) : $@convention(c) (Int, @inout __CxxTemplateInst32TemplateClassWithMemberTemplatesIiE) -> () |
| 45 | + |
| 46 | +// CHECK-LABEL: end sil function '$s4main12testSetValueyyF' |
| 47 | +func testSetValue() { |
| 48 | + var w = IntWrapper(11) |
| 49 | + w.setValue(42) |
| 50 | +} |
0 commit comments