LLVM/Clang bug found in convenience method and NSClassFromString(...) alloc/release
- by pirags
I am analyzing Objective-C iPhone project with LLVM/Clang static analyzer. I keep getting two reported bugs, but I am pretty sure that the code is correct.
1) Convenience method.
+ (UILabel *)simpleLabel
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 200, 25)];
label.adjustsFontSizeToFitWidth = YES;
[label autorelease]; // Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected.
return label;
}
2) The [NSClassFromString(...) alloc] returns retainCount + 1. Am I right?
Class detailsViewControllerClass =
NSClassFromString(self.detailsViewControllerName);
UIViewController *detailsViewController =
[[detailsViewControllerClass alloc]
performSelector:@selector(initWithAdditive:) withObject:additive];
[self.parentController.navigationController
pushViewController:detailsViewController animated:YES];
[detailsViewController release]; // Incorrect decrement of the reference count of an object is not owned...
Are these some Clang issues or I am totally mistaken in these both cases?