Files
swift-mirror/test/SILGen/dynamic_accessors.swift
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

44 lines
2.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o /dev/null -disable-objc-attr-requires-foundation-module -enable-objc-interop -emit-module-interface-path %t/dynamic_accessors.swiftinterface %s
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -disable-objc-attr-requires-foundation-module -enable-objc-interop %s | %FileCheck %s
// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-silgen -disable-objc-attr-requires-foundation-module -enable-objc-interop %t/dynamic_accessors.swiftinterface | %FileCheck %s
public class MyObjCClass {
@objc public dynamic var a: Int {
// CHECK-LABEL: sil private [thunk] [ossa] @$s17dynamic_accessors11MyObjCClassC1aSivgTo : $@convention(objc_method) (MyObjCClass) -> Int {
// CHECK: function_ref @$s17dynamic_accessors11MyObjCClassC1aSivg
// CHECK: }
get { return 4 }
// CHECK-LABEL: sil private [thunk] [ossa] @$s17dynamic_accessors11MyObjCClassC1aSivsTo : $@convention(objc_method) (Int, MyObjCClass) -> () {
// CHECK: function_ref @$s17dynamic_accessors11MyObjCClassC1aSivs
// CHECK: }
set {}
}
@objc public dynamic subscript(x: Int) -> Int {
// CHECK-LABEL: sil private [thunk] [ossa] @$s17dynamic_accessors11MyObjCClassCyS2icigTo : $@convention(objc_method) (Int, MyObjCClass) -> Int {
// CHECK: function_ref @$s17dynamic_accessors11MyObjCClassCyS2icig
// CHECK: }
get { return x }
// CHECK-LABEL: sil private [thunk] [ossa] @$s17dynamic_accessors11MyObjCClassCyS2icisTo : $@convention(objc_method) (Int, Int, MyObjCClass) -> () {
// CHECK: function_ref @$s17dynamic_accessors11MyObjCClassCyS2icis
// CHECK: }
set {}
}
public init() {}
}
@inlinable public func foo() {
let x = MyObjCClass()
// CHECK: objc_method %{{[0-9]+}} : $MyObjCClass, #MyObjCClass.a!getter.foreign
// CHECK: objc_method %{{[0-9]+}} : $MyObjCClass, #MyObjCClass.a!setter.foreign
x.a = x.a + 1
// CHECK: objc_method %{{[0-9]+}} : $MyObjCClass, #MyObjCClass.subscript!getter.foreign
// CHECK: objc_method %{{[0-9]+}} : $MyObjCClass, #MyObjCClass.subscript!setter.foreign
x[4] = x[5]
}