-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
| Bugzilla Link | 9486 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @belkadan,@tkremenek |
Extended Description
We have code like the following. It looks up a function pointer, and if NULL calls -doesNotRecognizeSelector:. Otherwise, it may or may not call it. clang-sa from trunk r127704 doesn't realize that the NULL pointer path can't be called and warns:
Called function pointer is null (null dereference)
This is easily avoided with attribute((analyzer_noreturn)), but it might be nice to have this method flagged as 'no return' automatically.
-
(void)setValue:(id)value forKey:(NSString *)key;
{
ODOProperty *prop = [[self->_objectID entity] propertyNamed:key];
if (!prop) {
[super setValue:value forKey:key];
return;
}// We only prevent write access via the generic KVC method for now. The issue is that we want to allow a class to redefined a property as writable internally if it wants, so it should be able to use 'self.foo = value' (going through the dynamic or any self-defined method). But subclasses could still -setValue:forKey: and get away with it w/o a warning. This does prevent the class itself from using generic KVC, but hopefully that is rare enough for this to be a good tradeoff.
struct _ODOPropertyFlags flags = ODOPropertyFlags(prop);
if (flags.calculated)
OBRejectInvalidCall(self, _cmd, @"Attempt to -setValue:forKey: on the calculated key '%@'.", key);ODOPropertySetter setter = ODOPropertySetterImpl(prop);
SEL sel = ODOPropertySetterSelector(prop);
if (!setter) {
// We have a property but no setter; presumably it is read-only.
[self doesNotRecognizeSelector:sel];
}// Avoid looking up the property again
if (setter == ODOSetterForUnknownOffset)
ODODynamicSetValueForProperty(self, sel, prop, value);
else
setter(self, sel, value);
}