Summary: This model is very important in the analysis of ObjC classes because the pattern ``` - (instancetype)init { if (self = [super init]) { ... } return self; } ``` is very common, so we need to know that if the super class is `NSObject`, the implementation of `init` is returning `self`, otherwise it's a skip function and we don't get the correct spec for the function. We fix some memory leak FP with this model, see test. Reviewed By: ezgicicek Differential Revision: D22259281 fbshipit-source-id: 3ee48c827master
parent
2c48e61031
commit
85ee958bf9
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@interface MyBufferContainer : NSObject
|
||||
|
||||
@property char* buffer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MyBufferContainer
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_buffer = malloc(sizeof(char));
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
free(_buffer);
|
||||
}
|
||||
|
||||
@end
|
||||
void raii_no_leak_ok() {
|
||||
MyBufferContainer* b = [[MyBufferContainer alloc] init];
|
||||
}
|
Loading…
Reference in new issue