[LLVMbugs] [Bug 11746] New: False positive warning with 'instancetype' and deprecated method of same name in NSString

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 11 12:44:47 PST 2012


             Bug #: 11746
           Summary: False positive warning with 'instancetype' and
                    deprecated method of same name in NSString
           Product: new-bugs
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sean at rogue-research.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

Using clang r147866 on Mac OS X 10.7, the code below causes this warning:

$ /path/to/my/clang -fsyntax-only test.m 
test.m:18:11: warning: 'initWithContentsOfURL:' is deprecated
        return [[[self alloc] initWithContentsOfURL:inURL] autorelease];

NSString has a deprecated method initWithContentsOfURL:, but in my own class
it's not deprecated.  I would have thought that between my own use of
instancetype and clang's special casing of alloc[1] that this should not warn.

[1] as described here:

Here's the code (also attached):

#import <Foundation/Foundation.h>

@interface Awesome : NSObject { }
- (instancetype)initWithContentsOfURL:(NSURL*)inURL; // designated initializer
+ (instancetype)awsomeWithContentsOfURL:(NSURL*)inURL;

@implementation Awesome

- (instancetype)initWithContentsOfURL:(NSURL*)inURL
 self = [super init];
 return self;

+ (instancetype)awsomeWithContentsOfURL:(NSURL*)inURL
 return [[[self alloc] initWithContentsOfURL:inURL] autorelease];


int main (int argc, char *argv[])
 (void)argc; (void)argv;
 return 0;

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