mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
48 lines
1.8 KiB
Swift
48 lines
1.8 KiB
Swift
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types %s | %FileCheck %s
|
|
|
|
protocol Fooable {
|
|
func foo()
|
|
static func class_foo()
|
|
}
|
|
|
|
protocol Barrable : Fooable {
|
|
func bar()
|
|
static func class_bar()
|
|
}
|
|
|
|
class X : Fooable {
|
|
func foo() {}
|
|
class func class_foo() {}
|
|
}
|
|
|
|
// -- Derived class conforms to a refined protocol
|
|
class Y : X, Barrable {
|
|
func bar() {}
|
|
// CHECK-NOT: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1YCAA7FooableA2aDP3foo{{[_0-9a-zA-Z]*}}FTW
|
|
class func class_bar() {}
|
|
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1YCAA8BarrableA2aDP9class_bar{{[_0-9a-zA-Z]*}}FZTW
|
|
}
|
|
|
|
class A : Fooable {
|
|
func foo() {}
|
|
func bar() {}
|
|
class func class_foo() {}
|
|
class func class_bar() {}
|
|
}
|
|
|
|
// -- Derived class conforms to a refined protocol using its base's methods
|
|
class B : A, Barrable {}
|
|
// CHECK-NOT: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1BCAA7FooableA2aDP3foo{{[_0-9a-zA-Z]*}}FTW
|
|
// CHECK-NOT: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1BCAA7FooableA2aDP9class_foo{{[_0-9a-zA-Z]*}}FZTW
|
|
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1BCAA8BarrableA2aDP3bar{{[_0-9a-zA-Z]*}}FTW
|
|
// CHECK: [[B:%.*]] = load_borrow {{%.*}} : $*B
|
|
// CHECK-NEXT: [[A:%.*]] = upcast [[B]] : $B to $A
|
|
// CHECK-NEXT: [[METH:%.*]] = class_method [[A]] : $A, #A.bar :
|
|
// CHECK-NEXT: apply [[METH]]([[A]]) : $@convention(method) (@guaranteed A) -> ()
|
|
// CHECK: end_borrow [[B]]
|
|
|
|
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21witnesses_inheritance1BCAA8BarrableA2aDP9class_bar{{[_0-9a-zA-Z]*}}FZTW
|
|
// CHECK: upcast {{%.*}} : $@thick B.Type to $@thick A.Type
|
|
|
|
// Add tests to make sure that we handle address only case correctly.
|