Skip to content

Commit 88f9c67

Browse files
committed
Add FileCheck tests
1 parent c19f3ce commit 88f9c67

File tree

1 file changed

+47
-24
lines changed

1 file changed

+47
-24
lines changed

test/SILGen/keypaths.swift

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,6 @@ struct SubscriptDefaults5 {
369369
}
370370
}
371371

372-
struct SubscriptVariadic1 {
373-
subscript(x: Int...) -> Int { x[0] }
374-
}
375-
376-
struct SubscriptVariadic2 {
377-
subscript<T : ExpressibleByStringLiteral>(x: T...) -> T { x[0] }
378-
}
379-
380-
struct SubscriptVariadic3<T : ExpressibleByStringLiteral> {
381-
subscript(x: T...) -> T { x[0] }
382-
}
383-
384372
// CHECK-LABEL: sil hidden [ossa] @{{.*}}10subscripts1x1y1syx_q_SStSHRzSHR_r0_lF
385373
func subscripts<T: Hashable, U: Hashable>(x: T, y: U, s: String) {
386374
_ = \Subscripts<T>.[]
@@ -429,18 +417,6 @@ func subscripts<T: Hashable, U: Hashable>(x: T, y: U, s: String) {
429417
_ = \SubscriptDefaults4.[x: 0, y: 0]
430418
_ = \SubscriptDefaults5.[x: ""]
431419
_ = \SubscriptDefaults5.[x: "", y: ""]
432-
433-
_ = \SubscriptVariadic1.[1, 2, 3]
434-
_ = \SubscriptVariadic1.[1]
435-
_ = \SubscriptVariadic1.[]
436-
437-
_ = \SubscriptVariadic2.["", "1"]
438-
_ = \SubscriptVariadic2.[""]
439-
_ = \SubscriptVariadic2.["", #function]
440-
441-
_ = \SubscriptVariadic3<String>.[""]
442-
_ = \SubscriptVariadic3<String>.["", "1"]
443-
_ = \SubscriptVariadic3<String>.[]
444420
}
445421

446422
// CHECK-LABEL: sil hidden [ossa] @{{.*}}check_default_subscripts
@@ -476,6 +452,53 @@ func check_default_subscripts() {
476452
_ = \SubscriptDefaults5.[x: "", y: ""]
477453
}
478454

455+
struct SubscriptVariadic1 {
456+
subscript(x: Int...) -> Int { x[0] }
457+
}
458+
459+
struct SubscriptVariadic2 {
460+
subscript<T : ExpressibleByStringLiteral>(x: T...) -> T { x[0] }
461+
}
462+
463+
struct SubscriptVariadic3<T : ExpressibleByStringLiteral> {
464+
subscript(x: T...) -> T { x[0] }
465+
}
466+
467+
// CHECK-LABEL: sil hidden [ossa] @{{.*}}test_variadics
468+
func test_variadics() {
469+
// CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 3
470+
// CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
471+
// CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
472+
// CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
473+
// CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
474+
_ = \SubscriptVariadic1.[1, 2, 3]
475+
// CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 1
476+
// CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
477+
// CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
478+
// CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
479+
// CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
480+
_ = \SubscriptVariadic1.[1]
481+
// CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 0
482+
// CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
483+
// CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<Int>([[ARR_COUNT]])
484+
// CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<Int>, Builtin.RawPointer)
485+
// CHECK: keypath $KeyPath<SubscriptVariadic1, Int>, (root $SubscriptVariadic1; gettable_property $Int, id @$s8keypaths18SubscriptVariadic1VyS2id_tcig : $@convention(method) (@guaranteed Array<Int>, SubscriptVariadic1) -> Int, getter @$s8keypaths18SubscriptVariadic1VyS2id_tcipACTK : $@convention(thin) (@in_guaranteed SubscriptVariadic1, UnsafeRawPointer) -> @out Int, indices [%$0 : $Array<Int> : $Array<Int>], indices_equals @$sSaySiGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySiGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
486+
_ = \SubscriptVariadic1.[]
487+
488+
_ = \SubscriptVariadic2.["", "1"]
489+
_ = \SubscriptVariadic2.[""]
490+
// CHECK: [[ARR_COUNT:%[0-9]+]] = integer_literal $Builtin.Word, 2
491+
// CHECK: [[FN_REF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
492+
// CHECK: [[MAKE_ARR:%[0-9]+]] = apply [[FN_REF]]<String>([[ARR_COUNT]])
493+
// CHECK: ([[ARR:%[0-9]+]], %{{[0-9]+}}) = destructure_tuple [[MAKE_ARR]] : $(Array<String>, Builtin.RawPointer)
494+
// CHECK: keypath $KeyPath<SubscriptVariadic2, String>, (root $SubscriptVariadic2; gettable_property $String, id @$s8keypaths18SubscriptVariadic2Vyxxd_tcs26ExpressibleByStringLiteralRzluig : $@convention(method) <τ_0_0 where τ_0_0 : ExpressibleByStringLiteral> (@guaranteed Array<τ_0_0>, SubscriptVariadic2) -> @out τ_0_0, getter @$s8keypaths18SubscriptVariadic2Vyxxd_tcs26ExpressibleByStringLiteralRzluipACSSTK : $@convention(thin) (@in_guaranteed SubscriptVariadic2, UnsafeRawPointer) -> @out String, indices [%$0 : $Array<String> : $Array<String>], indices_equals @$sSaySSGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$sSaySSGTh : $@convention(thin) (UnsafeRawPointer) -> Int) ([[ARR]])
495+
_ = \SubscriptVariadic2.["", #function]
496+
497+
_ = \SubscriptVariadic3<String>.[""]
498+
_ = \SubscriptVariadic3<String>.["", "1"]
499+
_ = \SubscriptVariadic3<String>.[]
500+
}
501+
479502
// CHECK-LABEL: sil hidden [ossa] @{{.*}}subclass_generics
480503
func subclass_generics<T: C<Int>, U: C<V>, V/*: PoC*/>(_: T, _: U, _: V) {
481504
_ = \T.x

0 commit comments

Comments
 (0)