Skip to content

Commit 17c77ba

Browse files
committed
Only use _CVarArgObject on non-ObjC platforms
1 parent 0e7749b commit 17c77ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

stdlib/public/core/VarArgs.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ protocol _CVarArgAligned: CVarArg {
6363
var _cVarArgAlignment: Int { get }
6464
}
6565

66+
#if !_runtime(_ObjC)
6667
/// Some pointers require an alternate object to be retained. The object
6768
/// that is returned will be used with _cVarArgEncoding and held until
6869
/// the closure is complete. This is required since autoreleased storage
@@ -71,6 +72,7 @@ public protocol _CVarArgObject: CVarArg {
7172
/// Returns the alternate object that should be encoded.
7273
var _cVarArgObject: CVarArg { get }
7374
}
75+
#endif
7476

7577
#if arch(x86_64)
7678
@usableFromInline
@@ -471,8 +473,10 @@ final internal class __VaListBuilder {
471473
@usableFromInline // c-abi
472474
internal var storage: ContiguousArray<Int>
473475

476+
#if !_runtime(_ObjC)
474477
@usableFromInline // c-abi
475478
internal var retainer = [CVarArg]()
479+
#endif
476480

477481
@inlinable // c-abi
478482
internal init() {
@@ -487,11 +491,13 @@ final internal class __VaListBuilder {
487491
internal func append(_ arg: CVarArg) {
488492
var arg = arg
489493

494+
#if !_runtime(_ObjC)
490495
// We may need to retain an object that provides a pointer value.
491496
if let obj = arg as? _CVarArgObject {
492497
arg = obj._cVarArgObject
493498
retainer.append(arg)
494499
}
500+
#endif
495501

496502
var encoded = arg._cVarArgEncoding
497503

@@ -582,11 +588,13 @@ final internal class __VaListBuilder {
582588
internal func append(_ arg: CVarArg) {
583589
var arg = arg
584590

591+
#if !_runtime(_ObjC)
585592
// We may need to retain an object that provides a pointer value.
586593
if let obj = arg as? _CVarArgObject {
587594
arg = obj._cVarArgObject
588595
retainer.append(arg)
589596
}
597+
#endif
590598

591599
// Write alignment padding if necessary.
592600
// This is needed on architectures where the ABI alignment of some
@@ -693,8 +701,10 @@ final internal class __VaListBuilder {
693701
@usableFromInline // c-abi
694702
internal var storage: UnsafeMutablePointer<Int>?
695703

704+
#if !_runtime(_ObjC)
696705
@usableFromInline // c-abi
697706
internal var retainer = [CVarArg]()
707+
#endif
698708

699709
internal static var alignedStorageForEmptyVaLists: Double = 0
700710
}

0 commit comments

Comments
 (0)