Skip to content

Commit 9fad85c

Browse files
committed
[SwiftifyImport] Add various submodule import test cases
Updates to these test cases will make it easier to follow the effects of the next commits.
1 parent 1babc48 commit 9fad85c

File tree

3 files changed

+401
-0
lines changed

3 files changed

+401
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// REQUIRES: swift_feature_SafeInteropWrappers
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: split-file %s %t
5+
6+
// RUN: %target-swift-ide-test -print-module -module-print-hidden -module-to-print=A1 -plugin-path %swift-plugin-dir -I %t -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s --check-prefix CHECK-A1 --implicit-check-not=import --match-full-lines
7+
// RUN: %target-swift-ide-test -print-module -module-print-hidden -module-to-print=A2 -plugin-path %swift-plugin-dir -I %t -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s --check-prefix CHECK-A2 --implicit-check-not=import --match-full-lines
8+
9+
//--- test.swift
10+
import A1
11+
12+
import A2
13+
14+
public func callUnsafe(_ p: UnsafeMutableRawPointer) {
15+
let _ = a1(p, 13)
16+
let _ = a2(p, 13)
17+
}
18+
19+
public func callSafe(_ p: UnsafeMutableRawBufferPointer) {
20+
let _ = a1(p)
21+
let _ = a2(p)
22+
}
23+
24+
//--- Inputs/module.modulemap
25+
module A1 {
26+
header "A1.h"
27+
explicit module Aliasing {
28+
// Make sure that the full module path is taken into account
29+
// and not just the module name
30+
header "Aliasing1.h"
31+
explicit module Aliasing {
32+
header "Aliasing2.h"
33+
}
34+
}
35+
}
36+
module A2 {
37+
header "A2.h"
38+
}
39+
module A3 {
40+
explicit module Aliasing {
41+
header "Aliasing3.h"
42+
}
43+
}
44+
module A4 {
45+
explicit module Aliasing {
46+
header "Aliasing4.h"
47+
}
48+
}
49+
50+
//--- Inputs/A1.h
51+
#pragma once
52+
53+
#include "Aliasing1.h"
54+
#include "Aliasing2.h"
55+
56+
// CHECK-A1: import A1.Aliasing
57+
// CHECK-A1: import A1.Aliasing.Aliasing
58+
59+
#define __sized_by(s) __attribute__((__sized_by__(s)))
60+
61+
aliasing1_t a1(void * _Nonnull __sized_by(size), aliasing2_t size);
62+
63+
//--- Inputs/Aliasing1.h
64+
#pragma once
65+
66+
typedef int aliasing1_t;
67+
68+
//--- Inputs/Aliasing2.h
69+
#pragma once
70+
71+
typedef int aliasing2_t;
72+
73+
//--- Inputs/Aliasing3.h
74+
#pragma once
75+
76+
typedef int aliasing3_t;
77+
78+
//--- Inputs/Aliasing4.h
79+
#pragma once
80+
81+
typedef int aliasing4_t;
82+
83+
//--- Inputs/A2.h
84+
#pragma once
85+
86+
#include "Aliasing3.h"
87+
#include "Aliasing4.h"
88+
89+
// CHECK-A2-NOT: import
90+
91+
#define __sized_by(s) __attribute__((__sized_by__(s)))
92+
93+
aliasing3_t a2(void * _Nonnull __sized_by(size), aliasing4_t size);
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// REQUIRES: swift_feature_SafeInteropWrappers
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: split-file %s %t
5+
6+
// RUN: %target-swift-ide-test -print-module -module-print-hidden -module-to-print=A1.B1 -plugin-path %swift-plugin-dir -I %t -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s --check-prefix CHECK-B1 --implicit-check-not=import --match-full-lines
7+
// RUN: %target-swift-ide-test -print-module -module-print-hidden -module-to-print=A1.B1.C1 -plugin-path %swift-plugin-dir -I %t -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s --check-prefix CHECK-C1 --implicit-check-not=import --match-full-lines
8+
9+
// RUN: %target-swift-ide-test -print-module -module-print-hidden -module-to-print=A2.B2 -plugin-path %swift-plugin-dir -I %t -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s --check-prefix CHECK-B2 --implicit-check-not=import --match-full-lines
10+
11+
//--- test.swift
12+
import A1.B1
13+
import A2.B2
14+
15+
public func callUnsafe(_ p: UnsafeMutableRawPointer) {
16+
let _ = b1b(p, 13)
17+
let _ = b1c(p, 13)
18+
let _ = b1d(p, 13)
19+
let _ = b2b(p, 13)
20+
let _ = b2c(p, 13)
21+
let _ = b2d(p, 13)
22+
}
23+
24+
public func callSafe(_ p: UnsafeMutableRawBufferPointer) {
25+
let _ = b1b(p)
26+
let _ = b1c(p)
27+
let _ = b1d(p)
28+
let _ = b2b(p)
29+
let _ = b2c(p)
30+
let _ = b2d(p)
31+
}
32+
//--- Inputs/module.modulemap
33+
module A1 {
34+
explicit module B1 {
35+
header "B1.h"
36+
explicit module C1 {
37+
header "C1.h"
38+
explicit module D1 {
39+
header "D1.h"
40+
}
41+
}
42+
}
43+
}
44+
module A2 {
45+
explicit module B2 {
46+
header "B2.h"
47+
}
48+
}
49+
50+
//--- Inputs/B1.h
51+
#pragma once
52+
53+
#include "C1.h"
54+
#include "D1.h"
55+
56+
// CHECK-B1: import A1.B1.C1
57+
// CHECK-B1: import A1.B1.C1.D1
58+
59+
typedef int b1_t;
60+
61+
b1_t b1b(void * _Nonnull __sized_by(size), int size);
62+
c1_t b1c(void * _Nonnull __sized_by(size), int size);
63+
d1_t b1d(void * _Nonnull __sized_by(size), int size);
64+
65+
//--- Inputs/C1.h
66+
#pragma once
67+
68+
#include "D1.h"
69+
70+
// CHECK-C1: import A1.B1.C1.D1
71+
72+
typedef int c1_t;
73+
74+
75+
//--- Inputs/D1.h
76+
#pragma once
77+
78+
#define __sized_by(s) __attribute__((__sized_by__(s)))
79+
80+
typedef int d1_t;
81+
82+
//--- Inputs/B2.h
83+
#pragma once
84+
85+
#include "B1.h"
86+
#include "C1.h"
87+
#include "D1.h"
88+
89+
// CHECK-B2-NOT: import
90+
91+
b1_t b2b(void * _Nonnull __sized_by(size), int size);
92+
c1_t b2c(void * _Nonnull __sized_by(size), int size);
93+
d1_t b2d(void * _Nonnull __sized_by(size), int size);

0 commit comments

Comments
 (0)