File: expose-swift-decls-to-wasm.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (54 lines) | stat: -rw-r--r-- 2,294 bytes parent folder | download | duplicates (2)
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" {{.*}}}