Reviewed By: mbouaziz Differential Revision: D7213885 fbshipit-source-id: e460f6amaster
parent
5898417fdd
commit
26697704dc
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2016 - present Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD style license found in the
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
TESTS_DIR = ../../..
|
||||
|
||||
ANALYZER = checkers
|
||||
CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c
|
||||
INFER_OPTIONS = --biabduction-only --no-filtering --debug-exceptions --project-root $(TESTS_DIR)
|
||||
INFERPRINT_OPTIONS = --issues-tests
|
||||
|
||||
SOURCES = \
|
||||
$(wildcard */*.mm) \
|
||||
|
||||
include $(TESTS_DIR)/clang.make
|
@ -0,0 +1 @@
|
||||
codetoanalyze/objcpp/errors/retain_cycles/RetainCycleWithStruct.mm, main_bad, 2, RETAIN_CYCLE, [start of procedure main_bad(),start of procedure tracer,start of procedure _State,return from a call to _State__State,start of procedure initWithAnimation:,Condition is true,return from a call to Tracer_initWithAnimation:,return from a call to Animation_tracer]
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class Tracer;
|
||||
|
||||
struct _State {
|
||||
Tracer* tracer;
|
||||
|
||||
virtual ~_State() { tracer = nil; }
|
||||
};
|
||||
|
||||
@interface Animation : NSObject
|
||||
- (Tracer*)tracer;
|
||||
@end
|
||||
|
||||
@interface Animation () {
|
||||
@public
|
||||
struct _State* _state;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface Tracer : NSObject
|
||||
- (instancetype)initWithAnimation:(Animation*)a;
|
||||
@end
|
||||
|
||||
@implementation Animation
|
||||
|
||||
- (Tracer*)tracer {
|
||||
_state = new _State();
|
||||
_state->tracer = [[Tracer alloc] initWithAnimation:self];
|
||||
return _state->tracer;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
NSLog(@"dealloc Animation");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation Tracer {
|
||||
_State* _state;
|
||||
}
|
||||
|
||||
- (id)initWithAnimation:(Animation*)a {
|
||||
self = [super init];
|
||||
if (nil != self) {
|
||||
_state = a->_state;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
NSLog(@"dealloc Tracer");
|
||||
}
|
||||
@end
|
||||
|
||||
int main_bad() {
|
||||
Animation* a = [Animation new];
|
||||
Tracer* tracer = [a tracer];
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue