Add some debugging help for ARC-compilance.

main
David Chisnall 8 years ago
parent fe579e3f1a
commit bdc20a8bab

@ -56,6 +56,13 @@ static BOOL ownsMethod(Class cls, SEL sel)
return NO; return NO;
} }
#ifdef DEBUG_ARC_COMPAT
#define ARC_DEBUG_LOG(...) fprintf(stderr, __VA_LIST__)
#else
#define ARC_DEBUG_LOG(...) do {} while(0)
#endif
/** /**
* Checks whether the class implements memory management methods, and whether * Checks whether the class implements memory management methods, and whether
* they are safe to use with ARC. * they are safe to use with ARC.
@ -73,18 +80,21 @@ static void checkARCAccessors(Class cls)
struct objc_slot *slot = objc_get_slot(cls, retain); struct objc_slot *slot = objc_get_slot(cls, retain);
if ((NULL != slot) && !ownsMethod(slot->owner, isARC)) if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
{ {
ARC_DEBUG_LOG("%s does not support ARC correctly (implements retain)\n", cls->name);
objc_clear_class_flag(cls, objc_class_flag_fast_arc); objc_clear_class_flag(cls, objc_class_flag_fast_arc);
return; return;
} }
slot = objc_get_slot(cls, release); slot = objc_get_slot(cls, release);
if ((NULL != slot) && !ownsMethod(slot->owner, isARC)) if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
{ {
ARC_DEBUG_LOG("%s does not support ARC correctly (implements release)\n", cls->name);
objc_clear_class_flag(cls, objc_class_flag_fast_arc); objc_clear_class_flag(cls, objc_class_flag_fast_arc);
return; return;
} }
slot = objc_get_slot(cls, autorelease); slot = objc_get_slot(cls, autorelease);
if ((NULL != slot) && !ownsMethod(slot->owner, isARC)) if ((NULL != slot) && !ownsMethod(slot->owner, isARC))
{ {
ARC_DEBUG_LOG("%s does not support ARC correctly (implements autorelease)\n", cls->name);
objc_clear_class_flag(cls, objc_class_flag_fast_arc); objc_clear_class_flag(cls, objc_class_flag_fast_arc);
return; return;
} }

Loading…
Cancel
Save