Commit Graph

9 Commits

Author SHA1 Message Date
Doug Gregor
733dd86c92 Merge pull request #79896 from DougGregor/strict-memory-safety-cleanups
Strict memory safety cleanups
2025-03-11 01:26:30 -07:00
Doug Gregor
9f2859edd8 Update Cxx library for strict memory safety 2025-03-10 15:42:29 -07:00
Guillaume Lessard
082aaecc9c [stdlib] update availability for CxxSpan (#79883) 2025-03-10 10:13:39 -07:00
Doug Gregor
89d0277a35 Enable strict memory safety in the Cxx/CxxStdlib modules 2025-02-26 14:28:30 -08:00
Gabor Horvath
df27b79579 [cxx-interop] Work around lifetime errors in SwiftifyImport generated code
Unfortunately, this was not discovered earlier as swift-ide-test is not
invoking the SIL passes that produce this diagnostic. When creating
Swift spans from C++ spans we have no lifetime dependency information to
propagate as C++ spans are modeled as escapable types. Hence, this PR
introduces a helper function to bypass the lifetime checks triggered by
this discepancy. Hopefully, the new utility will go away as the lifetime
analysis matures on the Swift side and we get standardized way to deal
with unsafe lifetimes.
2025-02-14 16:40:43 +00:00
Andrew Trick
60845673b0 Fix Span initialization from CxxSpan.
CxxSpan is trivial, but not immortal.

This initializer is diagnosed with an error after enabling trivial dependence
enforcement. Correct this with an _overrideLifetime call. This could be avoided
if we had a another way to tell the compiler that CxxSpan.__dataUnsafe()
produced a pointer with the same effective lifetime as the CxxSpan.
2024-12-18 16:58:49 -08: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
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00