mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
20 lines
713 B
Plaintext
20 lines
713 B
Plaintext
// First parse this and then emit a *.sib. Then read in the *.sib, then recreate
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name noImplicitCopy
|
|
// RUN: %target-sil-opt %t/tmp.sib -module-name noImplicitCopy | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
class Klass {}
|
|
|
|
// CHECK-LABEL: sil [serialized] [ossa] @noImplicitCopyTest : $@convention(thin) (@owned Klass) -> () {
|
|
// CHECK: bb0(%0 : @noImplicitCopy @owned $Klass):
|
|
// CHECK: } // end sil function 'noImplicitCopyTest'
|
|
sil [serialized] [ossa] @noImplicitCopyTest : $@convention(thin) (@owned Klass) -> () {
|
|
bb0(%0 : @noImplicitCopy @owned $Klass):
|
|
destroy_value %0 : $Klass
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|