|
1 |
| -// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name pointer_conversion -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -enable-objc-interop | %FileCheck %s |
| 1 | +// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name pointer_conversion \ |
| 2 | +// RUN: -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -enable-objc-interop \ |
| 3 | +// RUN: -import-objc-header %S/Inputs/readbytes.h \ |
| 4 | +// RUN: | %FileCheck %s |
2 | 5 |
|
3 | 6 | // FIXME: rdar://problem/19648117 Needs splitting objc parts out
|
4 | 7 | // REQUIRES: objc_interop
|
@@ -138,6 +141,56 @@ func arrayToPointer() {
|
138 | 141 | // CHECK: [[TAKES_OPT_CONST_POINTER:%.*]] = function_ref @$s18pointer_conversion20takesOptConstPointer_3andySPySiGSg_SitF :
|
139 | 142 | // CHECK: apply [[TAKES_OPT_CONST_POINTER]]([[OPTPTR]], [[RESULT1]])
|
140 | 143 | // CHECK: destroy_value [[OWNER]]
|
| 144 | + |
| 145 | + // -- test implicit conversions allowed by C functions |
| 146 | + read_char(ints) |
| 147 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss35_convertConstArrayToPointerArgumentyyXlSg_q_tSayxGs01_E0R_r0_lF |
| 148 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafePointer<Int8>>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 149 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafePointer<Int8> |
| 150 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafePointer<Int8> on |
| 151 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafePointer<Int8>>, #Optional.some!enumelt, [[PTR_MD]] |
| 152 | + // CHECK: [[READ_FN:%.*]] = function_ref @read_char : $@convention(c) (Optional<UnsafePointer<Int8>>) -> () |
| 153 | + // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafePointer<Int8>>) -> () |
| 154 | + read_uchar(ints); |
| 155 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss35_convertConstArrayToPointerArgumentyyXlSg_q_tSayxGs01_E0R_r0_lF |
| 156 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafePointer<UInt8>>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 157 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafePointer<UInt8> |
| 158 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafePointer<UInt8> on |
| 159 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafePointer<UInt8>>, #Optional.some!enumelt, [[PTR_MD]] |
| 160 | + // CHECK: [[READ_FN:%.*]] = function_ref @read_uchar : $@convention(c) (Optional<UnsafePointer<UInt8>>) -> () |
| 161 | + // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafePointer<UInt8>>) -> () |
| 162 | + read_void(ints); |
| 163 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss35_convertConstArrayToPointerArgumentyyXlSg_q_tSayxGs01_E0R_r0_lF |
| 164 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafeRawPointer>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 165 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeRawPointer |
| 166 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeRawPointer on |
| 167 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafeRawPointer>, #Optional.some!enumelt, [[PTR_MD]] |
| 168 | + // CHECK: [[READ_FN:%.*]] = function_ref @read_void : $@convention(c) (Optional<UnsafeRawPointer>) -> () |
| 169 | + // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafeRawPointer>) -> () |
| 170 | + write_char(&ints); |
| 171 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF |
| 172 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafeMutablePointer<Int8>>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 173 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutablePointer<Int8> |
| 174 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutablePointer<Int8> on |
| 175 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafeMutablePointer<Int8>>, #Optional.some!enumelt, [[PTR_MD]] |
| 176 | + // CHECK: [[WRITE_FN:%.*]] = function_ref @write_char : $@convention(c) (Optional<UnsafeMutablePointer<Int8>>) -> () |
| 177 | + // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafeMutablePointer<Int8>>) -> () |
| 178 | + write_uchar(&ints); |
| 179 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF |
| 180 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafeMutablePointer<UInt8>>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 181 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutablePointer<UInt8> |
| 182 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutablePointer<UInt8> on |
| 183 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafeMutablePointer<UInt8>>, #Optional.some!enumelt, [[PTR_MD]] |
| 184 | + // CHECK: [[WRITE_FN:%.*]] = function_ref @write_uchar : $@convention(c) (Optional<UnsafeMutablePointer<UInt8>>) -> () |
| 185 | + // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafeMutablePointer<UInt8>>) -> () |
| 186 | + write_void(&ints); |
| 187 | + // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF |
| 188 | + // CHECK: apply [[CONVERT_FN]]<Int, UnsafeMutableRawPointer>([[PTR_RESULT:%[0-9]+]], {{.*}}) |
| 189 | + // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutableRawPointer |
| 190 | + // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutableRawPointer on |
| 191 | + // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional<UnsafeMutableRawPointer>, #Optional.some!enumelt, [[PTR_MD]] |
| 192 | + // CHECK: [[WRITE_FN:%.*]] = function_ref @write_void : $@convention(c) (Optional<UnsafeMutableRawPointer>) -> () |
| 193 | + // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional<UnsafeMutableRawPointer>) -> () |
141 | 194 | }
|
142 | 195 |
|
143 | 196 | // CHECK-LABEL: sil hidden [ossa] @$s18pointer_conversion15stringToPointeryySSF
|
|
0 commit comments