|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | + |
| 5 | +// RUN: %target-build-swift %t/struct.swift -emit-module -emit-library -static -module-name OpaqueStruct -emit-module-path %t/Inputs/OpaqueStruct.swiftmodule -enable-library-evolution |
| 6 | + |
| 7 | +// RUN: %target-swift-emit-irgen %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s |
| 8 | + |
| 9 | +//--- Inputs/module.modulemap |
| 10 | +module CxxModule { |
| 11 | + header "header.h" |
| 12 | + requires cplusplus |
| 13 | +} |
| 14 | + |
| 15 | +//--- Inputs/header.h |
| 16 | + |
| 17 | +class |
| 18 | +__attribute__((swift_attr("import_reference"))) |
| 19 | +__attribute__((swift_attr("retain:immortal"))) |
| 20 | +__attribute__((swift_attr("release:immortal"))) |
| 21 | +SingletonReference { |
| 22 | +public: |
| 23 | + SingletonReference(const SingletonReference &) = delete; |
| 24 | + |
| 25 | + void method(); |
| 26 | +}; |
| 27 | + |
| 28 | +class |
| 29 | +__attribute__((swift_attr("import_reference"))) |
| 30 | +__attribute__((swift_attr("retain:retainS"))) |
| 31 | +__attribute__((swift_attr("release:releaseS"))) |
| 32 | +SingletonReferenceRef { |
| 33 | +public: |
| 34 | + SingletonReferenceRef(const SingletonReferenceRef &) = delete; |
| 35 | + |
| 36 | + void method(); |
| 37 | +}; |
| 38 | + |
| 39 | +void retainS(SingletonReferenceRef *); |
| 40 | +void releaseS(SingletonReferenceRef *); |
| 41 | + |
| 42 | +//--- struct.swift |
| 43 | + |
| 44 | +public struct ResilientStruct { |
| 45 | + let x: Int |
| 46 | +} |
| 47 | + |
| 48 | +//--- test.swift |
| 49 | + |
| 50 | +import OpaqueStruct |
| 51 | +import CxxModule |
| 52 | + |
| 53 | +public struct ImmortalFRT_OpaqueLayout { |
| 54 | + public let y: SingletonReference |
| 55 | + public let x: ResilientStruct |
| 56 | +} |
| 57 | + |
| 58 | +public struct SharedFRT_OpaqueLayout { |
| 59 | + public let x: ResilientStruct |
| 60 | + public let y: SingletonReferenceRef |
| 61 | +} |
| 62 | + |
| 63 | +// CHECK: define{{.*}} @"$s4test24ImmortalFRT_OpaqueLayoutVMr" |
| 64 | +// CHECK: store ptr getelementptr inbounds (ptr, ptr @"$sBpWV", i32 |
| 65 | + |
| 66 | +// CHECK: define{{.*}} @"$s4test22SharedFRT_OpaqueLayoutVMr" |
| 67 | +// CHECK: store ptr getelementptr inbounds (ptr, ptr @"$sBpWV", i32 |
0 commit comments