Commit Graph

8 Commits

Author SHA1 Message Date
Mads Odgaard 66b5fdc03d Add support for SwiftImportAs: opaque_pointer (#88714)
Adds support for making pointers to C structs always import as OpaquePointer through API notes. This is needed to bring down the Android SDK to API level 23, since FILE is imported differently on API 23 vs 24.
2026-05-01 22:45:47 +05:30
John Hui be3e118f8d [c-interop] Add test for SWIFT_RETURNS_RETAINED annotations in C interop mode
rdar://144976203
2025-10-22 14:53:11 -07:00
Egor Zhdan c73f528b82 [cxx-interop] Validate C foreign reference types
Swift validates the retain/release operations for foreign reference types to check for obvious errors, e.g. a wrong parameter type or return type.

That logic was only running for C++ foreign reference types. This patch enables it for C foreign reference types as well.

rdar://158609723
2025-08-18 19:18:18 +01:00
Doug Gregor 0821009c34 Fix test for Windows and add missing newline to header 2025-07-28 08:30:49 -07:00
Doug Gregor 21b9b9f713 [Clang importer] Allow C structs to be noncopyable, too
In C interoperability mode, respect the ~Copyable annotation on C
structs to import them as ~Copyable types.

Fixes rdar://156877772.
2025-07-27 20:06:48 -07:00
Doug Gregor c5db5cced5 [Clang importer] Handle Swift conformances on typedefs and C types
The code for handling Swift conforms_to attributes was specific to
C++ record types. Generalize it to work on typedefs imported as
nominal types, also in C.

Fixes rdar://156290361.
2025-07-22 20:20:23 -07:00
zoecarver dc581b9d58 Support foreign reference types when C++ interop is disabled. 2022-10-26 14:50:09 -07:00
Dmitri Gribenko 61d4793970 Added tests for edge cases in importing and mangling C structs
Some of the patterns in the new test header are special-cased by
ClangImporter (for example, the names of typedefs become names of
imported structs).

Nested structs have been historically imported in Swift according to C
rules, that is, structs lexically declared nested in other structs are
imported into the global namespace anyway. For the same reason, C
structs have been mangled in Swift names as if they are declared in the
global namespace. These rules are problematic when importing C++, see
https://bugs.swift.org/browse/SR-12803.
2020-05-15 18:50:19 +02:00