Reviewed By: sblackshear Differential Revision: D7197980 fbshipit-source-id: 56759ffmaster
parent
6976181b77
commit
716bb1939c
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
@interface AnalyticsTimeSpent : NSObject
|
||||
|
||||
@property(nonatomic, weak) id delegate;
|
||||
|
||||
@property(nonatomic, strong) id strong_delegate;
|
||||
|
||||
- (instancetype)initWithDelegate:(id)delegateObject;
|
||||
|
||||
- (instancetype)initWithStrongDelegate:(id)delegateObject;
|
||||
|
||||
@end
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 "AnalyticsTimeSpent.h"
|
||||
#import "TimeSpent.h"
|
||||
|
||||
@implementation AnalyticsTimeSpent
|
||||
|
||||
@synthesize delegate;
|
||||
|
||||
- (instancetype)initWithDelegate:(id)delegateObject {
|
||||
[self setDelegate:delegateObject];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStrongDelegate:(id)delegateObject {
|
||||
_strong_delegate = delegateObject;
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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>
|
||||
#import "AnalyticsTimeSpent.h"
|
||||
|
||||
@interface TimeSpent : NSObject
|
||||
- (instancetype)init;
|
||||
@end
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 "TimeSpent.h"
|
||||
#import "AnalyticsTimeSpent.h"
|
||||
|
||||
@interface TimeSpent () {
|
||||
AnalyticsTimeSpent* _timeSpent;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TimeSpent
|
||||
- (instancetype)init {
|
||||
_timeSpent = [[AnalyticsTimeSpent alloc] initWithDelegate:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setAnalyticsTimeSpent:(AnalyticsTimeSpent*)timeSpent {
|
||||
_timeSpent = timeSpent;
|
||||
}
|
||||
@end
|
||||
|
||||
int retain_cycle_weak_good() {
|
||||
TimeSpent* ts = [TimeSpent new];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int retain_cycle_weak_bad() {
|
||||
TimeSpent* ts = [[TimeSpent alloc] init];
|
||||
AnalyticsTimeSpent* ats =
|
||||
[[AnalyticsTimeSpent alloc] initWithStrongDelegate:ts];
|
||||
[ts setAnalyticsTimeSpent:ats];
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2017 - 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 = ../..
|
||||
ROOT_DIR = $(TESTS_DIR)/../..
|
||||
CODETOANALYZE_DIR = ../codetoanalyze/objc_retain_cycles_weak
|
||||
|
||||
ANALYZER = checkers
|
||||
SOURCES = $(CODETOANALYZE_DIR)/TimeSpent.m $(CODETOANALYZE_DIR)/AnalyticsTimeSpent.m
|
||||
OBJECTS = $(CODETOANALYZE_DIR)/TimeSpent.o $(CODETOANALYZE_DIR)/AnalyticsTimeSpent.o
|
||||
INFER_OPTIONS = --biabduction-only --report-custom-error --developer-mode --project-root $(TESTS_DIR)
|
||||
INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests
|
||||
|
||||
include $(TESTS_DIR)/infer.make
|
||||
|
||||
infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
|
||||
$(QUIET)$(REMOVE_DIR) buck-out && \
|
||||
$(call silent_on_success,Testing analysis with Objective-C retain cycles on weak properties,\
|
||||
$(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang -c -fobjc-arc $(SOURCES))
|
@ -0,0 +1 @@
|
||||
build_systems/codetoanalyze/objc_retain_cycles_weak/TimeSpent.m, retain_cycle_weak_bad, 4, RETAIN_CYCLE, [start of procedure retain_cycle_weak_bad(),start of procedure init,start of procedure initWithDelegate:,return from a call to AnalyticsTimeSpent_initWithDelegate:,return from a call to TimeSpent_init,start of procedure initWithStrongDelegate:,return from a call to AnalyticsTimeSpent_initWithStrongDelegate:,start of procedure setAnalyticsTimeSpent:,return from a call to TimeSpent_setAnalyticsTimeSpent:]
|
Loading…
Reference in new issue