File: moveonly_class_inits_end_to_end.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 (34 lines) | stat: -rw-r--r-- 1,367 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
// RUN: %target-swift-frontend -module-name moveonly_class_inits_end_to_end %s -emit-sil -o - | %FileCheck %s
// RUN: %target-swift-frontend %s -O -emit-sil -sil-verify-all > /dev/null

// A test that makes sure end to end in a copyable class containing a
// non-copyable type, in the init, we only have a single destroy_addr.

// REQUIRES: swift_in_compiler

public struct MO: ~Copyable {
  var x: Int8 = 0
  deinit { print("destroyed MO") }
}

public class MOHaver {
  var mo: MO

  // CHECK-LABEL: sil hidden @$s028moveonly_class_inits_end_to_D07MOHaverCACycfc : $@convention(method) (@owned MOHaver) -> @owned MOHaver {
  // CHECK: bb0([[ARG:%.*]] :
  // CHECK-NEXT: debug_value [[ARG]]
  // CHECK-NEXT: [[EI:%.*]] = end_init_let_ref [[ARG]]
  // CHECK-NEXT: [[META:%.*]] = metatype
  // CHECK-NEXT: function_ref MO.init()
  // CHECK-NEXT: [[FUNC:%.*]] = function_ref @$s028moveonly_class_inits_end_to_D02MOVACycfC :
  // CHECK-NEXT: [[RESULT:%.*]] = apply [[FUNC]]([[META]])
  // CHECK-NEXT: [[REF:%.*]] = ref_element_addr [[EI]]
  // CHECK-NEXT: [[REF_ACCESS:%.*]] = begin_access [modify] [dynamic] [[REF]]
  // CHECK-NEXT: store [[RESULT]] to [[REF_ACCESS]]
  // CHECK-NEXT: end_access [[REF_ACCESS]]
  // CHECK-NEXT: return [[EI]]
  // CHECK-NEXT: } // end sil function '$s028moveonly_class_inits_end_to_D07MOHaverCACycfc'
  init() {
    self.mo = MO()
  }
}