[LLVMbugs] [Bug 9486] New: -doesNotRecognizeSelector: not flagged as being "no return"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 15 15:02:41 PDT 2011


           Summary: -doesNotRecognizeSelector: not flagged as being "no
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: tjw at omnigroup.com
                CC: llvmbugs at cs.uiuc.edu

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];

    // 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);
        setter(self, sel, value);

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list