mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The ComputeEffects pass derives escape information for function arguments and adds those effects in the function. This needs a lot of changes in check-lines in the tests, because the effects are printed in SIL
40 lines
991 B
Swift
40 lines
991 B
Swift
// RUN: %target-swift-emit-sil -Xllvm -sil-full-demangle -O %s | %FileCheck %s
|
|
|
|
// The second run tests is it can be compiled without crashes.
|
|
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -O -S %s
|
|
|
|
private class A {
|
|
func foo() -> Int { return 0 }
|
|
}
|
|
|
|
// CHECK-LABEL: deinit_in_vtable.(A in {{.*}}).__deallocating_deinit
|
|
// CHECK: sil private {{.*}}@[[A:.*]] :
|
|
|
|
private class B : A {
|
|
override func foo() -> Int { return 1 }
|
|
}
|
|
|
|
// CHECK-LABEL: deinit_in_vtable.(B in {{.*}}).__deallocating_deinit
|
|
// CHECK: sil private {{.*}}@[[B:.*]] :
|
|
|
|
@inline(never)
|
|
private func testfunc(_ a: A) -> Int {
|
|
return a.foo()
|
|
}
|
|
|
|
public func testmain() {
|
|
testfunc(B())
|
|
}
|
|
|
|
// Check if the deallocating destructors are listed in the vtable.
|
|
// This is required so that the are not removed (if not public) by dead
|
|
// function elimination
|
|
|
|
// CHECK-LABEL: sil_vtable A
|
|
// CHECK: A.deinit!deallocator: @[[A]]
|
|
|
|
// CHECK-LABEL: sil_vtable B
|
|
// CHECK-NOT: A.deinit
|
|
// CHECK: B.deinit!deallocator: @[[B]]
|
|
|