Skip to content

Guard InlineArray addressors with feature flag #82455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ LANGUAGE_FEATURE(AlwaysInheritActorContext, 472, "@_inheritActorContext(always)"
LANGUAGE_FEATURE(BuiltinSelect, 0, "Builtin.select")
LANGUAGE_FEATURE(BuiltinInterleave, 0, "Builtin.interleave and Builtin.deinterleave")
LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector types")
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")

// Swift 6
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
Expand Down
1 change: 1 addition & 0 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ static bool usesFeatureDefaultIsolationPerFile(Decl *D) {
UNINTERESTING_FEATURE(BuiltinSelect)
UNINTERESTING_FEATURE(BuiltinInterleave)
UNINTERESTING_FEATURE(BuiltinVectorsExternC)
UNINTERESTING_FEATURE(AddressOfProperty)

// ----------------------------------------------------------------------------
// MARK: - FeatureSet
Expand Down
8 changes: 8 additions & 0 deletions stdlib/public/core/InlineArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ extension InlineArray where Element: ~Copyable {
@_alwaysEmitIntoClient
@_transparent
internal var _address: UnsafePointer<Element> {
#if $AddressOfProperty
unsafe UnsafePointer<Element>(Builtin.unprotectedAddressOfBorrow(_storage))
#else
unsafe UnsafePointer<Element>(Builtin.unprotectedAddressOfBorrow(self))
#endif
}

/// Returns a buffer pointer over the entire array.
Expand All @@ -86,7 +90,11 @@ extension InlineArray where Element: ~Copyable {
@_transparent
internal var _mutableAddress: UnsafeMutablePointer<Element> {
mutating get {
#if $AddressOfProperty
unsafe UnsafeMutablePointer<Element>(Builtin.unprotectedAddressOf(&_storage))
#else
unsafe UnsafeMutablePointer<Element>(Builtin.unprotectedAddressOf(&self))
#endif
}
}

Expand Down