Skip to content

[ModuleInterface] Fix silencing errors mode in swiftinterface rebuild #61980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/AST/ModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct InterfaceSubContextDelegate {
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
bool silenceErrors,
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) = 0;

virtual ~InterfaceSubContextDelegate() = default;
Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/ModuleInterfaceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
bool silenceErrors,
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) override;

~InterfaceSubContextDelegateImpl() = default;
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/ModuleInterfaceBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,8 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
SourceLoc diagLoc,
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
ArrayRef<StringRef>, 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(),
Expand All @@ -1739,6 +1740,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
bool silenceErrors,
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> 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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/Index/index_system_modules_swiftinterfaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down