[LLVMbugs] [Bug 7240] New: The analyser gets the documented pattern for dealing with NSURLConnection wrong.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 27 04:01:20 PDT 2010


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

           Summary: The analyser gets the documented pattern for dealing
                    with NSURLConnection wrong.
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: iamleeg at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Summary: Apple document example asynchronous use of NSURLConnections as:
 - create an NSURLConnection object in one method
 - when you get a callback indicating completion of the connection, release it.

The static analyser (correctly) reports that the NSURLConnection object created
in the first method has a retain count of +1 by the end of the method, but in
this case we know that the warning is redundant because the object will be
released elsewhere.

Distasteful solution: an annotation on the variable saying "this local variable
should have a retain count of +1 when it goes out of scope"

More tasteful solution: an annotation on the class saying "instances of this
class are allowed to be created with extra retain counts, as long as they've
been given a delegate implementing these methods, where the method releases the
parameter passed as self by this class's instance". So on NSURLConnection, it
would indicate that -[delegate connectionDidFinishLoading:] and -[delegate
connection:didFailWithError:] should release the connection if it was created
with an extra retain count.

Real solution: you're the experts :-).

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