|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -enable-experimental-feature RuntimeDiscoverableAttrs -emit-module -o %t -enable-library-evolution %S/Inputs/runtime_metadata_defs.swift |
| 3 | + |
| 4 | +// This uses '-primary-file' to ensure we're conservative with lazy SIL emission. |
| 5 | +// RUN: %target-swift-emit-silgen -enable-experimental-feature RuntimeDiscoverableAttrs -primary-file %s -I %t | %FileCheck %s |
| 6 | + |
| 7 | +// REQUIRES: asserts |
| 8 | + |
| 9 | +import runtime_metadata_defs |
| 10 | + |
| 11 | +/// Test that generator has source locations for both explicit and inferred attributes. |
| 12 | + |
| 13 | +// CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes4TestAaBVmvpfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 14 | +// CHECK: [[FILE_ID:%.*]] = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 15 | +// CHECK: [[STRING_INIT:%.*]] = function_ref @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC |
| 16 | +// CHECK-NEXT: [[FILE_STR:%.*]] = apply [[STRING_INIT]]([[FILE_ID]], {{.*}}) |
| 17 | +// CHECK: [[LINE_RAW:%.*]] = integer_literal $Builtin.IntLiteral, 25 |
| 18 | +// CHECK: [[INT_INIT:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC |
| 19 | +// CHECK-NEXT: [[LINE:%.*]] = apply [[INT_INIT]]([[LINE_RAW]], {{.*}}) |
| 20 | +// CHECK: [[COLUMN_RAW:%.*]] = integer_literal $Builtin.IntLiteral, 1 |
| 21 | +// CHECK: [[INT_INIT:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC |
| 22 | +// CHECK-NEXT: [[COLUMN:%.*]] = apply [[INT_INIT]]([[COLUMN_RAW]], {{.*}}) |
| 23 | +// CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 24 | +// CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<Test.Type>({{.*}}, {{.*}}, [[FILE_STR]], [[LINE]], [[COLUMN]], {{.*}}) |
| 25 | +struct Test : Ignorable {} |
| 26 | + |
| 27 | +// CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes8globalFnyycvpfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 28 | +// CHECK: {{.*}} = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 29 | +// CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 33 |
| 30 | +// CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 2 |
| 31 | +// CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 32 | +// CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<() -> ()>({{.*}}) |
| 33 | +@Ignore func globalFn() {} |
| 34 | + |
| 35 | +struct MemberTests { |
| 36 | + // CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes11MemberTestsV1xSivpfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 37 | + // CHECK: {{.*}} = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 38 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 42 |
| 39 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 4 |
| 40 | + // CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 41 | + // CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<WritableKeyPath<MemberTests, Int>>({{.*}}) |
| 42 | + @Ignore var x: Int = 42 |
| 43 | + |
| 44 | + // CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes11MemberTestsV6instFn_1xSSSi_SaySiGtcvpfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 45 | + // CHECK: {{.*}} = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 46 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 50 |
| 47 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 4 |
| 48 | + // CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 49 | + // CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<(MemberTests, Int, [Int]) -> String>({{.*}}) |
| 50 | + @Ignore func instFn(_: Int, x: [Int]) -> String { "" } |
| 51 | + |
| 52 | + // CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes11MemberTestsV8staticFn_1ySi_SStSS_SiztcvpZfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 53 | + // CHECK: {{.*}} = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 54 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 58 |
| 55 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 4 |
| 56 | + // CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 57 | + // CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<(MemberTests.Type, String, inout Int) -> (Int, String)>({{.*}}) |
| 58 | + @Ignore static func staticFn(_ x: String, y: inout Int) -> (Int, String) { (42, "") } |
| 59 | + |
| 60 | + // CHECK-LABEL: sil hidden [runtime_accessible] [ossa] @$s18runtime_attributes11MemberTestsV10mutatingFnSiycvpfa0A14_metadata_defs6Ignore : $@convention(thin) () -> @out Optional<Ignore> |
| 61 | + // CHECK: {{.*}} = string_literal utf8 "runtime_attributes/runtime_attributes.swift" |
| 62 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 66 |
| 63 | + // CHECK: {{.*}} = integer_literal $Builtin.IntLiteral, 4 |
| 64 | + // CHECK: [[IGNORE_INIT:%.*]] = function_ref @$s21runtime_metadata_defs6IgnoreV10attachedTo6fileID4line6columnACx_SSS2itclufC |
| 65 | + // CHECK-NEXT: {{.*}} = apply [[IGNORE_INIT]]<(inout MemberTests) -> Int>({{.*}}) |
| 66 | + @Ignore mutating func mutatingFn() -> Int { 42 } |
| 67 | +} |
0 commit comments