Files
swift-mirror/test/Interop/Cxx/stdlib/std-span-transformed-execution.swift
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

24 lines
826 B
Swift

// RUN: %target-run-simple-swift(-plugin-path %swift-plugin-dir -I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -swift-version 6 -Xfrontend -disable-availability-checking -Xcc -std=c++20 -enable-experimental-feature LifetimeDependence -enable-experimental-feature Span -enable-experimental-feature SafeInteropWrappers)
// FIXME swift-ci linux tests do not support std::span
// UNSUPPORTED: OS=linux-gnu
// TODO: test failed in Windows PR testing: rdar://144384453
// UNSUPPORTED: OS=windows-msvc
// REQUIRES: swift_feature_SafeInteropWrappers
// REQUIRES: swift_feature_Span
// REQUIRES: swift_feature_LifetimeDependence
// REQUIRES: executable_test
#if !BRIDGING_HEADER
import StdSpan
#endif
import CxxStdlib
func canCallSafeSpanAPIs(_ x: Span<CInt>) {
funcWithSafeWrapper(x)
funcWithSafeWrapper2(x)
}