Skip to content

Conversation

@egorzhdan
Copy link
Contributor

SWIFT_IMPORT_UNSAFE is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

This removes a few usages of SWIFT_IMPORT_UNSAFE in SwiftCompilerSources that can be better expressed by other means:

  • SILDebugLocation is better described as a self-contained Swift type.
  • OptionalInt is not an unsafe type in Swift, so the attribute has no effect.
  • swift::Decl and its inheritors should be treated as foreign reference types in Swift
  • These attributes have no effect on C++ constructors.

Similar to 35263ef.

…with `SILDebugLocation`

`SWIFT_IMPORT_UNSAFE` is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

`SILDebugLocation` is better described as a self-contained Swift type.

Similar to 35263ef.
…SAFE`

`OptionalInt` is not an unsafe type in Swift, so the attribute has no effect.
…SAFE`

`swift::Decl` and its inheritors should be treated as foreign reference types in Swift, meaning pointers to them (`Decl*`) should be mapped to Swift classes. This can be done by applying `SWIFT_UNSAFE_REFERENCE` attribute to the `swift::Decl` types. However, at the moment these functions don't seem to be used from Swift, so this change just removes the `SWIFT_IMPORT_UNSAFE` attributes.
…onstructors

These attributes have no effect on C++ constructors.
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Sep 17, 2024
@egorzhdan egorzhdan requested a review from eeckstein September 17, 2024 12:40
@egorzhdan egorzhdan requested a review from jckarter as a code owner September 17, 2024 12:40
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit ad503af into main Sep 18, 2024
@egorzhdan egorzhdan deleted the egorzhdan/scs-reduce-unsafe branch September 18, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants