mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
embedded: avoid false error "Deinit of non-copyable type not visible in the current module" in SourceKit
As SourceKit explicitly disables WMO, silence the diagnostic in this case (but leave it enabled for explicit non-WMO builds otherwise). rdar://150596807
This commit is contained in:
@@ -137,11 +137,17 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ modu
|
||||
// We need to de-virtualize deinits of non-copyable types to be able to specialize the deinitializers.
|
||||
case let destroyValue as DestroyValueInst:
|
||||
if !devirtualizeDeinits(of: destroyValue, simplifyCtxt) {
|
||||
context.diagnosticEngine.diagnose(destroyValue.location.sourceLoc, .deinit_not_visible)
|
||||
// If invoked from SourceKit avoid reporting false positives when WMO is turned off for indexing purposes.
|
||||
if moduleContext.enableWMORequiredDiagnostics {
|
||||
context.diagnosticEngine.diagnose(destroyValue.location.sourceLoc, .deinit_not_visible)
|
||||
}
|
||||
}
|
||||
case let destroyAddr as DestroyAddrInst:
|
||||
if !devirtualizeDeinits(of: destroyAddr, simplifyCtxt) {
|
||||
context.diagnosticEngine.diagnose(destroyAddr.location.sourceLoc, .deinit_not_visible)
|
||||
// If invoked from SourceKit avoid reporting false positives when WMO is turned off for indexing purposes.
|
||||
if moduleContext.enableWMORequiredDiagnostics {
|
||||
context.diagnosticEngine.diagnose(destroyAddr.location.sourceLoc, .deinit_not_visible)
|
||||
}
|
||||
}
|
||||
|
||||
case let iem as InitExistentialMetatypeInst:
|
||||
|
||||
@@ -16,6 +16,11 @@ func foo() {
|
||||
bar(Int.self)
|
||||
}
|
||||
|
||||
func testNonCopyable() {
|
||||
let nc = NonCopyable()
|
||||
nc.doSomething()
|
||||
}
|
||||
|
||||
@main
|
||||
struct Main {
|
||||
var someClass = SomeClass()
|
||||
@@ -31,6 +36,11 @@ final class SomeClass {}
|
||||
|
||||
func bar<T>(_ T: T.Type) {}
|
||||
|
||||
struct NonCopyable : ~Copyable {
|
||||
func doSomething() {}
|
||||
deinit {}
|
||||
}
|
||||
|
||||
// CHECK: {
|
||||
// CHECK-NEXT: key.diagnostics: [
|
||||
// CHECK-NEXT: ]
|
||||
|
||||
Reference in New Issue
Block a user