File: has_symbol_async.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (42 lines) | stat: -rw-r--r-- 2,115 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/has_symbol_helper.swiftmodule -parse-as-library %S/Inputs/has_symbol/has_symbol_helper.swift -enable-library-evolution -disable-availability-checking -DCONCURRENCY
// RUN: %target-swift-frontend -emit-irgen %s -I %t -module-name test | %FileCheck %s

// REQUIRES: concurrency
// UNSUPPORTED: OS=windows-msvc

@_weakLinked import has_symbol_helper

public func testGlobalFunctions() {
  // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper9asyncFuncyyYaFTwS"()
  if #_hasSymbol(asyncFunc) {}

  // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper12isolatedFuncyyFTwS"()
  if #_hasSymbol(isolatedFunc) {}
}

// --- asyncFunc() ---
// CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9asyncFuncyyYaFTwS"()
// CHECK:   ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null))

// --- isolatedFunc() ---
// CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper12isolatedFuncyyFTwS"()
// CHECK:   ret i1 icmp ne (ptr @"$s17has_symbol_helper12isolatedFuncyyF", ptr null)

public func testActor(_ a: A) {
  // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1ACACycfcTwS"()
  if #_hasSymbol(A.init) {}

  // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1AC11asyncMethodyyYaFTwS"()
  if #_hasSymbol(a.asyncMethod) {}

  // FIXME: Add support for actor isolated methods
}

// --- A.init() ---
// CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1ACACycfcTwS"()
// CHECK:   ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null))

// --- A.asyncMethod() ---
// CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1AC11asyncMethodyyYaFTwS"()
// CHECK:   ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null))