File: overloaded_member.sil

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 (62 lines) | stat: -rw-r--r-- 2,326 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
55
56
57
58
59
60
61
62
// RUN: %target-swift-frontend %s -emit-silgen -disable-objc-attr-requires-foundation-module -enable-objc-interop | %FileCheck %s

// rdar://15763213
// Make sure that we can parse SILDeclRef to an overloaded member.

import Swift
import Builtin

struct A {
  init()
}

@objc class X {
  init(a: A)
  init(a1: A, a2: A)
}

// CHECK-LABEL: sil [ossa] @_TFCSo1XcfMS_FT1aV11peer_method1A_S_
sil [ossa] @_TFCSo1XcfMS_FT1aV11peer_method1A_S_ : $@convention(method) (A, @owned X) -> @owned X {
bb0(%0 : $A, %1 : @owned $X):
  %2 = alloc_box $<τ_0_0> { var τ_0_0 } <X>
  %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } <X>, 0
  %3 = alloc_box $<τ_0_0> { var τ_0_0 } <A>
  %3a = project_box %3 : $<τ_0_0> { var τ_0_0 } <A>, 0
  store %0 to [trivial] %3a : $*A
  %5 = mark_uninitialized [delegatingself] %1 : $X
  store %5 to [init] %2a : $*X
  %7 = load [copy] %2a : $*X
  // CHECK: objc_method %{{[0-9]+}} : $X, #X.init!initializer.foreign : (X.Type) -> (A, A) -> X, $@convention(objc_method) (A, A, @owned X) -> @owned X
  %9 = objc_method %7 : $X, #X.init!initializer.foreign : (X.Type) -> (A, A) -> X, $@convention(objc_method) (A, A, @owned X) -> @owned X
  %10 = load [trivial] %3a : $*A
  %11 = load [trivial] %3a : $*A
  %12 = apply %9(%10, %11, %7) : $@convention(objc_method) (A, A, @owned X) -> @owned X
  assign %12 to %2a : $*X
  destroy_value %3 : $<τ_0_0> { var τ_0_0 } <A>
  %15 = load [copy] %2a : $*X
  destroy_value %2 : $<τ_0_0> { var τ_0_0 } <X>
  return %15 : $X
}

// rdar://46650834
//   Don't complain that the first lookup result lacks an accessor when a
//   later lookup result provides it.
class B {
  typealias Index = Int
  typealias Element = String

  subscript(owned index: Index) -> Element { get }

  @_borrowed
  subscript(borrowed index: Index) -> Element { get }
}

sil [ossa] @test_overloaded_subscript : $@convention(thin) (@guaranteed B, B.Index) -> () {
bb0(%0 : @guaranteed $B, %1 : $B.Index):
  %reader = class_method %0 : $B, #B.subscript!read : (B) -> (B.Index) -> (), $@convention(method) @yield_once (B.Index, @guaranteed B) -> @yields @guaranteed B.Element
  (%element, %token) = begin_apply %reader(%1, %0) : $@convention(method) @yield_once (B.Index, @guaranteed B) -> @yields @guaranteed B.Element
  end_apply %token as $()

  %result = tuple ()
  return %result : $()
}