Files
swift-mirror/test/SILGen/if_expr.swift
Dmitri Hrybenko 3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00

49 lines
1.5 KiB
Swift

// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
func fizzbuzz(i: Int) -> String {
return i % 3 == 0
? "fizz"
: i % 5 == 0
? "buzz"
: "\(i)"
// CHECK: cond_br {{%.*}}, [[OUTER_TRUE:bb[0-9]+]], [[OUTER_FALSE:bb[0-9]+]]
// CHECK: [[OUTER_TRUE]]:
// CHECK: br [[OUTER_CONT:bb[0-9]+]]
// CHECK: [[OUTER_FALSE]]:
// CHECK: cond_br {{%.*}}, [[INNER_TRUE:bb[0-9]+]], [[INNER_FALSE:bb[0-9]+]]
// CHECK: [[INNER_TRUE]]:
// CHECK: br [[INNER_CONT:bb[0-9]+]]
// CHECK: [[INNER_FALSE]]:
// CHECK: function_ref {{.*}}stringInterpolation
// CHECK: br [[INNER_CONT]]
// CHECK: [[INNER_CONT]]({{.*}}):
// CHECK: br [[OUTER_CONT]]
// CHECK: [[OUTER_CONT]]({{.*}}):
// CHECK: return
}
protocol AddressOnly {}
struct A : AddressOnly {}
struct B : AddressOnly {}
func consumeAddressOnly(_: AddressOnly) {}
// CHECK: sil hidden @_TF7if_expr19addr_only_ternary_1
func addr_only_ternary_1(let x: Bool) -> AddressOnly {
// CHECK: bb0([[RET:%.*]] : $*AddressOnly, {{.*}}):
// CHECK: [[a:%[0-9]+]] = alloc_box $AddressOnly // var a
var a : AddressOnly = A()
// CHECK: [[b:%[0-9]+]] = alloc_box $AddressOnly // var b
var b : AddressOnly = B()
// CHECK: cond_br {{%.*}}, [[TRUE:bb[0-9]+]], [[FALSE:bb[0-9]+]]
// CHECK: [[TRUE]]:
// CHECK: copy_addr [[a]]#1 to [initialization] [[RET]]
// CHECK: br [[CONT:bb[0-9]+]]
// CHECK: [[FALSE]]:
// CHECK: copy_addr [[b]]#1 to [initialization] [[RET]]
// CHECK: br [[CONT]]
return x ? a : b
}