mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This prevents the linker from trying to emit relative relocations to locally-defined public symbols into dynamic libraries, which gives ld.so heartache.
59 lines
1.4 KiB
Swift
59 lines
1.4 KiB
Swift
// RUN: %target-swift-frontend -primary-file %s -emit-ir | FileCheck %s
|
|
|
|
// Test if all methods which go into a vtable have at least the visibility of its class.
|
|
// Reason: Derived classes from "outside" still have to put the less visible base members
|
|
// into their vtables.
|
|
|
|
class Base {
|
|
// CHECK: define hidden void @_TFC14method_linkage4Base{{.*}}3foofT_T_
|
|
@inline(never)
|
|
private func foo() {
|
|
}
|
|
|
|
// CHECK: define internal void @_TFC14method_linkage4Base{{.*}}3barfT_T_
|
|
@inline(never)
|
|
private final func bar() {
|
|
}
|
|
|
|
// CHECK: define hidden void @_TFC14method_linkage4Base{{.*}}5otherfT_T_
|
|
@inline(never)
|
|
private func other() {
|
|
}
|
|
}
|
|
class Derived : Base {
|
|
// CHECK: define hidden void @_TFC14method_linkage7Derived{{.*}}3foofT_T_
|
|
@inline(never)
|
|
private final override func foo() {
|
|
}
|
|
}
|
|
|
|
extension Base {
|
|
// CHECK: define internal void @_TFC14method_linkage4Base{{.*}}7extfuncfT_T_
|
|
@inline(never)
|
|
private func extfunc() {
|
|
}
|
|
}
|
|
|
|
public class PublicClass {
|
|
// CHECK: define{{( protected)?}} void @_TFC14method_linkage11PublicClass{{.*}}4pfoofT_T_
|
|
@inline(never)
|
|
private func pfoo() {
|
|
}
|
|
|
|
// CHECK: define{{( protected)?}} void @_TFC14method_linkage11PublicClass4pbarfT_T_
|
|
@inline(never)
|
|
internal func pbar() {
|
|
}
|
|
}
|
|
|
|
// Just in case anyone wants to delete unused methods...
|
|
func callit(b: Base, p: PublicClass) {
|
|
b.foo()
|
|
b.bar()
|
|
b.other()
|
|
b.extfunc()
|
|
p.pfoo()
|
|
p.pbar()
|
|
}
|
|
|