[cost] Add FN test: saving lambda in object field

Summary: This diff adds a test, in which autoreleasing lambda is written in an object field, then called later. The test is not analyzed precisely because it cannot follow that a lambda value is written to a field of an object as of now.

Reviewed By: ezgicicek

Differential Revision: D23843089

fbshipit-source-id: 62ba153aa
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 68597c5908
commit 03b330214f

@ -0,0 +1,58 @@
/*
* 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"
typedef BOOL (^Filter)(id);
@interface MyEnumerator : NSObject
@end
@implementation MyEnumerator
NSEnumerator* _enumerator;
Filter _filter;
- (instancetype)initWithArray:(NSArray*)array filter:(Filter)filter {
_enumerator = [array objectEnumerator];
_filter = filter;
return self;
}
- (id)nextObject {
id obj;
while (obj = [_enumerator nextObject]) {
if (_filter(obj)) {
return obj;
}
}
return NULL;
}
@end
@interface ArcEnumerator : NSObject
@end
@implementation ArcEnumerator
- (MyEnumerator*)makeMyEnumerator_zero:(NSArray*)x {
return [[MyEnumerator alloc] initWithArray:x
filter:^BOOL(NSObject* o) {
NoArcCallee* dummy =
[NoArcCallee giveMeObject];
return true;
}];
}
- (void)callMyEnumerator_linear_FN:(NSArray*)x {
MyEnumerator* enumerator = [self makeMyEnumerator_zero:x];
id s;
while (s = [enumerator nextObject]) {
}
}
@end

@ -24,6 +24,13 @@ codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.callGiveMeObject_line
codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.callMutableCopyObject_zero:x:, 0, OnUIThread:false, [] codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.callMutableCopyObject_zero:x:, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.callNewObject_zero:, 0, OnUIThread:false, [] codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.callNewObject_zero:, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.dealloc, 0, OnUIThread:false, [] codetoanalyze/objc/autoreleasepool/arc_caller.m, ArcCaller.dealloc, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, ArcEnumerator.callMyEnumerator_linear_FN:, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, ArcEnumerator.dealloc, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, ArcEnumerator.makeMyEnumerator_zero:, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, MyEnumerator.dealloc, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, MyEnumerator.initWithArray:filter:, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, MyEnumerator.nextObject, 0, OnUIThread:false, []
codetoanalyze/objc/autoreleasepool/arc_enumerator.m, objc_blockArcEnumerator.makeMyEnumerator_zero:_1, 1, OnUIThread:false, [autorelease,Call to NoArcCallee.giveMeObject,Modeled call to NSObject.autorelease]
codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callInitForReadingFromData_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.initForReadingFromData:error:] codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callInitForReadingFromData_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.initForReadingFromData:error:]
codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callInitForReadingWithData_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.initForReadingWithData:] codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callInitForReadingWithData_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.initForReadingWithData:]
codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callUnarchivedObjectOfClass_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.unarchivedObjectOfClass:fromData:error:] codetoanalyze/objc/autoreleasepool/arc_keyed_unarchiver.m, ArcKeyedUnarchiver.callUnarchivedObjectOfClass_constant:data:, 1, OnUIThread:false, [autorelease,Modeled call to NSKeyedUnarchiver.unarchivedObjectOfClass:fromData:error:]

Loading…
Cancel
Save