@@ -912,6 +912,28 @@ lookup_protocol_in_reflist (tree rproto_list, tree lproto)
912
912
return 0;
913
913
}
914
914
915
+ /* APPLE LOCAL begin radar 7865106 */
916
+ static bool objc_class_weak_import(tree class)
917
+ {
918
+ tree chain;
919
+ gcc_assert (class && TREE_CODE (class) == CLASS_INTERFACE_TYPE);
920
+ for (chain = CLASS_ATTRIBUTES (class); chain; chain = TREE_CHAIN (chain))
921
+ if (is_attribute_p ("weak_import", TREE_PURPOSE (chain)))
922
+ return true;
923
+ return false;
924
+ }
925
+
926
+ static char*
927
+ objc_build_weak_reference_internal_classname (tree ident, bool metaclass)
928
+ {
929
+ static char string[BUFSIZE];
930
+ sprintf (string, ".weak_reference %s_%s", !metaclass ? "_OBJC_CLASS_$"
931
+ : "_OBJC_METACLASS_$",
932
+ IDENTIFIER_POINTER (ident));
933
+ return string;
934
+ }
935
+ /* APPLE LOCAL end radar 7865106 */
936
+
915
937
void
916
938
/* APPLE LOCAL radar 4548636 */
917
939
objc_start_class_interface (tree class, tree super_class, tree protos, tree attributes)
@@ -923,6 +945,17 @@ objc_start_class_interface (tree class, tree super_class, tree protos, tree attr
923
945
CLASS_ATTRIBUTES (objc_interface_context) = attributes;
924
946
objc_warn_on_class_attributes (objc_interface_context, false);
925
947
/* APPLE LOCAL end radar 4548636 */
948
+ /* APPLE LOCAL begin radar 7865106 */
949
+ if (flag_objc_abi == 2 && objc_class_weak_import(objc_interface_context)) {
950
+ const char * name =
951
+ objc_build_weak_reference_internal_classname(CLASS_NAME(objc_interface_context) , 0);
952
+ tree asm_str = build_string(strlen(name), name);
953
+ cgraph_add_asm_node(asm_str);
954
+ name = objc_build_weak_reference_internal_classname(CLASS_NAME(objc_interface_context) , 1);
955
+ asm_str = build_string(strlen(name), name);
956
+ cgraph_add_asm_node(asm_str);
957
+ }
958
+ /* APPLE LOCAL end radar 7865106 */
926
959
objc_public_flag = 0;
927
960
}
928
961
@@ -14756,6 +14789,10 @@ objc_warn_on_class_attributes (tree class, bool use)
14756
14789
else if (is_attribute_p ("objc_exception", TREE_PURPOSE (chain)))
14757
14790
;
14758
14791
/* APPLE LOCAL end radar 5008110 */
14792
+ /* APPLE LOCAL begin radar 7865106 */
14793
+ else if (is_attribute_p ("weak_import", TREE_PURPOSE (chain)))
14794
+ ;
14795
+ /* APPLE LOCAL end radar 7865106 */
14759
14796
else if (!use)
14760
14797
warning (0, "attribute %s is unknown - ignored",
14761
14798
IDENTIFIER_POINTER (TREE_PURPOSE (chain)));
0 commit comments