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.
35 lines
1.2 KiB
Swift
35 lines
1.2 KiB
Swift
|
|
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name force_cast_chained_optional %s | %FileCheck %s
|
|
|
|
class Foo {
|
|
var bar: Bar!
|
|
}
|
|
|
|
class Bar {
|
|
var bas: C!
|
|
}
|
|
|
|
class C {}
|
|
class D: C {}
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s27force_cast_chained_optional4testyAA1DCAA3FooCF
|
|
// CHECK: bb0([[ARG:%.*]] : @guaranteed $Foo):
|
|
// CHECK: class_method [[ARG]] : $Foo, #Foo.bar!getter : (Foo) -> () -> Bar?, $@convention(method) (@guaranteed Foo) ->
|
|
// CHECK: select_enum_addr {{%.*}}
|
|
// CHECK: cond_br {{%.*}}, [[SOME_BAR:bb[0-9]+]], [[NO_BAR:bb[0-9]+]]
|
|
//
|
|
// CHECK: [[SOME_BAR]]:
|
|
// CHECK: [[PAYLOAD_ADDR:%.*]] = unchecked_take_enum_data_addr {{%.*}} : $*Optional<Bar>
|
|
// CHECK: [[BAR:%.*]] = load [copy] [[PAYLOAD_ADDR]]
|
|
// CHECK: [[BORROWED_BAR:%.*]] = begin_borrow [[BAR]]
|
|
// CHECK: [[METHOD:%.*]] = class_method [[BORROWED_BAR]] : $Bar, #Bar.bas!getter : (Bar) -> () -> C?, $@convention(method) (@guaranteed Bar) ->
|
|
// CHECK: apply [[METHOD]]([[BORROWED_BAR]])
|
|
// CHECK: end_borrow [[BORROWED_BAR]]
|
|
// CHECK: unconditional_checked_cast {{%.*}} : $C to D
|
|
//
|
|
// CHECK: [[NO_BAR]]:
|
|
// CHECK: unreachable
|
|
func test(_ x: Foo) -> D {
|
|
return x.bar?.bas as! D
|
|
}
|