File: expose-swift-decls-to-wasm.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 (54 lines) | stat: -rw-r--r-- 2,294 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
43
44
45
46
47
48
49
50
51
52
53
54
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -emit-ir -module-name Expose | %FileCheck %s

import Swift

// CHECK: define{{.*}} swiftcc void @"$s6Expose8exposed1yyF"() [[EA1:#[0-9]+]]
@_expose(wasm)
public func exposed1() {
}

// CHECK: define{{.*}} swiftcc void @"$s6Expose18exposed2NotExposedyyF"() [[DEFAULT_A:#[0-9]+]]
public func exposed2NotExposed() {
}

// CHECK: define{{.*}} swiftcc void @"$s6Expose22exposed3WithCustomNameyyF"() [[EA3:#[0-9]+]]
@_expose(wasm, "exposed3_with_custom_name")
public func exposed3WithCustomName() {
}


// CHECK: define{{.*}} swiftcc void @"$s6Expose17exposed4NonCIdentyyF"() [[EA4:#[0-9]+]]
@_expose(wasm, "exposed4-non-c-ident")
public func exposed4NonCIdent() {
}

// CHECK: define{{.*}} swiftcc i32 @"$s6Expose17exposed5ReturnInts5Int32VyF"() [[EA5:#[0-9]+]]
@_expose(wasm)
public func exposed5ReturnInt() -> Int32 {
  return 0
}

// If @_cdecl is applied at the same time as @_expose, expose C thunk instead of Swift function.
// CHECK: define{{.*}} void @exposed6WithCDecl() [[EA6:#[0-9]+]]
// CHECK: define{{.*}} swiftcc void @"$s6Expose17exposed6WithCDeclyyF"() [[DEFAULT:#[0-9]+]]
@_expose(wasm)
@_cdecl("exposed6WithCDecl")
public func exposed6WithCDecl() {
}

// CHECK: define{{.*}} void @exposed7WithCDecl() [[EA7:#[0-9]+]]
// CHECK: define{{.*}} swiftcc void @"$s6Expose018exposed7WithCDecl_C13DifferentNameyyF"() [[DEFAULT_A:#[0-9]+]]
@_expose(wasm, "exposed7WithCDecl:WithDifferentName")
@_cdecl("exposed7WithCDecl")
public func exposed7WithCDecl_WithDifferentName() {
}

// CHECK-NOT: attributes [[DEFAULT_A]] = {{.*}} "wasm-export-name"="{{.*}}"
// CHECK: attributes [[EA1]] = {{{.*}} "wasm-export-name"="$s6Expose8exposed1yyF" {{.*}}}
// CHECK-NOT: attributes {{.*}} = {{{.*}} "wasm-export-name"="$s6Expose18exposed2NotExposedyyF" {{.*}}}
// CHECK: attributes [[EA3]] = {{{.*}} "wasm-export-name"="exposed3_with_custom_name" {{.*}}}
// CHECK: attributes [[EA4]] = {{{.*}} "wasm-export-name"="exposed4-non-c-ident" {{.*}}}
// CHECK: attributes [[EA5]] = {{{.*}} "wasm-export-name"="$s6Expose17exposed5ReturnInts5Int32VyF" {{.*}}}
// CHECK: attributes [[EA6]] = {{{.*}} "wasm-export-name"="exposed6WithCDecl" {{.*}}}
// CHECK: attributes [[EA7]] = {{{.*}} "wasm-export-name"="exposed7WithCDecl:WithDifferentName" {{.*}}}