http://llvm.org/bugs/show_bug.cgi?id=15270

            Bug ID: 15270
           Summary: The static analyzer does not understand that CFSTR is
                    never NULL
           Product: clang
           Version: 3.2
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

This code reports an issue with value potentially being NULL, but if CFSTR is
known to not be NULL, then that assert makes it is clear result cannot be NULL
in this case.

Ironically, it is the assert testing for result != NULL that sets off the
analyzer in this case, but if the analyzer knew that CFSTR was never NULL, then
it would have no difficulty determining that result was never NULL in this
case.

inline void
CFDictionaryGet( CFStringRef def, CFStringRef& result )
{
    result = def;
    assert( (result != NULL) || (def == NULL) ); // Clearly indicates that
result cannot be NULL if def is not NULL
}


void Test2()
{
    CFStringRef value;
    CFDictionaryGet( CFSTR("Variable"), value );
    CFRetain( value ); // Erroneously detects as value might be NULL
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to