Skip to content

Commit 4a58280

Browse files
committed
[ModuleInterface] Fix silencing errors mode in swiftinterface rebuild
Make sure we disable forwarding diagnostics from the underlying instance when building a swiftinterface in silencing errors mode.
1 parent f184504 commit 4a58280

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

include/swift/AST/ModuleLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct InterfaceSubContextDelegate {
173173
StringRef interfacePath,
174174
StringRef outputPath,
175175
SourceLoc diagLoc,
176+
bool silenceErrors,
176177
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) = 0;
177178

178179
virtual ~InterfaceSubContextDelegate() = default;

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
523523
StringRef interfacePath,
524524
StringRef outputPath,
525525
SourceLoc diagLoc,
526+
bool silenceErrors,
526527
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) override;
527528

528529
~InterfaceSubContextDelegateImpl() = default;

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ bool ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(
330330

331331
SubError = (bool)subASTDelegate.runInSubCompilerInstance(
332332
moduleName, interfacePath, OutPath, diagnosticLoc,
333+
silenceInterfaceDiagnostics,
333334
[&](SubCompilerInstanceInfo &info) {
334335
auto EBuilder = ExplicitModuleInterfaceBuilder(
335336
*info.Instance, rebuildDiags, sourceMgr, moduleCachePath, backupInterfaceDir,

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,8 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
17241724
SourceLoc diagLoc,
17251725
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
17261726
ArrayRef<StringRef>, StringRef)> action) {
1727-
return runInSubCompilerInstance(moduleName, interfacePath, outputPath, diagLoc,
1727+
return runInSubCompilerInstance(moduleName, interfacePath, outputPath,
1728+
diagLoc, /*silenceErrors=*/false,
17281729
[&](SubCompilerInstanceInfo &info){
17291730
return action(info.Instance->getASTContext(),
17301731
info.Instance->getMainModule(),
@@ -1739,6 +1740,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
17391740
StringRef interfacePath,
17401741
StringRef outputPath,
17411742
SourceLoc diagLoc,
1743+
bool silenceErrors,
17421744
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) {
17431745
// We are about to mess up the compiler invocation by using the compiler
17441746
// arguments in the textual interface file. So copy to use a new compiler
@@ -1833,7 +1835,8 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
18331835
subInstance.getSourceMgr().setFileSystem(SM.getFileSystem());
18341836

18351837
ForwardingDiagnosticConsumer FDC(*Diags);
1836-
subInstance.addDiagnosticConsumer(&FDC);
1838+
if (!silenceErrors)
1839+
subInstance.addDiagnosticConsumer(&FDC);
18371840
std::string InstanceSetupError;
18381841
if (subInstance.setup(subInvocation, InstanceSetupError)) {
18391842
return std::make_error_code(std::errc::not_supported);

test/Index/index_system_modules_swiftinterfaces.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD %s
5656

5757
/// We don't expect so see the swiftinterface error for indexing
58-
// BROKEN-BUILD: indexing system module {{.*}} skipping
5958
// BROKEN-BUILD-NOT: error
6059
// BROKEN-BUILD-NOT: breaking_the_swifinterface
60+
// BROKEN-BUILD: indexing system module {{.*}} skipping
6161

6262
/// We don't expect SystemModule to be indexed with a broken swiftinterface
6363
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=BROKEN-UNIT %s

0 commit comments

Comments
 (0)