Skip to content

Commit c42bdde

Browse files
authored
Merge pull request #61980 from xymus/index-fix-silencing-swiftinterface
[ModuleInterface] Fix silencing errors mode in swiftinterface rebuild
2 parents c4ebdeb + 4a58280 commit c42bdde

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
@@ -1725,7 +1725,8 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
17251725
SourceLoc diagLoc,
17261726
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
17271727
ArrayRef<StringRef>, StringRef)> action) {
1728-
return runInSubCompilerInstance(moduleName, interfacePath, outputPath, diagLoc,
1728+
return runInSubCompilerInstance(moduleName, interfacePath, outputPath,
1729+
diagLoc, /*silenceErrors=*/false,
17291730
[&](SubCompilerInstanceInfo &info){
17301731
return action(info.Instance->getASTContext(),
17311732
info.Instance->getMainModule(),
@@ -1740,6 +1741,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
17401741
StringRef interfacePath,
17411742
StringRef outputPath,
17421743
SourceLoc diagLoc,
1744+
bool silenceErrors,
17431745
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) {
17441746
// We are about to mess up the compiler invocation by using the compiler
17451747
// arguments in the textual interface file. So copy to use a new compiler
@@ -1834,7 +1836,8 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
18341836
subInstance.getSourceMgr().setFileSystem(SM.getFileSystem());
18351837

18361838
ForwardingDiagnosticConsumer FDC(*Diags);
1837-
subInstance.addDiagnosticConsumer(&FDC);
1839+
if (!silenceErrors)
1840+
subInstance.addDiagnosticConsumer(&FDC);
18381841
std::string InstanceSetupError;
18391842
if (subInstance.setup(subInvocation, InstanceSetupError)) {
18401843
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)