Skip to content

Commit bca3ae4

Browse files
committed
[Explicit Modules] Fix detection of a type-checking action in 'ExplicitModuleInterfaceBuilder'
When we run an interface verification tasks with Explicit module builds, we directly invoke a '-explicit-interface-module-build' instance with a '-typecheck-module-from-interface' action. So the builder needs to recognize this as a typechecking invocation. In implicit builds, this gets lowered into a separate compiler sub-instance with a '-typecheck' action, for some reason. resolves rdar://115565571
1 parent 451b5fd commit bca3ae4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct ErrorDowngradeConsumerRAII: DiagnosticConsumer {
9090
for (auto *consumer: allConsumers) {
9191
consumer->handleDiagnostic(SM, localInfo);
9292
}
93+
Diag.resetHadAnyError();
9394
}
9495
}
9596
};
@@ -215,7 +216,8 @@ std::error_code ExplicitModuleInterfaceBuilder::buildSwiftModuleFromInterface(
215216
}
216217
FrontendOptions &FEOpts = Invocation.getFrontendOptions();
217218
bool isTypeChecking =
218-
(FEOpts.RequestedAction == FrontendOptions::ActionType::Typecheck);
219+
(FEOpts.RequestedAction == FrontendOptions::ActionType::Typecheck ||
220+
FEOpts.RequestedAction == FrontendOptions::ActionType::TypecheckModuleFromInterface);
219221
const auto &InputInfo = FEOpts.InputsAndOutputs.firstInput();
220222
StringRef InPath = InputInfo.getFileName();
221223

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo "// swift-interface-format-version: 1.0" > %t/Main.swiftinterface
3+
// RUN: echo "// swift-module-flags: -module-name Foo" >> %t/Main.swiftinterface
4+
// RUN: echo "malfunctioned" >> %t/Main.swiftinterface
5+
6+
// Verify with '-downgrade-typecheck-interface-error'
7+
// RUN: %target-swift-frontend -typecheck-module-from-interface %t/Main.swiftinterface -module-name Foo -downgrade-typecheck-interface-error -explicit-interface-module-build 2>&1 | %FileCheck %s
8+
9+
// Verify with a blocklist
10+
// RUN: echo "---" > %t/blocklist.yml
11+
// RUN: echo "DowngradeInterfaceVerificationFailure:" >> %t/blocklist.yml
12+
// RUN: echo " ModuleName:" >> %t/blocklist.yml
13+
// RUN: echo " - Foo" >> %t/blocklist.yml
14+
// RUN: %target-swift-frontend -typecheck-module-from-interface %t/Main.swiftinterface -module-name Foo -blocklist-file %t/blocklist.yml -explicit-interface-module-build 2>&1 | %FileCheck %s
15+
16+
// CHECK: warning:
17+
// CHECK-NOT: error:

0 commit comments

Comments
 (0)