[LLVMbugs] [Bug 10376] New: Autoreleased return value results in sub-optimal path diagnostics

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 15 15:35:44 PDT 2011


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

           Summary: Autoreleased return value results in sub-optimal path
                    diagnostics
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: quality-of-implementation
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: jediknil at belkadan.com
                CC: llvmbugs at cs.uiuc.edu


In the code below (or any code that returns an autoreleased object and causes a
bug report), the emitted messages look something like this (locations omitted):

warning: Object with a +0 retain count returned to caller where a +1 (owning)
retain count is expected
note: Method returns an Objective-C object with a +1 retain count
note: Object sent -autorelease message
note: Object returned to caller as an owning reference (single retain count
transferred to caller)
note: Object returned to caller with a +0 retain count
note: Object with a +0 retain count returned to caller where a +1 (owning)
retain count is expected

Note the two "returned to caller" lines. This happens because we process
autorelease counts after deciding that a value is returned. Ideally we'd just
skip the first line.


@interface NSObject
+ (id)alloc;
- (id)init;

- (id)retain;
- (void)release;
- (void)autorelease;
@end

@implementation NSObject (Copying)
- (id)copy {
        id result = [[NSObject alloc] init];
    [result autorelease];
    return result;
}
@end

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