mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ModuleInterface] Implement silencing errors on rebuild with a new engine
This commit is contained in:
@@ -320,11 +320,19 @@ bool ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(
|
|||||||
llvm::RestorePrettyStackState(savedInnerPrettyStackState);
|
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(
|
SubError = (bool)subASTDelegate.runInSubCompilerInstance(
|
||||||
moduleName, interfacePath, OutPath, diagnosticLoc,
|
moduleName, interfacePath, OutPath, diagnosticLoc,
|
||||||
[&](SubCompilerInstanceInfo &info) {
|
[&](SubCompilerInstanceInfo &info) {
|
||||||
auto EBuilder = ExplicitModuleInterfaceBuilder(
|
auto EBuilder = ExplicitModuleInterfaceBuilder(
|
||||||
*info.Instance, diags, sourceMgr, moduleCachePath, backupInterfaceDir,
|
*info.Instance, rebuildDiags, sourceMgr, moduleCachePath, backupInterfaceDir,
|
||||||
prebuiltCachePath, ABIDescriptorPath, extraDependencies, diagnosticLoc,
|
prebuiltCachePath, ABIDescriptorPath, extraDependencies, diagnosticLoc,
|
||||||
dependencyTracker);
|
dependencyTracker);
|
||||||
return EBuilder.buildSwiftModuleFromInterface(
|
return EBuilder.buildSwiftModuleFromInterface(
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s
|
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s
|
||||||
// BROKEN-RECORD-NOT: function/Swift | systemFunc()
|
// 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: %target-swift-frontend -typecheck -parse-stdlib \
|
||||||
// RUN: -index-system-modules \
|
// RUN: -index-system-modules \
|
||||||
// RUN: -index-store-path %t/idx \
|
// RUN: -index-store-path %t/idx \
|
||||||
@@ -78,6 +79,20 @@
|
|||||||
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD-2 --allow-empty %s
|
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD-2 --allow-empty %s
|
||||||
// BROKEN-BUILD-2-NOT: indexing system module
|
// 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
|
//--- SecretModule.swift
|
||||||
public struct SecretType {}
|
public struct SecretType {}
|
||||||
|
|
||||||
@@ -92,3 +107,12 @@ func leakyFunc(_ a: SecretType) { }
|
|||||||
import SystemModule
|
import SystemModule
|
||||||
|
|
||||||
public func clientFunc() {}
|
public func clientFunc() {}
|
||||||
|
|
||||||
|
//--- ClientWithError.swift
|
||||||
|
|
||||||
|
import SystemModule
|
||||||
|
public func clientFunc() {}
|
||||||
|
|
||||||
|
struct T {}
|
||||||
|
struct U {}
|
||||||
|
func f() -> T { return U() }
|
||||||
|
|||||||
Reference in New Issue
Block a user