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.
84 lines
3.8 KiB
Swift
84 lines
3.8 KiB
Swift
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name optional -I %S/Inputs/custom-modules -Xllvm -sil-print-types -emit-silgen -o - %s | %FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import ObjectiveC
|
|
import Foundation
|
|
import objc_ext
|
|
import TestProtocols
|
|
|
|
class A {
|
|
@objc func foo() -> String? {
|
|
return ""
|
|
}
|
|
// CHECK-LABEL: sil private [thunk] [ossa] @$s8optional1AC3fooSSSgyFTo : $@convention(objc_method) (A) -> @autoreleased Optional<NSString>
|
|
// CHECK: bb0([[SELF:%.*]] : @unowned $A):
|
|
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
|
|
// CHECK: [[BORROWED_SELF_COPY:%.*]] = begin_borrow [[SELF_COPY]]
|
|
// CHECK: [[T0:%.*]] = function_ref @$s8optional1AC3fooSSSgyF
|
|
// CHECK-NEXT: [[T1:%.*]] = apply [[T0]]([[BORROWED_SELF_COPY]])
|
|
// CHECK-NEXT: end_borrow [[BORROWED_SELF_COPY]]
|
|
// CHECK-NEXT: destroy_value [[SELF_COPY]]
|
|
// CHECK-NEXT: switch_enum [[T1]] : $Optional<String>, case #Optional.some!enumelt: [[SOME_BB:bb[0-9]+]], case #Optional.none!enumelt: [[NONE_BB:bb[0-9]+]]
|
|
//
|
|
// Something branch: project value, translate, inject into result.
|
|
// CHECK: [[SOME_BB]]([[STR:%.*]] : @owned $String):
|
|
// CHECK: [[T0:%.*]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF
|
|
// CHECK-NEXT: [[BORROWED_STR:%.*]] = begin_borrow [[STR]]
|
|
// CHECK-NEXT: [[T1:%.*]] = apply [[T0]]([[BORROWED_STR]])
|
|
// CHECK-NEXT: end_borrow [[BORROWED_STR:%.*]]
|
|
// CHECK-NEXT: enum $Optional<NSString>, #Optional.some!enumelt, [[T1]]
|
|
// CHECK-NEXT: destroy_value [[STR]]
|
|
// CHECK-NEXT: br
|
|
// Nothing branch: inject nothing into result.
|
|
//
|
|
// CHECK: [[NONE_BB]]:
|
|
// CHECK-NEXT: enum $Optional<NSString>, #Optional.none!enumelt
|
|
// CHECK-NEXT: br
|
|
// Continuation.
|
|
// CHECK: bb3([[T0:%.*]] : @owned $Optional<NSString>):
|
|
// CHECK-NEXT: return [[T0]]
|
|
|
|
@objc func bar(x x : String?) {}
|
|
// CHECK-LABEL: sil private [thunk] [ossa] @$s8optional1AC3bar1xySSSg_tFTo : $@convention(objc_method) (Optional<NSString>, A) -> ()
|
|
// CHECK: bb0([[ARG:%.*]] : @unowned $Optional<NSString>, [[SELF:%.*]] : @unowned $A):
|
|
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
|
|
// CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]]
|
|
// CHECK: switch_enum [[ARG_COPY]] : $Optional<NSString>, case #Optional.some!enumelt: [[SOME_BB:bb[0-9]+]], case #Optional.none!enumelt: [[NONE_BB:bb[0-9]+]]
|
|
//
|
|
// Something branch: project value, translate, inject into result.
|
|
// CHECK: [[SOME_BB]]([[NSSTR:%.*]] : @owned $NSString):
|
|
// CHECK: [[T0:%.*]] = function_ref @$sSS10FoundationE36_unconditionallyBridgeFromObjectiveCySSSo8NSStringCSgFZ
|
|
// Make a temporary initialized string that we're going to clobber as part of the conversion process (?).
|
|
// CHECK-NEXT: [[NSSTR_BOX:%.*]] = enum $Optional<NSString>, #Optional.some!enumelt, [[NSSTR]] : $NSString
|
|
// CHECK-NEXT: [[STRING_META:%.*]] = metatype $@thin String.Type
|
|
// CHECK-NEXT: [[T1:%.*]] = apply [[T0]]([[NSSTR_BOX]], [[STRING_META]])
|
|
// CHECK-NEXT: enum $Optional<String>, #Optional.some!enumelt, [[T1]]
|
|
// CHECK-NEXT: destroy_value [[NSSTR_BOX]]
|
|
// CHECK-NEXT: br
|
|
//
|
|
// Nothing branch: inject nothing into result.
|
|
// CHECK: [[NONE_BB]]:
|
|
// CHECK: enum $Optional<String>, #Optional.none!enumelt
|
|
// CHECK-NEXT: br
|
|
// Continuation.
|
|
// CHECK: bb3([[T0:%.*]] : @owned $Optional<String>):
|
|
// CHECK: [[BORROWED_T0:%.*]] = begin_borrow [[T0]]
|
|
// CHECK: [[BORROWED_SELF_COPY:%.*]] = begin_borrow [[SELF_COPY]]
|
|
// CHECK: [[T1:%.*]] = function_ref @$s8optional1AC3bar1xySSSg_tF
|
|
// CHECK-NEXT: [[T2:%.*]] = apply [[T1]]([[BORROWED_T0]], [[BORROWED_SELF_COPY]])
|
|
// CHECK-NEXT: end_borrow [[BORROWED_SELF_COPY]]
|
|
// CHECK-NEXT: end_borrow [[BORROWED_T0]]
|
|
// CHECK-NEXT: destroy_value [[T0]]
|
|
// CHECK-NEXT: destroy_value [[SELF_COPY]]
|
|
// CHECK-NEXT: return [[T2]] : $()
|
|
}
|
|
|
|
|
|
// rdar://15144951
|
|
class TestWeak : NSObject {
|
|
weak var b : WeakObject? = nil
|
|
}
|
|
class WeakObject : NSObject {}
|