File: overloaded_member.sil

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 (62 lines) | stat: -rw-r--r-- 2,319 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

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