Runtime: Work around rdar://problem/18950072 to avoid paying for .cxx_destruct on Swift objects.

Clang overzealously infects SwiftObject with the HasCXXStructors bit because it contained a struct (with trivial constructor). Manually explode the struct to avoid this.

Swift SVN r23259
This commit is contained in:
Joe Groff
2014-11-12 02:30:31 +00:00
parent 4244c45f37
commit b50293b26a
2 changed files with 45 additions and 1 deletions

View File

@@ -216,3 +216,36 @@ println("done ValueLike hashValue")
// CHECK-NEXT: sh2 20
// CHECK-NEXT: sh3 10
// CHECK-NEXT: done ValueLike hashValue
// Native Swift objects should not have nontrivial structors from ObjC's point
// of view.
class NativeSwift {}
class GenericNativeSwift<T> {}
var native: AnyObject = NativeSwift()
if native.respondsToSelector(".cxx_construct") {
println("SwiftObject has nontrivial constructor")
} else {
println("no nontrivial constructor") // CHECK-NEXT: no nontrivial constructor
}
if native.respondsToSelector(".cxx_destruct") {
println("SwiftObject has nontrivial destructor")
} else {
println("no nontrivial destructor") // CHECK-NEXT: no nontrivial destructor
}
native = GenericNativeSwift<Int>()
if native.respondsToSelector(".cxx_construct") {
println("SwiftObject has nontrivial constructor")
} else {
println("no nontrivial constructor") // CHECK-NEXT: no nontrivial constructor
}
if native.respondsToSelector(".cxx_destruct") {
println("SwiftObject has nontrivial destructor")
} else {
println("no nontrivial destructor") // CHECK-NEXT: no nontrivial destructor
}