[LLVMbugs] [Bug 15270] New: The static analyzer does not understand that CFSTR is never NULL

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 14 19:47:16 PST 2013


            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: kremenek at apple.com
          Reporter: peter at stairways.com.au
                CC: llvmbugs at cs.uiuc.edu
    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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130215/673d3b5f/attachment.html>

More information about the llvm-bugs mailing list