Files
swift-mirror/test/SILGen/super_init_refcounting.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

67 lines
2.2 KiB
Swift

// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
class Foo {
init() {}
init(_ x: Foo) {}
}
class Bar: Foo {
// CHECK-LABEL: sil hidden @_TFC22super_init_refcounting3BarcfMS0_FT_S0_
// CHECK: [[SELF_VAR:%.*]] = alloc_box $Bar
// CHECK: [[SELF_MUI:%.*]] = mark_uninitialized [derivedself] [[SELF_VAR]]#1
// CHECK: [[ORIG_SELF:%.*]] = load [[SELF_MUI]]
// CHECK-NOT: strong_retain [[ORIG_SELF]]
// CHECK: [[ORIG_SELF_UP:%.*]] = upcast [[ORIG_SELF]]
// CHECK-NOT: strong_retain [[ORIG_SELF_UP]]
// CHECK: [[SUPER_INIT:%.*]] = function_ref @_TFC22super_init_refcounting3FoocfMS0_FT_S0_
// CHECK: [[NEW_SELF:%.*]] = apply [[SUPER_INIT]]([[ORIG_SELF_UP]])
// CHECK: [[NEW_SELF_DOWN:%.*]] = unchecked_ref_cast [[NEW_SELF]]
// CHECK: store [[NEW_SELF_DOWN]] to [[SELF_MUI]]
override init() {
super.init()
}
}
extension Foo {
// CHECK-LABEL: sil hidden @_TFC22super_init_refcounting3FoocfMS0_FT1xSi_S0_
// CHECK: [[SELF_VAR:%.*]] = alloc_box $Foo
// CHECK: [[SELF_MUI:%.*]] = mark_uninitialized [delegatingself] [[SELF_VAR]]#1
// CHECK: [[ORIG_SELF:%.*]] = load [[SELF_MUI]]
// CHECK-NOT: strong_retain [[ORIG_SELF]]
// CHECK: [[SUPER_INIT:%.*]] = class_method
// CHECK: [[NEW_SELF:%.*]] = apply [[SUPER_INIT]]([[ORIG_SELF]])
// CHECK: store [[NEW_SELF]] to [[SELF_MUI]]
convenience init(x: Int) {
self.init()
}
}
class Zim: Foo {
var foo = Foo()
// CHECK-LABEL: sil hidden @_TFC22super_init_refcounting3ZimcfMS0_FT_S0_
// CHECK-NOT: strong_retain
// CHECK-NOT: strong_release
// CHECK: function_ref @_TFC22super_init_refcounting3FoocfMS0_FT_S0_
}
class Zang: Foo {
var foo: Foo
override init() {
foo = Foo()
super.init()
}
// CHECK-LABEL: sil hidden @_TFC22super_init_refcounting4ZangcfMS0_FT_S0_
// CHECK-NOT: strong_retain
// CHECK-NOT: strong_release
// CHECK: function_ref @_TFC22super_init_refcounting3FoocfMS0_FT_S0_
}
class Bad: Foo {
// Invalid code, but it's not diagnosed till DI. We at least shouldn't
// crash on it.
override init() {
super.init(self)
}
}