Skip to content

Commit 75e2195

Browse files
author
Harlan Haskins
committed
[TBDGen] Enable TBD generation after -typecheck
1 parent 14a7ae5 commit 75e2195

File tree

9 files changed

+44
-3
lines changed

9 files changed

+44
-3
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,9 @@ static bool performCompile(CompilerInstance &Instance,
979979
return true;
980980
}
981981

982+
if (writeTBDIfNeeded(Invocation, Instance))
983+
return true;
984+
982985
// FIXME: This is still a lousy approximation of whether the module file will
983986
// be externally consumed.
984987
bool moduleIsPublic =
@@ -1001,9 +1004,6 @@ static bool performCompile(CompilerInstance &Instance,
10011004
return hadPrintAsObjCError || hadEmitIndexDataError || Context.hadError();
10021005
}
10031006

1004-
if (writeTBDIfNeeded(Invocation, Instance))
1005-
return true;
1006-
10071007
assert(FrontendOptions::doesActionGenerateSIL(Action) &&
10081008
"All actions not requiring SILGen must have been handled!");
10091009

test/TBD/class.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
99
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
1010

11+
// RUN: %empty-directory(%t)
12+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
13+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
14+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
15+
1116
open class OpenNothing {}
1217

1318
open class OpenInit {

test/TBD/enum.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -swift-version 4 -enable-testing -O
2222
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -swift-version 4 -enable-testing -O
2323

24+
// RUN: %empty-directory(%t)
25+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
26+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
27+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
28+
29+
2430
public protocol P {}
2531

2632
public class C {

test/TBD/function.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 4 %s -O
44
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all -swift-version 4 %s -enable-testing -O
55

6+
// RUN: %empty-directory(%t)
7+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
8+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
9+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
10+
611
public func publicNoArgs() {}
712
public func publicSomeArgs(_: Int, x: Int) {}
813
public func publicWithDefault(_: Int = 0) {}

test/TBD/global.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-testing -O
88
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all -enable-resilience -enable-testing %s -O
99

10+
// RUN: %empty-directory(%t)
11+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
12+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
13+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
14+
1015
public let publicLet: Int = 0
1116
internal let internalLet: Int = 0
1217
private let privateLet: Int = 0

test/TBD/main.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// RUN: %target-swift-frontend -emit-ir -o/dev/null -module-name test -validate-tbd-against-ir=all %s
22
// RUN: %target-swift-frontend -emit-ir -o/dev/null -module-name test -validate-tbd-against-ir=all %s -O
33

4+
// RUN: %empty-directory(%t)
5+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
6+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
7+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
8+
49
// Top-level code (i.e. implicit `main`) should be handled

test/TBD/protocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
99
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -enable-testing -O
1010

11+
// RUN: %empty-directory(%t)
12+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
13+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
14+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
15+
1116
public protocol Public {
1217
func publicMethod()
1318
associatedtype PublicAT

test/TBD/specialization.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
// RUN: %target-swift-frontend -emit-ir -o/dev/null -O -validate-tbd-against-ir=all -enable-testing %s
1010
// RUN: %target-swift-frontend -emit-ir -o/dev/null -O -validate-tbd-against-ir=all -enable-resilience -enable-testing %s
1111

12+
// RUN: %empty-directory(%t)
13+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
14+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
15+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
16+
1217
// rdar://problem/40738913
1318

1419
open class Foo {

test/TBD/struct.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-testing -O
88
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s -enable-resilience -enable-testing -O
99

10+
// RUN: %empty-directory(%t)
11+
// RUN: %target-swift-frontend -typecheck -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/typecheck.tbd
12+
// RUN: %target-swift-frontend -emit-ir -parse-as-library -module-name test %s -emit-tbd -emit-tbd-path %t/emit-ir.tbd
13+
// RUN: diff -u %t/typecheck.tbd %t/emit-ir.tbd
14+
1015
public struct StructPublicNothing {}
1116

1217
public struct StructPublicInit {

0 commit comments

Comments
 (0)