Files
swift-mirror/test/SIL/Parser/no_implicit_copy.sil
Michael Gottesman 4cd1201bab [noImplicitCopy] Add support for marking a SILArgument as being a NoImplicitCopy argument.
I am purposely doing this in SILGen rather than at the type system level to
avoid having to have to add a bunch of boilerplate to the type system. Instead
of doing that, I am in SILGen checking for the isNoImplicitCopy bit on the
ParamDecl when we emit arguments. At that point, I set on the specific
SILArgument being emitted the bit that it is no implicit copy. In terms of
printing at the SIL level, I just printed it in front of the function argument
type like @owned, e.x.:

  func myFunc(_ x: @_noImplicitCopy T) -> T {
  ...
  }

becomes:

  bb0(%0 : @noImplicitCopy @owned $T):

Some notes:

* Just to be explicit, I am making it so that no implicit copy parameters by
  default are always passed at +1. The reason why I think this makes sense is
  that this is the natural way of working with a move only value.

* As always, one can not write no implicit copy the attribute without passing
  the flag -enable-experimental-move-only so this is NFC.

rdar://83957088
2021-11-01 09:34:38 -07:00

15 lines
496 B
Plaintext

// RUN: %target-sil-opt -enable-objc-interop -enable-experimental-move-only -enable-sil-verify-all=true %s | %target-sil-opt -enable-objc-interop -enable-experimental-move-only -enable-sil-verify-all=true | %FileCheck %s
sil_stage canonical
class Klass {}
// CHECK: bb0(%0 : @noImplicitCopy @owned $Klass):
sil [ossa] @noImplicitCopyTest : $@convention(thin) (@owned Klass) -> () {
bb0(%0 : @noImplicitCopy @owned $Klass):
destroy_value %0 : $Klass
%9999 = tuple()
return %9999 : $()
}