Skip to content

Commit 339d214

Browse files
authored
Merge pull request #70129 from bnbarham/index-salvage
[Frontend] Ensure constraint solving runs salvaging
2 parents 86adc6f + eba98a6 commit 339d214

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,14 @@ bool ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(
329329
llvm::RestorePrettyStackState(savedInnerPrettyStackState);
330330
};
331331

332+
NullDiagnosticConsumer noopConsumer;
332333
llvm::Optional<DiagnosticEngine> localDiags;
333334
DiagnosticEngine *rebuildDiags = diags;
334335
if (silenceInterfaceDiagnostics) {
335336
// To silence diagnostics, use a local temporary engine.
336337
localDiags.emplace(sourceMgr);
337338
rebuildDiags = &*localDiags;
339+
rebuildDiags->addConsumer(noopConsumer);
338340
}
339341

340342
SubError = (bool)subASTDelegate.runInSubCompilerInstance(

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,13 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
20072007
subInstance.getSourceMgr().setFileSystem(SM.getFileSystem());
20082008

20092009
ForwardingDiagnosticConsumer FDC(*Diags);
2010-
if (!silenceErrors)
2010+
NullDiagnosticConsumer noopConsumer;
2011+
if (!silenceErrors) {
20112012
subInstance.addDiagnosticConsumer(&FDC);
2013+
} else {
2014+
subInstance.addDiagnosticConsumer(&noopConsumer);
2015+
}
2016+
20122017
std::string InstanceSetupError;
20132018
if (subInstance.setup(subInvocation, InstanceSetupError)) {
20142019
return std::make_error_code(std::errc::not_supported);

test/Index/index_system_modules_swiftinterfaces.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
/// Index a client reading from a broken swiftinterface
114114
// RUN: %empty-directory(%t/idx)
115115
// RUN: %empty-directory(%t/modulecache)
116-
// RUN: echo "breaking_the_swifinterface" >> %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface
116+
// RUN: echo "breaking_the_swiftinterface" >> %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface
117117

118118
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
119119
// RUN: -index-system-modules \
@@ -128,7 +128,7 @@
128128

129129
/// We don't expect to see the swiftinterface error for indexing
130130
// BROKEN-BUILD-NOT: error
131-
// BROKEN-BUILD-NOT: breaking_the_swifinterface
131+
// BROKEN-BUILD-NOT: breaking_the_swiftinterface
132132
// BROKEN-BUILD: indexing system module {{.*}} skipping
133133

134134
/// We don't expect SystemModule to be indexed with a broken swiftinterface
@@ -178,6 +178,19 @@ import SystemDepB
178178
public func systemFunc() {}
179179
func leakyFunc(_ a: SecretType) {}
180180

181+
// Currently requires salvaging, which we need to make sure runs when the
182+
// interface is rebuilt (as it produces a solution), we'll crash if it isn't.
183+
public struct SysA { public init() {} }
184+
public struct SysB { public init() {} }
185+
@available(macOS, unavailable)
186+
public func forceDisjunction() -> SysA { return SysA() }
187+
public func forceDisjunction() -> SysB { return SysB() }
188+
@available(macOS, unavailable)
189+
@inlinable
190+
public func requireSalvage() -> SysA {
191+
return forceDisjunction()
192+
}
193+
181194
//--- SystemDepA.swift
182195
import SystemDepCommon
183196
public func systemDepAFunc() {}

0 commit comments

Comments
 (0)