Skip to content

Commit 20eaa34

Browse files
committed
Swift: failing tests for linkage awareness
1 parent c8e894b commit 20eaa34

File tree

22 files changed

+127
-15
lines changed

22 files changed

+127
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| file://:0:0:0:0 | cross_references |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import swift
2+
3+
// check that the `cross_references` module has exactly one entity in the DB
4+
from ModuleDecl m
5+
where m.getName() = "cross_references"
6+
select m
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
func foo() {}
1+
public func foo() {}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
func bar() {}
1+
public func bar() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public func baz() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public func bazz() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import F
2+
import Fs
3+
4+
func use_imported() {
5+
F.foo()
6+
F.bar()
7+
Fs.baz()
8+
Fs.bazz()
9+
}

swift/integration-tests/posix-only/frontend-invocations/Files.expected

+4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
| E.swift:0:0:0:0 | E.swift |
66
| F1.swift:0:0:0:0 | F1.swift |
77
| F2.swift:0:0:0:0 | F2.swift |
8+
| F3.swift:0:0:0:0 | F3.swift |
9+
| F5.swift:0:0:0:0 | F5.swift |
810
| G.swift:0:0:0:0 | G.swift |
911
| H1.swift:0:0:0:0 | H1.swift |
1012
| H2.swift:0:0:0:0 | H2.swift |
13+
| I1.swift:0:0:0:0 | I1.swift |
14+
| I2.swift:0:0:0:0 | I2.swift |
1115
| file://:0:0:0:0 | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let I1 = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let I2 = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
| file://:0:0:0:0 | A |
2+
| file://:0:0:0:0 | B |
3+
| file://:0:0:0:0 | Builtin |
4+
| file://:0:0:0:0 | C |
5+
| file://:0:0:0:0 | D |
6+
| file://:0:0:0:0 | E |
7+
| file://:0:0:0:0 | F |
8+
| file://:0:0:0:0 | F5 |
9+
| file://:0:0:0:0 | Fs |
10+
| file://:0:0:0:0 | G |
11+
| file://:0:0:0:0 | H1 |
12+
| file://:0:0:0:0 | I1 |
13+
| file://:0:0:0:0 | Swift |
14+
| file://:0:0:0:0 | SwiftOnoneSupport |
15+
| file://:0:0:0:0 | SwiftShims |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import swift
2+
3+
from ModuleDecl m
4+
where m.getName().charAt(0) != "_"
5+
select m
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -x
22

33
if [[ "$(uname)" == Darwin ]]; then
44
SDK="-sdk $(xcrun -show-sdk-path)"
@@ -8,16 +8,22 @@ else
88
FRONTEND="swift-frontend"
99
fi
1010

11+
function invoke() {
12+
$FRONTEND -frontend "$@" $SDK
13+
}
14+
1115
rm -rf *.swiftmodule *.o
1216

13-
$FRONTEND -frontend -c A.swift $SDK
14-
$FRONTEND -frontend -c B.swift -o B.o $SDK
15-
$FRONTEND -frontend -c -primary-file C.swift $SDK
16-
$FRONTEND -frontend -c -primary-file D.swift -o D.o $SDK
17-
$FRONTEND -frontend -c -primary-file E.swift Esup.swift -o E.o $SDK
18-
$FRONTEND -frontend -emit-module -primary-file F1.swift F2.swift -module-name F -o F1.swiftmodule $SDK
19-
$FRONTEND -frontend -emit-module F1.swift -primary-file F2.swift -module-name F -o F2.swiftmodule $SDK
20-
$FRONTEND -frontend -emit-module F1.swift F2.swift -o Fs.swiftmodule $SDK
21-
$FRONTEND -frontend -merge-modules F1.swiftmodule F2.swiftmodule -o F.swiftmodule $SDK
22-
( cd dir; $FRONTEND -frontend -c ../G.swift $SDK )
23-
$FRONTEND -frontend -c -primary-file H1.swift -primary-file H2.swift H3.swift -emit-module-path H1.swiftmodule -emit-module-path H2.swiftmodule -o H1.o -o H2.o $SDK
17+
invoke -c A.swift
18+
invoke -c B.swift -o B.o
19+
invoke -c -primary-file C.swift
20+
invoke -c -primary-file D.swift -o D.o
21+
invoke -c -primary-file E.swift Esup.swift -o E.o
22+
invoke -emit-module -primary-file F1.swift F2.swift -module-name F -o F1.swiftmodule
23+
invoke -emit-module F1.swift -primary-file F2.swift -module-name F -o F2.swiftmodule
24+
invoke -emit-module F3.swift F4.swift -o Fs.swiftmodule
25+
invoke -emit-module -merge-modules F1.swiftmodule F2.swiftmodule -o F.swiftmodule
26+
invoke -c F5.swift -o F5.o -I.
27+
( cd dir; invoke -c ../G.swift )
28+
invoke -c -primary-file H1.swift -primary-file H2.swift H3.swift -emit-module-path H1.swiftmodule -emit-module-path H2.swiftmodule -o H1.o -o H2.o
29+
invoke -emit-module -primary-file I1.swift -primary-file I2.swift -o I1.swiftmodule -o I2.swiftmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Foo1/Sources/foo/main.swift:1:1:1:31 | foo() | Foo1/Sources/foo/main.swift:1:19:1:31 | { ... } |
2+
| Foo2/Sources/foo/main.swift:2:1:2:32 | foo() | Foo2/Sources/foo/main.swift:2:19:2:32 | { ... } |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import swift
2+
3+
from ConcreteFuncDecl decl, BraceStmt body
4+
where decl.getName() = "foo()" and decl.getBody() = body
5+
select decl, body
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// swift-tools-version: 5.7
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "Foo",
7+
products: [
8+
.executable(
9+
name: "foo",
10+
targets: ["foo"]),
11+
],
12+
targets: [
13+
.executableTarget(
14+
name: "foo",
15+
dependencies: []),
16+
]
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
func foo() -> Int { return 42 }
2+
3+
print(foo())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// swift-tools-version: 5.7
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "Foo",
7+
products: [
8+
.executable(
9+
name: "foo",
10+
targets: ["foo"]),
11+
],
12+
targets: [
13+
.executableTarget(
14+
name: "foo",
15+
dependencies: []),
16+
]
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
func foo() -> Int { return 404 }
3+
4+
5+
print(foo())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
for dir in Foo1 Foo2; do
4+
(
5+
cd $dir
6+
swift package clean
7+
swift build
8+
)
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from create_database_utils import *
2+
3+
run_codeql_database_create([
4+
'./build.sh',
5+
], lang='swift', keep_trap=True)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from create_database_utils import *
22

33
run_codeql_database_create([
4-
'env',
54
'swift package clean',
65
'swift build'
76
], lang='swift', keep_trap=True)

0 commit comments

Comments
 (0)