Revision d9b2fe601b793741633d77606c4618e63612fbb2 authored by Chris Lattner on 10 January 2016, 04:17:56 UTC, committed by Chris Lattner on 10 January 2016, 04:17:56 UTC
1 parent 0fbbf59
method_linkage.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 void @_TFC14method_linkage11PublicClass{{.*}}4pfoofT_T_
@inline(never)
private func pfoo() {
}
// CHECK: define 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()
}
Computing file changes ...