Clang analyzer produces a false negative when setting action of an NSControl

Originator:grayson.hansard
Number:rdar://14121533 Date Originated:11-Jun-2013 03:52 PM
Status:Open Resolved:
Product:Xcode Product Version:4.6.1+
Classification:Bug Reproducible:Always
 
Summary:

Xcode's static analyzer feature misses improperly memory managed NSControls when the action is set.  Any subclasses of NSControl have that action set, either through the setter or the property, can leak without a warning from the analyzer.

Steps to Reproduce:

1. Create a new project, turning off ARC.
2. Create a subclass of NSControl in -applicationDidFinishLaunching:.

    NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];

3. Set the action of the control.

    [button setAction:@selector(noop:)];

4. Analyze the project. 

Expected Results:

The Xcode static analyzer should indicate that the created button will leak.

Actual Results:

The static analyzer does not alert the user of the leak.

Regression:

Xcode 4.6 correctly identifies the leak.  Xcode 4.6.1 does not.

Notes:

The attached zip file contains a sample project that reproduces this problem as well as illustrates some more information.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!