Teach the CF retain checker about "_init" methods. Fixes: <rdar://problem/5956379>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-06-02 17:14:13 +00:00
Родитель b96ffdf59e
Коммит 0327f77869
2 изменённых файлов: 22 добавлений и 11 удалений

Просмотреть файл

@ -607,7 +607,7 @@ RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME) {
const char* s = S.getIdentifierInfoForSlot(0)->getName();
assert (ScratchArgs.empty());
if (strncmp(s, "init", 4) == 0)
if (strncmp(s, "init", 4) == 0 || strncmp(s, "_init", 5) == 0)
return getInitMethodSummary(S);
// "copyXXX", "createXXX", "newXXX": allocators.

Просмотреть файл

@ -71,23 +71,15 @@ NSString* f10() {
}
@interface C1 : NSObject {}
- (NSString*) getShared;
+ (C1*) sharedInstance;
@end
@implementation C1 : NSObject {}
- (NSString*) getShared {
static NSString* s = nil;
if (!s) s = [[NSString alloc] init];
if (!s) s = [[NSString alloc] init];
return s; // no-warning
}
+ (C1 *)sharedInstance {
static C1 *sharedInstance = nil;
if (!sharedInstance) {
@ -95,6 +87,25 @@ NSString* f10() {
}
return sharedInstance; // no-warning
}
@end
@interface SharedClass : NSObject
+ (id)sharedInstance;
@end
@implementation SharedClass
- (id)_init {
if ((self = [super init])) {
NSLog(@"Bar");
}
return self;
}
+ (id)sharedInstance {
static SharedClass *_sharedInstance = nil;
if (!_sharedInstance) {
_sharedInstance = [[SharedClass alloc] _init];
}
return _sharedInstance; // no-warning
}
@end