|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/has_symbol_helper.swiftmodule -parse-as-library %S/Inputs/has_symbol_helper.swift -enable-library-evolution |
| 3 | +// RUN: %target-swift-frontend -emit-silgen %s -I %t -module-name test | %FileCheck %s |
| 4 | + |
| 5 | +// REQUIRES: VENDOR=apple |
| 6 | + |
| 7 | +@_weakLinked import has_symbol_helper |
| 8 | + |
| 9 | +// CHECK: sil hidden [ossa] @$s4test0A15GlobalFunctionsyyF : $@convention(thin) () -> () |
| 10 | +func testGlobalFunctions() { |
| 11 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper8function4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 12 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 13 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 14 | + if #_hasSymbol(function(with:)) {} |
| 15 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper11genericFuncyyxAA1PRzlFTwS : $@convention(thin) () -> Builtin.Int1 |
| 16 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 17 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 18 | + if #_hasSymbol(genericFunc(_:) as (S) -> Void) {} |
| 19 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper9cdeclFuncyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 20 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 21 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 22 | + if #_hasSymbol(cdeclFunc) {} |
| 23 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper19forwardDeclaredFuncyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 24 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 25 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 26 | + if #_hasSymbol(forwardDeclaredFunc) {} |
| 27 | +} |
| 28 | + |
| 29 | +// CHECK: sil hidden_external @$s17has_symbol_helper8function4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 30 | +// CHECK: sil hidden_external @$s17has_symbol_helper11genericFuncyyxAA1PRzlFTwS : $@convention(thin) () -> Builtin.Int1 |
| 31 | +// CHECK: sil hidden_external @$s17has_symbol_helper9cdeclFuncyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 32 | + |
| 33 | +// CHECK: sil hidden [ossa] @$s4test0A4VarsyyF : $@convention(thin) () -> () |
| 34 | +func testVars() { |
| 35 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper6globalSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 36 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 37 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 38 | + if #_hasSymbol(global) {} |
| 39 | +} |
| 40 | + |
| 41 | +// CHECK: sil hidden_external @$s17has_symbol_helper6globalSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 42 | + |
| 43 | +// CHECK: sil hidden [ossa] @$s4test0A6Structyy17has_symbol_helper1SVF : $@convention(thin) (@in_guaranteed S) -> () |
| 44 | +func testStruct(_ s: S) { |
| 45 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV6memberSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 46 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 47 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 48 | + if #_hasSymbol(s.member) {} |
| 49 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV6method4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 50 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 51 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 52 | + if #_hasSymbol(s.method(with:)) {} |
| 53 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV11genericFuncyyxAA1PRzlFTwS : $@convention(thin) () -> Builtin.Int1 |
| 54 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 55 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 56 | + if #_hasSymbol(s.genericFunc(_:) as (S) -> ()) {} |
| 57 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV10staticFuncyyFZTwS : $@convention(thin) () -> Builtin.Int1 |
| 58 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 59 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 60 | + if #_hasSymbol(S.staticFunc) {} |
| 61 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV12staticMemberSivpZTwS : $@convention(thin) () -> Builtin.Int1 |
| 62 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 63 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 64 | + if #_hasSymbol(S.staticMember) {} |
| 65 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SV6memberACSi_tcfcTwS : $@convention(thin) () -> Builtin.Int1 |
| 66 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 67 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 68 | + if #_hasSymbol(S.init(member:)) {} |
| 69 | +} |
| 70 | + |
| 71 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV6memberSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 72 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV6method4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 73 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV11genericFuncyyxAA1PRzlFTwS : $@convention(thin) () -> Builtin.Int1 |
| 74 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV10staticFuncyyFZTwS : $@convention(thin) () -> Builtin.Int1 |
| 75 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV12staticMemberSivpZTwS : $@convention(thin) () -> Builtin.Int1 |
| 76 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SV6memberACSi_tcfcTwS : $@convention(thin) () -> Builtin.Int1 |
| 77 | + |
| 78 | +// CHECK: sil hidden [ossa] @$s4test0A13GenericStructyy17has_symbol_helper0B1SVyAC1SVGF : $@convention(thin) (@in_guaranteed GenericS<S>) -> () |
| 79 | +func testGenericStruct(_ s: GenericS<S>) { |
| 80 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper8GenericSV6memberxvpTwS : $@convention(thin) () -> Builtin.Int1 |
| 81 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 82 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 83 | + if #_hasSymbol(s.member) {} |
| 84 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper8GenericSV6method4withyx_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 85 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 86 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 87 | + if #_hasSymbol(s.method(with:)) {} |
| 88 | +} |
| 89 | + |
| 90 | +// CHECK: sil hidden_external @$s17has_symbol_helper8GenericSV6memberxvpTwS : $@convention(thin) () -> Builtin.Int1 |
| 91 | +// CHECK: sil hidden_external @$s17has_symbol_helper8GenericSV6method4withyx_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 92 | + |
| 93 | +// CHECK: sil hidden [ossa] @$s4test0A5Classyy17has_symbol_helper1CCF : $@convention(thin) (@guaranteed C) -> () { |
| 94 | +func testClass(_ c: C) { |
| 95 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CC6memberSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 96 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 97 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 98 | + if #_hasSymbol(c.member) {} |
| 99 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CC6method4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 100 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 101 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 102 | + if #_hasSymbol(c.method(with:)) {} |
| 103 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CC9classFuncyyFZTwS : $@convention(thin) () -> Builtin.Int1 |
| 104 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 105 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 106 | + if #_hasSymbol(C.classFunc) {} |
| 107 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CC12staticMemberSivpZTwS : $@convention(thin) () -> Builtin.Int1 |
| 108 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 109 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 110 | + if #_hasSymbol(C.staticMember) {} |
| 111 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CC6memberACSi_tcfcTwS : $@convention(thin) () -> Builtin.Int1 |
| 112 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 113 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 114 | + if #_hasSymbol(C.init(member:)) {} |
| 115 | +} |
| 116 | + |
| 117 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CC6memberSivpTwS : $@convention(thin) () -> Builtin.Int1 |
| 118 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CC6method4withySi_tFTwS : $@convention(thin) () -> Builtin.Int1 |
| 119 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CC9classFuncyyFZTwS : $@convention(thin) () -> Builtin.Int1 |
| 120 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CC12staticMemberSivpZTwS : $@convention(thin) () -> Builtin.Int1 |
| 121 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CC6memberACSi_tcfcTwS : $@convention(thin) () -> Builtin.Int1 |
| 122 | + |
| 123 | +// CHECK: sil hidden [ossa] @$s4test0A4Enumyy17has_symbol_helper1EOF : $@convention(thin) (@in_guaranteed E) -> () |
| 124 | +func testEnum(_ e: E) { |
| 125 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1EO9basicCaseyA2CmFTwS : $@convention(thin) () -> Builtin.Int1 |
| 126 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 127 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 128 | + if #_hasSymbol(E.basicCase) {} |
| 129 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1EO11payloadCaseyAcA1SVcACmFTwS : $@convention(thin) () -> Builtin.Int1 |
| 130 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 131 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 132 | + if #_hasSymbol(E.payloadCase(_:)) {} |
| 133 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1EO6methodyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 134 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 135 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 136 | + if #_hasSymbol(e.method) {} |
| 137 | +} |
| 138 | + |
| 139 | +// CHECK: sil hidden_external @$s17has_symbol_helper1EO9basicCaseyA2CmFTwS : $@convention(thin) () -> Builtin.Int1 |
| 140 | +// CHECK: sil hidden_external @$s17has_symbol_helper1EO11payloadCaseyAcA1SVcACmFTwS : $@convention(thin) () -> Builtin.Int1 |
| 141 | +// CHECK: sil hidden_external @$s17has_symbol_helper1EO6methodyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 142 | + |
| 143 | +// CHECK: sil hidden [ossa] @$s4test0A8Protocolyyx17has_symbol_helper1PRzlF : $@convention(thin) <T where T : P> (@in_guaranteed T) -> () |
| 144 | +func testProtocol<T: P>(_ p: T) { |
| 145 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1PP11requirementyyFTwS : $@convention(thin) () -> Builtin.Int1 |
| 146 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 147 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 148 | + if #_hasSymbol(p.requirement) {} |
| 149 | +} |
| 150 | + |
| 151 | +// CHECK: sil hidden [ossa] @$s4test0A9MetatypesyyF : $@convention(thin) () -> () |
| 152 | +func testMetatypes() { |
| 153 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1PPTwS : $@convention(thin) () -> Builtin.Int1 |
| 154 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 155 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 156 | + if #_hasSymbol(P.self) {} |
| 157 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1SVTwS : $@convention(thin) () -> Builtin.Int1 |
| 158 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 159 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 160 | + if #_hasSymbol(S.self) {} |
| 161 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper8GenericSVTwS : $@convention(thin) () -> Builtin.Int1 |
| 162 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 163 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 164 | + if #_hasSymbol(GenericS<S>.self) {} |
| 165 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1CCTwS : $@convention(thin) () -> Builtin.Int1 |
| 166 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 167 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 168 | + if #_hasSymbol(C.self) {} |
| 169 | + // CHECK: [[QUERY:%[0-9]+]] = function_ref @$s17has_symbol_helper1EOTwS : $@convention(thin) () -> Builtin.Int1 |
| 170 | + // CHECK: [[RES:%[0-9]+]] = apply [[QUERY]]() : $@convention(thin) () -> Builtin.Int1 |
| 171 | + // CHECK: cond_br [[RES]], bb{{[0-9]+}}, bb{{[0-9]+}} |
| 172 | + if #_hasSymbol(E.self) {} |
| 173 | +} |
| 174 | + |
| 175 | +// CHECK: sil hidden_external @$s17has_symbol_helper1PPTwS : $@convention(thin) () -> Builtin.Int1 |
| 176 | +// CHECK: sil hidden_external @$s17has_symbol_helper1SVTwS : $@convention(thin) () -> Builtin.Int1 |
| 177 | +// CHECK: sil hidden_external @$s17has_symbol_helper8GenericSVTwS : $@convention(thin) () -> Builtin.Int1 |
| 178 | +// CHECK: sil hidden_external @$s17has_symbol_helper1CCTwS : $@convention(thin) () -> Builtin.Int1 |
| 179 | +// CHECK: sil hidden_external @$s17has_symbol_helper1EOTwS : $@convention(thin) () -> Builtin.Int1 |
0 commit comments