mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user