-
Notifications
You must be signed in to change notification settings - Fork 439
[Syntax] Workaround for 'cannot bypass resilience' warnings #3020
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
Conversation
Sources/SwiftSyntax/Syntax.swift
Outdated
private let mutex: PlatformMutex | ||
/// | ||
/// - Note: `UnsafeMutableRawPointer` + casting accessor is a workaround to silence the warning 'cannot bypass resilience'. | ||
private let _mutex: UnsafeMutableRawPointer! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this nave to be an IUO? Shouldn’t we be able to make this a UnsafeMutableRawPointer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have platforms where it is actually nil
(i.e !SWIFTSYNTAX_HAS_THREAD
). I used IUO because the PlatformMutex.opaque
type is UnsafeMutableRawPointer!
(by default by ClangImporter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Should we just make it a proper optional in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I don't see any drawbacks for using optional. Done
@swift-ci Please test |
`RawSyntaxArena` and `SyntaxDataaArena` have properties with types from `_SwiftSyntaxCShims` which is `@_implementationOnly` when compiling with '-enable-library-evolution`. But for `-allow-non-resilient-access` for the package cross module optimizations, they causes warnings: ``` warning: cannot bypass resilience due to member deserialization failure while attempting to access member 'mutex' of 'SyntaxDataArena' in module 'SwiftSyntax' from module 'SwiftSyntax' warning: cannot bypass resilience due to member deserialization failure while attempting to access member 'hasParent' of 'RawSyntaxArena' in module 'SwiftSyntax' from module 'SwiftSyntax' ``` and non-resilient-access are disabled for these types. To workaround that, use `UnsafeRawPointer` for those stored properties and use casting methods to access the actual types. Note the using computed properties were not enough to silience the warnings.
40b82e4
to
31182de
Compare
@swift-ci Please test |
@swift-ci Please test Linux |
@swift-ci Please test Windows |
@swift-ci Please test Linux |
swiftlang/swift-package-manager#8386 |
RawSyntaxArena
andSyntaxDataaArena
have properties with types from_SwiftSyntaxCShims
which is@_implementationOnly
when compiling with-enable-library-evolution
.But for
-allow-non-resilient-access
for the package cross module optimizations, they caused warnings in 6.1+ compilers:and non-resilient-access are disabled for these types.
To workaround that, use
UnsafeRawPointer
for those stored properties and use casting methods to access the actual types. Note the using computed properties were not enough to silience the warnings.