Files
swift-mirror/test/Interop/Cxx/class/inheritance/fields-silgen.swift
Alex Lorenz 415045024c [cxx-interop] Use a synthesized C++ method when accessing a base field or subscript from a derived class synthesized method
The use of a synthesized C++ method allows us to avoid making a copy of self when accessing the base field or subscript from Swift
2023-10-16 14:34:37 -07:00

16 lines
664 B
Swift

// RUN: %target-swift-emit-sil -I %S/Inputs -enable-experimental-cxx-interop %s -validate-tbd-against-ir=none | %FileCheck %s
import Fields
func testGetX() -> CInt {
let derived = CopyTrackedDerivedClass(42)
return derived.x
}
let _ = testGetX()
// CHECK: sil shared [transparent] @$sSo23CopyTrackedDerivedClassV1xs5Int32Vvg : $@convention(method) (@in_guaranteed CopyTrackedDerivedClass) -> Int32
// CHECK: {{.*}}(%[[SELF_VAL:.*]] : $*CopyTrackedDerivedClass):
// CHECK: function_ref @{{.*}}__synthesizedBaseGetterAccessor_{{.*}} : $@convention(cxx_method) (@in_guaranteed CopyTrackedDerivedClass) -> Int32
// CHECK-NEXT: apply %{{.*}}(%[[SELF_VAL]])