Files
swift-mirror/test/IRGen/noncopyable_private.swift
Arnold Schwaighofer ad6f6dec6e IRGen: We cannot call destroy through metadata of private types of non-copyable fields
So call the destroy on the closing type instead.

Amends the concepts areFieldsABIAccessible/isABIAccessible to take metadata
accessibility of non-copyable types into account.

rdar://133990500
2024-08-21 11:22:30 -07:00

43 lines
1.4 KiB
Swift

// RUN: %swift-frontend -primary-file %s %S/Inputs/noncopyable_private_other.swift -emit-ir -o - | %FileCheck %s
public struct SomeStruct : ~Copyable {
// PublicType is a struct without a deinit but a non-copyable field with a
// deinit of private type. So we can't access the private type's metadata.
// Instead we have to call destroy on PublicType's metadata.
public let x = PublicType()
}
// Call the destroy on the `PublicType` metadata instead of its private typed
// subfield.
// CHECK: define{{.*}} internal void @"$s19noncopyable_private10SomeStructVwxx"(
// CHECK: entry
// CHECK-NOT: define
// CHECK: call void %Destroy(ptr {{.*}}, ptr @"$s19noncopyable_private10PublicTypeVN"
// CHECK: ret void
// CHECK: }
// Similar issue with enums.
public struct SomeStructWithSPE : ~Copyable {
public let x = PublicSinglePayloadEnum.empty
}
// CHECK: define{{.*}} internal void @"$s19noncopyable_private17SomeStructWithSPEVwxx"(
// CHECK: entry:
// CHECK-NOT: define
// CHECK: call void %Destroy(ptr {{.*}}, ptr @"$s19noncopyable_private23PublicSinglePayloadEnumON"
// CHECK: ret void
// CHECK: }
public struct SomeStructWithMPE : ~Copyable {
public let x = PublicMultiPayloadEnum.empty
}
// CHECK: define{{.*}} internal void @"$s19noncopyable_private17SomeStructWithMPEVwxx"(
// CHECK: entry:
// CHECK-NOT: define
// CHECK: call void %Destroy(ptr {{.*}}, ptr @"$s19noncopyable_private22PublicMultiPayloadEnumON"
// CHECK: ret void
// CHECK: }