[LLVMbugs] [Bug 12509] New: False positive for "Instance variable used while 'self' is not set to the result of '[(super or self) init...]'" warning

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 9 16:29:07 PDT 2012


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

             Bug #: 12509
           Summary: False positive for "Instance variable used while
                    'self' is not set to the result of '[(super or self)
                    init...]'" warning
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8360
  --> http://llvm.org/bugs/attachment.cgi?id=8360
repro

The attached file contains:

- (id)initWithBalloon:(Balloon*)balloon {
  NSString* nibpath =
      [base::mac::FrameworkBundle() pathForResource:@"Notification"
                                             ofType:@"nib"];
  if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
    balloon_ = balloon;
    [self initializeHost];
    menuModel_.reset(new NotificationOptionsMenuModel(balloon));
    menuController_.reset([[MenuController alloc]
initWithModel:menuModel_.get()
                                         useWithPopUpButtonCell:(BOOL)0]);
  }
  return self;
}


The analyzer warns about this:


$ third_party/llvm-build/Release+Asserts/bin/scan-build \
    --use-c++ third_party/llvm-build/Release+Asserts/bin/clang++ \
    clang++ -x objective-c++ -c  ~/balloon.ii \
        -Wno-c++11-extensions -arch i386 
In file included from
../../chrome/browser/ui/cocoa/notifications/balloon_controller.mm:1:
../../chrome/browser/ui/cocoa/notifications/balloon_controller.mm:55:5:
warning: Instance variable used while 'self' is not set to the result of
'[(super or self) init...]'
    menuController_.reset([[MenuController alloc]
initWithModel:menuModel_.get()
    ^~~~~~~~~~~~~~~
1 warning generated.
scan-build: 1 bugs found.


As far as I can tell, |self| _is_ set to the result of [super init...] in this
line.

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