|
| 1 | +// Test that Objective-C class and selector references inlined across crates |
| 2 | +// get defined in this CGU but non-inline references don't. |
| 3 | + |
| 4 | +// ignore-tidy-linelength |
| 5 | +//@ aux-build: darwin_objc_aux.rs |
| 6 | +//@ revisions: x86_64_macos aarch64_macos |
| 7 | +//@ [x86_64_macos] only-x86_64-apple-darwin |
| 8 | +//@ [aarch64_macos] only-aarch64-apple-darwin |
| 9 | + |
| 10 | +#![crate_type = "lib"] |
| 11 | +#![feature(darwin_objc)] |
| 12 | + |
| 13 | +use std::os::darwin::objc; |
| 14 | + |
| 15 | +extern crate darwin_objc_aux as aux; |
| 16 | + |
| 17 | +#[no_mangle] |
| 18 | +pub fn get_object_class() -> objc::Class { |
| 19 | + aux::inline_get_object_class() |
| 20 | +} |
| 21 | + |
| 22 | +#[no_mangle] |
| 23 | +pub fn get_alloc_selector() -> objc::SEL { |
| 24 | + aux::inline_get_alloc_selector() |
| 25 | +} |
| 26 | + |
| 27 | +#[no_mangle] |
| 28 | +pub fn get_string_class() -> objc::Class { |
| 29 | + aux::never_inline_get_string_class() |
| 30 | +} |
| 31 | + |
| 32 | +#[no_mangle] |
| 33 | +pub fn get_init_selector() -> objc::SEL { |
| 34 | + aux::never_inline_get_init_selector() |
| 35 | +} |
| 36 | + |
| 37 | +// CHECK: %struct._class_t = type { ptr, ptr, ptr, ptr, ptr } |
| 38 | + |
| 39 | +// CHECK: @"OBJC_CLASS_$_NSObject" = external global %struct._class_t |
| 40 | +// CHECK: @"OBJC_CLASSLIST_REFERENCES_$_.{{[0-9]+}}" = internal global ptr @"OBJC_CLASS_$_NSObject", section "__DATA,__objc_classrefs,regular,no_dead_strip", align 8 |
| 41 | + |
| 42 | +// CHECK: @OBJC_METH_VAR_NAME_.{{[0-9]+}} = private unnamed_addr constant [6 x i8] c"alloc\00", section "__TEXT,__objc_methname,cstring_literals", align 1 |
| 43 | +// CHECK: @OBJC_SELECTOR_REFERENCES_.{{[0-9]+}} = internal externally_initialized global ptr @OBJC_METH_VAR_NAME_.{{[0-9]+}}, section "__DATA,__objc_selrefs,literal_pointers,no_dead_strip", align 8 |
| 44 | + |
| 45 | +// CHECK-NOT: @"OBJC_CLASS_$_NSString" = external global %struct._class_t |
| 46 | +// CHECK-NOT: @"OBJC_CLASSLIST_REFERENCES_$_.{{[0-9]+}}" = internal global ptr @"OBJC_CLASS_$_NSString" |
| 47 | + |
| 48 | +// CHECK-NOT: @OBJC_METH_VAR_NAME_.{{[0-9]+}} = private unnamed_addr constant [5 x i8] c"init\00" |
| 49 | +// CHECK-NOT: @OBJC_SELECTOR_REFERENCES_.{{[0-9]+}} = internal externally_initialized global ptr @OBJC_METH_VAR_NAME_.{{[0-9]+}} |
| 50 | + |
| 51 | +// CHECK: load ptr, ptr @"OBJC_CLASSLIST_REFERENCES_$_.{{[0-9]+}}", align 8 |
| 52 | +// CHECK: load ptr, ptr @OBJC_SELECTOR_REFERENCES_.{{[0-9]+}}, align 8 |
| 53 | + |
| 54 | +// CHECK: !{{[0-9]+}} = !{i32 1, !"Objective-C Version", i32 2} |
| 55 | +// CHECK: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Version", i32 0} |
| 56 | +// CHECK: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"} |
| 57 | +// CHECK-NOT: !{{[0-9]+}} = !{i32 1, !"Objective-C Is Simulated", i32 32} |
| 58 | +// CHECK: !{{[0-9]+}} = !{i32 1, !"Objective-C Class Properties", i32 64} |
0 commit comments