mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[embedded] Add swift_isUniquelyReferenced_native into the embedded runtime
This commit is contained in:
@@ -146,6 +146,12 @@ func swift_initStackObject(metadata: UnsafeMutablePointer<ClassMetadata>, object
|
||||
public func swift_setDeallocating(object: Builtin.RawPointer) {
|
||||
}
|
||||
|
||||
@_cdecl("swift_isUniquelyReferenced_native")
|
||||
public func swift_isUniquelyReferenced_native(object: Builtin.RawPointer) -> Bool {
|
||||
if Int(Builtin.ptrtoint_Word(object)) == 0 { return false }
|
||||
return swift_isUniquelyReferenced_nonNull_native(object: UnsafeMutablePointer<HeapObject>(object))
|
||||
}
|
||||
|
||||
@_cdecl("swift_isUniquelyReferenced_nonNull_native")
|
||||
public func swift_isUniquelyReferenced_nonNull_native(object: Builtin.RawPointer) -> Bool {
|
||||
return swift_isUniquelyReferenced_nonNull_native(object: UnsafeMutablePointer<HeapObject>(object))
|
||||
|
||||
19
test/embedded/classes-optional.swift
Normal file
19
test/embedded/classes-optional.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend %s -enable-experimental-feature Embedded -c -o %t/main.o
|
||||
// RUN: %target-clang %t/main.o -o %t/a.out -dead_strip
|
||||
// RUN: %target-run %t/a.out | %FileCheck %s
|
||||
|
||||
// REQUIRES: swift_in_compiler
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: optimized_stdlib
|
||||
// REQUIRES: OS=macosx || OS=linux-gnu
|
||||
|
||||
class Foo {
|
||||
var foo: Foo?
|
||||
}
|
||||
|
||||
do {
|
||||
_ = Foo()
|
||||
print("OK!")
|
||||
}
|
||||
// CHECK: OK!
|
||||
Reference in New Issue
Block a user