Skip to content

Commit 932c6eb

Browse files
committed
[Tests] RuntimeMetadata: Add test-cases for attributes on methods of inner types
1 parent 4a91832 commit 932c6eb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/IRGen/runtime_attributes.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
// CHECK: @"$s18runtime_attributes23MembersWithAvailabilityC6instFnyycvpfaAA0E5TestsHF"
4747
// CHECK: @"$s18runtime_attributes23MembersWithAvailabilityC4propSivpfaAA0E5TestsHF"
4848
// CHECK: @"$s18runtime_attributes20attrIsHigherThanFuncyycvpfaAA13FlagWithAvailHF"
49+
// CHECK: @"$s18runtime_attributes9OuterTypeV5InnerV15innerInstFnTestyycvpfaAA07FlagForE7MethodsHF"
50+
// CHECK: @"$s18runtime_attributes9OuterTypeV5InnerV17innerStaticFnTestyycvpZfaAA07FlagForE7MethodsHF"
4951

5052
// CHECK: @"$s18runtime_attributes4FlagVHa" = internal constant { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } { i32 0, i32 trunc (i64 sub (i64 ptrtoint (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s18runtime_attributes4FlagVMn" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes4FlagVHa", i32 0, i32 1) to i64)) to i32), i32 16, {{.*}} @"$s18runtime_attributes4FlagVHa", i32 0, i32 34) to i64)) to i32) }, section "__TEXT, __swift5_rattrs, regular", align 4
5153

@@ -59,6 +61,8 @@
5961

6062
// CHECK: @"$s18runtime_attributes13FlagWithAvailVHa" = internal constant { i32, i32, i32, i32, i32 } { i32 0, i32 trunc (i64 sub (i64 ptrtoint (<{ i32, i32, i32, i32, i32, i32, i32 }>* @"$s18runtime_attributes13FlagWithAvailVMn" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32 }* @"$s18runtime_attributes13FlagWithAvailVHa", i32 0, i32 1) to i64)) to i32), i32 1, i32 trunc (i64 sub (i64 ptrtoint (<{ [3 x i8], i8 }>* @"symbolic yyc" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32 }* @"$s18runtime_attributes13FlagWithAvailVHa", i32 0, i32 3) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (%swift.accessible_function* @"$s18runtime_attributes20attrIsHigherThanFuncyycvpfaAA13FlagWithAvailHF" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32 }* @"$s18runtime_attributes13FlagWithAvailVHa", i32 0, i32 4) to i64)) to i32) }, section "__TEXT, __swift5_rattrs, regular", align 4
6163

64+
// CHECK: @"$s18runtime_attributes19FlagForInnerMethodsVHa" = internal constant { i32, i32, i32, i32, i32, i32, i32 } { i32 0, i32 trunc (i64 sub (i64 ptrtoint (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s18runtime_attributes19FlagForInnerMethodsVMn" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes19FlagForInnerMethodsVHa", i32 0, i32 1) to i64)) to i32), i32 2, i32 trunc (i64 sub (i64 ptrtoint (<{ [3 x i8], i8, i32, [1 x i8], i8 }>* @"symbolic yyc_____c 18runtime_attributes9OuterTypeV5InnerV" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes19FlagForInnerMethodsVHa", i32 0, i32 3) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (%swift.accessible_function* @"$s18runtime_attributes9OuterTypeV5InnerV15innerInstFnTestyycvpfaAA07FlagForE7MethodsHF" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes19FlagForInnerMethodsVHa", i32 0, i32 4) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (<{ [3 x i8], i8, i32, [2 x i8], i8 }>* @"symbolic yyc_____mc 18runtime_attributes9OuterTypeV5InnerV" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes19FlagForInnerMethodsVHa", i32 0, i32 5) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (%swift.accessible_function* @"$s18runtime_attributes9OuterTypeV5InnerV17innerStaticFnTestyycvpZfaAA07FlagForE7MethodsHF" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i32, i32, i32, i32, i32, i32, i32 }, { i32, i32, i32, i32, i32, i32, i32 }* @"$s18runtime_attributes19FlagForInnerMethodsVHa", i32 0, i32 6) to i64)) to i32) }, section "__TEXT, __swift5_rattrs, regular", align 4
65+
6266
import RAD
6367

6468
@runtimeMetadata
@@ -214,3 +218,18 @@ func test_local_type_with_protocol_conformance() {
214218
// CHECK-NOT: define hidden swiftcc void @"$s18runtime_attributes41test_local_type_with_protocol_conformanceyyF9LocalTest{{.*}}"
215219
struct LocalTest : Ignored {} // Ok but attribute is not inferred.
216220
}
221+
222+
@runtimeMetadata
223+
struct FlagForInnerMethods<Result> {
224+
init<T>(attachedTo: (T) -> () -> Result) {}
225+
init(attachedTo: () -> Result) {}
226+
}
227+
228+
struct OuterType {
229+
struct Inner {
230+
// CHECK-LABEL: define hidden swiftcc void @"$s18runtime_attributes9OuterTypeV5InnerV15innerInstFnTestyycvpfaAA07FlagForE7Methods"(%T18runtime_attributes19FlagForInnerMethodsVyytGSg* noalias nocapture sret(%T18runtime_attributes19FlagForInnerMethodsVyytGSg) %0)
231+
@FlagForInnerMethods func innerInstFnTest() {}
232+
// CHECK-LABEL: define hidden swiftcc void @"$s18runtime_attributes9OuterTypeV5InnerV17innerStaticFnTestyycvpZfaAA07FlagForE7Methods"(%T18runtime_attributes19FlagForInnerMethodsVyytGSg* noalias nocapture sret(%T18runtime_attributes19FlagForInnerMethodsVyytGSg) %0)
233+
@FlagForInnerMethods static func innerStaticFnTest() {}
234+
}
235+
}

test/type/runtime_discoverable_attrs.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct A { // Ok
7272

7373
class Inner {
7474
@OnlyPropsTest @Flag("test property") var test: [Int]? = nil // Ok
75+
76+
@Flag func testInner() {}
77+
@Flag static func testStaticInner() {}
7578
}
7679
}
7780

0 commit comments

Comments
 (0)