Skip to content

Commit df563ba

Browse files
authored
Merge pull request swiftlang#40414 from drodriguez/tbd-validation-modules
2 parents 4c5cc21 + 8a0e512 commit df563ba

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,10 +1379,14 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
13791379
// may have serialized hand-crafted SIL definitions that are invisible to
13801380
// TBDGen as it is an AST-only traversal.
13811381
if (auto *mod = MSF.dyn_cast<ModuleDecl *>()) {
1382-
return llvm::none_of(mod->getFiles(), [](const FileUnit *File) -> bool {
1382+
bool hasSIB = llvm::any_of(mod->getFiles(), [](const FileUnit *File) -> bool {
13831383
auto SASTF = dyn_cast<SerializedASTFile>(File);
13841384
return SASTF && SASTF->isSIB();
13851385
});
1386+
1387+
if (hasSIB) {
1388+
return false;
1389+
}
13861390
}
13871391

13881392
// "Default" mode's behavior varies if using a debug compiler.

test/TBD/sib-module.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swiftc_driver -emit-sib -module-name mysibmodule %s -o - | %target-swiftc_driver -emit-module -module-name mysibmodule -o %t/mysibmodule.swiftmodule -
4+
5+
/// Since -validate-tbd-against-ir=default, TBD validation is not done since the module has a SIB file
6+
// RUN: %target-swift-frontend -emit-sil %t/mysibmodule.swiftmodule | %FileCheck %s
7+
8+
// RUN: %target-swiftc_driver -emit-module -module-name mynonsibmodule -o %t/mynonsibmodule.swiftmodule %s
9+
10+
/// Since -validate-tbd-against-ir=default, TBD validation is done or not depending on the build configuration
11+
// RUN: %target-swift-frontend -emit-sil %t/mynonsibmodule.swiftmodule | %FileCheck %s
12+
13+
public class MyClass {
14+
var x : Int
15+
16+
public init(input : Int) {
17+
x = 2 * input
18+
}
19+
20+
public func do_something(input : Int) -> Int {
21+
return x * input
22+
}
23+
}
24+
25+
// CHECK: class MyClass

0 commit comments

Comments
 (0)