11// RUN: %empty-directory(%t)
22// RUN: split-file %s %t
33
4- // RUN: %target-swift-frontend -typecheck %t/use-span.swift -typecheck -module-name UseSpan -emit-clang-header-path %t/UseSpan.h -I %t -enable-experimental-cxx-interop -Xcc -std=c++20 -clang-header-expose-decls=all-public
4+ // RUN: %target-swift-frontend -typecheck %t/use-span.swift -typecheck -module-name UseSpan -emit-clang-header-path %t/UseSpan.h -I %t -enable-experimental-cxx-interop -Xcc -Xclang -Xcc -fmodule-format=raw -Xcc - std=c++20 -clang-header-expose-decls=all-public
55
66// RUN: %target-interop-build-clangxx -std=c++20 -c %t/use-span.cpp -I %t -o %t/swift-cxx-execution.o
77// RUN: %target-interop-build-swift %t/use-span.swift -o %t/swift-cxx-execution -Xlinker %t/swift-cxx-execution.o -module-name UseSpan -Xfrontend -entry-point-function-name -Xfrontend swiftMain -I %t -O -Xcc --std=c++20
2121using Span = std::span<int >;
2222using SpanOfString = std::span<std::string>;
2323
24+ namespace ns {
25+ using SpanOfConstUInt8 = std::span<const uint8_t >;
26+ }
27+
2428static int staticArr[] = {1 , 2 , 3 };
2529static Span staticSpan = {staticArr};
2630
@@ -34,49 +38,46 @@ module CxxTest {
3438// --- use-span.swift
3539import CxxTest
3640
37- @_expose(Cxx)
3841public func createEmptySpan () -> Span {
3942 return Span ()
4043}
4144
42- @_expose(Cxx)
4345public func printSpan () {
4446 print (" {\(staticSpan[0]), \(staticSpan[1]), \(staticSpan[2])}" )
4547}
4648
47- @_expose(Cxx)
4849public func printSpan (_ sp: Span) {
4950 print (" {\(sp[0]), \(sp[1]), \(sp[2])}" )
5051}
5152
52- @_expose(Cxx)
5353public func printSpanOfString (_ sp: SpanOfString) {
5454 print (" {\(sp[0]), \(sp[1]), \(sp[2])}" )
5555}
5656
57- @_expose(Cxx)
5857public func passthroughSpan (_ sp: Span) -> Span {
5958 return sp;
6059}
6160
62- @_expose(Cxx)
6361public func changeSpan (_ sp: inout Span) {
6462 sp[0 ] = 0 ;
6563}
6664
67- @_expose(Cxx)
6865public func mapSpan (_ sp: Span) {
6966 let result = sp.map { $0 + 3 }
7067 print (result)
7168}
7269
73- @_expose(Cxx)
7470public func receiveArr (_ arr: inout [Int32]) -> Span {
7571 arr.withUnsafeMutableBufferPointer { ubpointer in
7672 return Span (ubpointer);
7773 }
7874}
7975
76+ public typealias SpanConstUInt8 = ns.SpanOfConstUInt8
77+
78+ public func receiveSpanAlias (_ sp1: SpanConstUInt8, _ sp2: SpanConstUInt8) {
79+ }
80+
8081// --- use-span.cpp
8182#include < cassert>
8283#include " header.h"
0 commit comments