Commit Graph

4 Commits

Author SHA1 Message Date
Gabor Horvath
43cef148cb [cxx-interop] Do not consider std::span<T>::size and co unsafe
Since these APIs operate on unsafes we consider them unsafe by default.
This PR adds APINotes to override these defaults as these APIs will not
touch the underlying buffer. This should slightly reduce the number of
`unsafe`s in user code.

rdar://159839254
2025-09-25 11:28:26 +01:00
Gabor Horvath
b6cc118f71 [cxx-interop] Explicit conversions between Swift and C++ spans
A first step towards creating safe overloads for C++ APIs using span
(rdar://139074571).

Note that we need to mark span as owned because it the libc++
implementation was mistakenly recognized as owned and might now rely on
span methods like `data` being renamed as `__dataUnsafe`. We will change
it under a new interop version. But for the time being, we want
consistent behavior across stdlib versions.
2024-12-13 16:01:02 +00:00
Egor Zhdan
c39c8da4db [cxx-interop] Use APINotes to apply import_owned attr to std::string and std::vector
This removes a special case in the compiler for these types, and applies the `import_owned` attribute to all instantiations of `vector` and `basic_string` via API Notes.
2023-12-04 19:54:17 +00:00
Egor Zhdan
9b7dbf2599 [cxx-interop] Introduce APINotes file for C++ stdlib
This adds an `std.apinotes` file that is installed into `lib/swift/apinotes` along with existing Darwin apinotes. This new file is installed on all platforms. It replaces a few special cases in the compiler for `cmath` and `cstring` functions.

This does not require the upcoming APINotes support for namespaces, however, this does require https://github.com/apple/llvm-project/pull/7309.

rdar://107572302
2023-08-29 23:34:36 +01:00