[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.
This commit is contained in:
Alexis Laferrière
2022-11-08 08:28:59 -08:00
parent f184504d62
commit 4a582806dc
5 changed files with 9 additions and 3 deletions

View File

@@ -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(),
@@ -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
@@ -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);