[ModuleInterface] Implement silencing errors on rebuild with a new engine

This commit is contained in:
Alexis Laferrière
2022-10-31 07:48:43 -07:00
parent 82f63b090e
commit 5d59a8fe16
2 changed files with 33 additions and 1 deletions

View File

@@ -320,11 +320,19 @@ bool ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(
llvm::RestorePrettyStackState(savedInnerPrettyStackState);
};
Optional<DiagnosticEngine> localDiags;
DiagnosticEngine *rebuildDiags = diags;
if (silenceInterfaceDiagnostics) {
// To silence diagnostics, use a local temporary engine.
localDiags.emplace(sourceMgr);
rebuildDiags = &*localDiags;
}
SubError = (bool)subASTDelegate.runInSubCompilerInstance(
moduleName, interfacePath, OutPath, diagnosticLoc,
[&](SubCompilerInstanceInfo &info) {
auto EBuilder = ExplicitModuleInterfaceBuilder(
*info.Instance, diags, sourceMgr, moduleCachePath, backupInterfaceDir,
*info.Instance, rebuildDiags, sourceMgr, moduleCachePath, backupInterfaceDir,
prebuiltCachePath, ABIDescriptorPath, extraDependencies, diagnosticLoc,
dependencyTracker);
return EBuilder.buildSwiftModuleFromInterface(

View File

@@ -66,6 +66,7 @@
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s
// BROKEN-RECORD-NOT: function/Swift | systemFunc()
/// Subsequent builds won't attempt to index the broken swiftinterface again
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
@@ -78,6 +79,20 @@
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD-2 --allow-empty %s
// BROKEN-BUILD-2-NOT: indexing system module
/// Local errors should be preserved even when indexing against a broken swiftinterface
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: not %target-swift-frontend -typecheck -parse-stdlib \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %t/ClientWithError.swift 2> %t/client-with-error.err
// RUN: cat %t/client-with-error.err | %FileCheck -check-prefix=WITH-ERROR %s
// WITH-ERROR: cannot convert return expression of type 'U' to return type 'T'
//--- SecretModule.swift
public struct SecretType {}
@@ -92,3 +107,12 @@ func leakyFunc(_ a: SecretType) { }
import SystemModule
public func clientFunc() {}
//--- ClientWithError.swift
import SystemModule
public func clientFunc() {}
struct T {}
struct U {}
func f() -> T { return U() }