Summary: This diff adds some tests run with ARC/non-ARC compiled objective-c sources. Reviewed By: ezgicicek Differential Revision: D23542135 fbshipit-source-id: 8e089666bmaster
parent
b62c3f55b9
commit
6ff1a42b6a
@ -0,0 +1,21 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
ROOT_DIR = $(TESTS_DIR)/../..
|
||||||
|
|
||||||
|
CLEAN_EXTRA += duplicates.txt
|
||||||
|
|
||||||
|
OBJECTS = $(foreach source,$(filter %.c %.cpp %.m %.mm,$(SOURCES)),$(basename $(source)).o)
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/infer.make
|
||||||
|
include $(TESTS_DIR)/clang-base.make
|
||||||
|
|
||||||
|
infer-out$(TEST_SUFFIX)/report.json: $(CLANG_DEPS) $(SOURCES) $(HEADERS) $(TESTS_DIR)/.inferconfig $(MAKEFILE_LIST)
|
||||||
|
$(QUIET)$(call silent_on_success,Testing infer/clang in $(TEST_REL_DIR),\
|
||||||
|
$(INFER_BIN) capture --results-dir $(@D) --dump-duplicate-symbols $(INFER_OPTIONS) \
|
||||||
|
-- clang -fno-objc-arc $(CLANG_OPTIONS) $(SOURCES_NO_ARC) && \
|
||||||
|
$(INFER_BIN) capture --continue --results-dir $(@D) --dump-duplicate-symbols $(INFER_OPTIONS) \
|
||||||
|
-- clang -fobjc-arc $(CLANG_OPTIONS) $(SOURCES_ARC) && \
|
||||||
|
$(INFER_BIN) analyze --results-dir $(@D) --dump-duplicate-symbols $(INFER_OPTIONS))
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "no_arc_callee.h"
|
||||||
|
|
||||||
|
@interface ArcCaller : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ArcCaller
|
||||||
|
|
||||||
|
- (void)callAllocObject_zero:(int)n {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
NoArcCallee* obj = [NoArcCallee allocObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)callNewObject_zero:(int)n {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
NoArcCallee* obj = [NoArcCallee newObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)callCopyObject_zero:(int)n x:(NoArcCallee*)x {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
NoArcCallee* obj = [NoArcCallee copyObject:x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)callMutableCopyObject_zero:(int)n x:(NoArcCallee*)x {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
NoArcCallee* obj = [NoArcCallee mutableCopyObject:x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)callGiveMeObject_linear:(int)n {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
NoArcCallee* obj = [NoArcCallee giveMeObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)callGiveMeObject_autoreleasepool_zero:(int)n {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
@autoreleasepool {
|
||||||
|
NoArcCallee* obj = [NoArcCallee giveMeObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface NoArcCallee : NSObject
|
||||||
|
|
||||||
|
+ (NoArcCallee*)allocObject;
|
||||||
|
|
||||||
|
+ (NoArcCallee*)newObject;
|
||||||
|
|
||||||
|
+ (NoArcCallee*)copyObject:(NoArcCallee*)obj;
|
||||||
|
|
||||||
|
+ (NoArcCallee*)mutableCopyObject:(NoArcCallee*)obj;
|
||||||
|
|
||||||
|
+ (NoArcCallee*)giveMeObject;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "no_arc_callee.h"
|
||||||
|
|
||||||
|
@implementation NoArcCallee
|
||||||
|
|
||||||
|
+ (NoArcCallee*)allocObject {
|
||||||
|
return [NoArcCallee alloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Since the checker cares about calling `autorelease` only, we define the
|
||||||
|
following functions as returning a new object simply. */
|
||||||
|
|
||||||
|
+ (NoArcCallee*)newObject {
|
||||||
|
return [[NoArcCallee alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NoArcCallee*)copyObject:(NoArcCallee*)obj {
|
||||||
|
return [[NoArcCallee alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NoArcCallee*)mutableCopyObject:(NoArcCallee*)obj {
|
||||||
|
return [[NoArcCallee alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NoArcCallee*)giveMeObject {
|
||||||
|
return [[[NoArcCallee alloc] init] autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in new issue