diff --git a/include/swift/AST/ModuleLoader.h b/include/swift/AST/ModuleLoader.h index e350d9f55e5b7..3b7e6b30cfa2b 100644 --- a/include/swift/AST/ModuleLoader.h +++ b/include/swift/AST/ModuleLoader.h @@ -173,6 +173,7 @@ struct InterfaceSubContextDelegate { StringRef interfacePath, StringRef outputPath, SourceLoc diagLoc, + bool silenceErrors, llvm::function_ref action) = 0; virtual ~InterfaceSubContextDelegate() = default; diff --git a/include/swift/Frontend/ModuleInterfaceLoader.h b/include/swift/Frontend/ModuleInterfaceLoader.h index aac73a8c7dd1b..acce6532451b2 100644 --- a/include/swift/Frontend/ModuleInterfaceLoader.h +++ b/include/swift/Frontend/ModuleInterfaceLoader.h @@ -523,6 +523,7 @@ struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate { StringRef interfacePath, StringRef outputPath, SourceLoc diagLoc, + bool silenceErrors, llvm::function_ref action) override; ~InterfaceSubContextDelegateImpl() = default; diff --git a/lib/Frontend/ModuleInterfaceBuilder.cpp b/lib/Frontend/ModuleInterfaceBuilder.cpp index c6f600d4bd16f..dc9b9c5b3ed3a 100644 --- a/lib/Frontend/ModuleInterfaceBuilder.cpp +++ b/lib/Frontend/ModuleInterfaceBuilder.cpp @@ -330,6 +330,7 @@ bool ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal( SubError = (bool)subASTDelegate.runInSubCompilerInstance( moduleName, interfacePath, OutPath, diagnosticLoc, + silenceInterfaceDiagnostics, [&](SubCompilerInstanceInfo &info) { auto EBuilder = ExplicitModuleInterfaceBuilder( *info.Instance, rebuildDiags, sourceMgr, moduleCachePath, backupInterfaceDir, diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index bf01b1828a0b9..687408626219c 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1724,7 +1724,8 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName, SourceLoc diagLoc, llvm::function_ref, ArrayRef, StringRef)> action) { - return runInSubCompilerInstance(moduleName, interfacePath, outputPath, diagLoc, + return runInSubCompilerInstance(moduleName, interfacePath, outputPath, + diagLoc, /*silenceErrors=*/false, [&](SubCompilerInstanceInfo &info){ return action(info.Instance->getASTContext(), info.Instance->getMainModule(), @@ -1739,6 +1740,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName, StringRef interfacePath, StringRef outputPath, SourceLoc diagLoc, + bool silenceErrors, llvm::function_ref action) { // We are about to mess up the compiler invocation by using the compiler // arguments in the textual interface file. So copy to use a new compiler @@ -1833,7 +1835,8 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName, subInstance.getSourceMgr().setFileSystem(SM.getFileSystem()); ForwardingDiagnosticConsumer FDC(*Diags); - subInstance.addDiagnosticConsumer(&FDC); + if (!silenceErrors) + subInstance.addDiagnosticConsumer(&FDC); std::string InstanceSetupError; if (subInstance.setup(subInvocation, InstanceSetupError)) { return std::make_error_code(std::errc::not_supported); diff --git a/test/Index/index_system_modules_swiftinterfaces.swift b/test/Index/index_system_modules_swiftinterfaces.swift index c9834d6f12919..8225bd1642035 100644 --- a/test/Index/index_system_modules_swiftinterfaces.swift +++ b/test/Index/index_system_modules_swiftinterfaces.swift @@ -55,9 +55,9 @@ // RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD %s /// We don't expect so see the swiftinterface error for indexing -// BROKEN-BUILD: indexing system module {{.*}} skipping // BROKEN-BUILD-NOT: error // BROKEN-BUILD-NOT: breaking_the_swifinterface +// BROKEN-BUILD: indexing system module {{.*}} skipping /// We don't expect SystemModule to be indexed with a broken swiftinterface // RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=BROKEN-UNIT %s