1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// RUN: %target-swift-emit-sil -I %S/Inputs -enable-experimental-cxx-interop %s | %FileCheck %s
// REQUIRES: swift_in_compiler
// CHECK: // clang name: WithStaticMember::staticMember
// CHECK: sil_global public_external @{{_ZN16WithStaticMember12staticMemberE|\?staticMember@WithStaticMember@@2HA}} : $Int32
// CHECK: // clang name: WithIncompleteStaticMember::selfMember
// CHECK: sil_global public_external @{{_ZN26WithIncompleteStaticMember10selfMemberE|\?selfMember@WithIncompleteStaticMember@@2V1@A}} : $WithIncompleteStaticMember
import StaticMemberVar
func readStaticMember() -> CInt {
return WithStaticMember.staticMember
}
// CHECK: sil hidden @$s4main16readStaticMembers5Int32VyF : $@convention(thin) () -> Int32
// CHECK: [[ADDR:%.*]] = global_addr @{{_ZN16WithStaticMember12staticMemberE|\?staticMember@WithStaticMember@@2HA}} : $*Int32
// CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[ADDR]] : $*Int32
// CHECK: [[VALUE:%.*]] = load [[ACCESS]] : $*Int32
// CHECK: return [[VALUE]] : $Int32
func writeStaticMember() {
WithStaticMember.staticMember = -1
}
// CHECK: sil hidden @$s4main17writeStaticMemberyyF : $@convention(thin) () -> ()
// CHECK: [[ADDR:%.*]] = global_addr @{{_ZN16WithStaticMember12staticMemberE|\?staticMember@WithStaticMember@@2HA}} : $*Int32
// CHECK: [[LIT:%.*]] = integer_literal $Builtin.Int32, -1
// CHECK: [[INT:%.*]] = struct $Int32 ([[LIT]] : $Builtin.Int32)
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[ADDR]] : $*Int32
// CHECK: store [[INT]] to [[ACCESS]] : $*Int32
func readSelfMember() -> WithIncompleteStaticMember {
return WithIncompleteStaticMember.selfMember
}
// CHECK: sil hidden @$s4main14readSelfMemberSo020WithIncompleteStaticD0VyF : $@convention(thin) () -> WithIncompleteStaticMember
// CHECK: [[ADDR:%.*]] = global_addr @{{_ZN26WithIncompleteStaticMember10selfMemberE|\?selfMember@WithIncompleteStaticMember@@2V1@A}} : $*WithIncompleteStaticMember
// CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[ADDR]] : $*WithIncompleteStaticMember
// CHECK: [[VALUE:%.*]] = load [[ACCESS]] : $*WithIncompleteStaticMember
// CHECK: return [[VALUE]] : $WithIncompleteStaticMember
func writeSelfMember(_ m: WithIncompleteStaticMember) {
WithIncompleteStaticMember.selfMember = m
}
// CHECK: sil hidden @$s4main15writeSelfMemberyySo020WithIncompleteStaticD0VF : $@convention(thin) (WithIncompleteStaticMember) -> ()
// CHECK: [[ADDR:%.*]] = global_addr @{{_ZN26WithIncompleteStaticMember10selfMemberE|\?selfMember@WithIncompleteStaticMember@@2V1@A}} : $*WithIncompleteStaticMember
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[ADDR]] : $*WithIncompleteStaticMember
// CHECK: store %0 to [[ACCESS]] : $*WithIncompleteStaticMember
//TODO fix undefined reference to `WithConstStaticMember::notDefined`.
// func readNotDefinedConstMember() -> CInt {
// return WithConstStaticMember.notDefined
// }
func readDefinedConstMember() -> CInt {
return WithConstStaticMember.defined
}
// CHECK: sil hidden @$s4main22readDefinedConstMembers5Int32VyF : $@convention(thin) () -> Int32
// CHECK: [[ADDR:%.*]] = global_addr @{{_ZN21WithConstStaticMember7definedE|\?defined@WithConstStaticMember@@2HB}} : $*Int32
// CHECK: [[VALUE:%.*]] = load [[ADDR]] : $*Int32
// CHECK: return [[VALUE]] : $Int32
func readDefinedOutOfLineConstMember() -> CInt {
return WithConstStaticMember.definedOutOfLine
}
|