Skip to content

Commit 830a842

Browse files
authored
Merge pull request #82455 from eeckstein/adress-of-borrow-feature
Guard InlineArray addressors with feature flag
2 parents 92dd843 + 0dbc63a commit 830a842

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ LANGUAGE_FEATURE(AlwaysInheritActorContext, 472, "@_inheritActorContext(always)"
268268
LANGUAGE_FEATURE(BuiltinSelect, 0, "Builtin.select")
269269
LANGUAGE_FEATURE(BuiltinInterleave, 0, "Builtin.interleave and Builtin.deinterleave")
270270
LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector types")
271+
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")
271272

272273
// Swift 6
273274
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ static bool usesFeatureDefaultIsolationPerFile(Decl *D) {
691691
UNINTERESTING_FEATURE(BuiltinSelect)
692692
UNINTERESTING_FEATURE(BuiltinInterleave)
693693
UNINTERESTING_FEATURE(BuiltinVectorsExternC)
694+
UNINTERESTING_FEATURE(AddressOfProperty)
694695

695696
// ----------------------------------------------------------------------------
696697
// MARK: - FeatureSet

stdlib/public/core/InlineArray.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ extension InlineArray where Element: ~Copyable {
6969
@_alwaysEmitIntoClient
7070
@_transparent
7171
internal var _address: UnsafePointer<Element> {
72+
#if $AddressOfProperty
7273
unsafe UnsafePointer<Element>(Builtin.unprotectedAddressOfBorrow(_storage))
74+
#else
75+
unsafe UnsafePointer<Element>(Builtin.unprotectedAddressOfBorrow(self))
76+
#endif
7377
}
7478

7579
/// Returns a buffer pointer over the entire array.
@@ -86,7 +90,11 @@ extension InlineArray where Element: ~Copyable {
8690
@_transparent
8791
internal var _mutableAddress: UnsafeMutablePointer<Element> {
8892
mutating get {
93+
#if $AddressOfProperty
8994
unsafe UnsafeMutablePointer<Element>(Builtin.unprotectedAddressOf(&_storage))
95+
#else
96+
unsafe UnsafeMutablePointer<Element>(Builtin.unprotectedAddressOf(&self))
97+
#endif
9098
}
9199
}
92100

0 commit comments

Comments
 (0)