clang static analyser in Xcode does not respect per-file -fobj-arc
| Originator: | alan.francis | ||
| Number: | rdar://11002181 | Date Originated: | 28th March 2011 |
| Status: | Open | Resolved: | 28th March 2011 |
| Product: | Xcode | Product Version: | 4.2.1 |
| Classification: | Other | Reproducible: | Always |
Summary:
In a non-arc project, specifying -fobj-arc against a particular file to compile with ARC still triggers analyser warnings inside Xcode.
Steps to Reproduce:
1. Create a new single-view iOS project, ensure ARC is switched *off* for the project.
2. In Build Phases, add -fobj-arc to the generated ViewController class. [DOH. TRY OBJC-ARC, IDIOT]
3. add the following code to the ViewControllers viewDidLoad
NSString* leak = [[NSString alloc] initWithString:@"I will be reported as a leak despite -fobj-arc"];
NSLog(@"LEAK: %@", leak);
4. Add the following code to the AppDelegates application:didFinishLaunchingWithOptions:
NSString* leak = [[NSString alloc] initWithString:@"I *SHOULD* be reported as a leak as this is a non-ARC project"];
NSLog(@"LEAK: %@", leak);
5. Select Product->Analyse
Expected Results:
The leak in AppDelegate should be reported as the file (and indeed the project) are not ARC-enabled. The leak in the ViewController should *not* be reported as it's ARC compiled.
Actual Results:
Both leaks are reported.
['ClangTest.zip' was successfully uploaded]
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!