Files
swift-mirror/test/Interop/Cxx/operators/subscripts-irgen.swift
John Hui f1f17b8c75 [cxx-interop] Synthesize subscript on-demand
The implementation for this behavior was added in a previous patch;
this patch integrates and removes unused call sites.

This patch also adds some tests exercising the overloading behavior.

Annoyingly, imported members that point to the same source location
aren't sorted correctly in the module interface, so this changes the
order in a bunch of module interface tests.

rdar://170857428

Also, un-comment broken test case of using Base::operator[], which is
fixed by this commit.

rdar://145345345
2026-05-11 23:23:39 -07:00

15 lines
639 B
Swift

// RUN: %target-swift-emit-irgen -I %S/Inputs -enable-experimental-cxx-interop %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
import Subscripts
func testGetX() -> CInt {
let derivedDerived = CopyTrackedDerivedDerivedClass(42)
return derivedDerived[0]
}
let _ = testGetX()
// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @{{.*}}synthesizedBaseCall_operatorSubscript{{.*}}(ptr {{.*}} %[[THIS_PTR:.*]], i32 {{.*}})
// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i{{32|64}} 4
// CHECK: {{.*}}call {{.*}} i32 @{{.*}}CopyTrackedBaseClass{{.*}}(ptr {{.*}} %[[ADD_PTR]], i32 {{.*}}){{.*}}