[inferbo] Add model for NSFastEnumeration

Reviewed By: ngorogiannis

Differential Revision: D24562644

fbshipit-source-id: 71e589883
master
Ezgi Çiçek 4 years ago committed by Facebook GitHub Bot
parent 059c0f24a2
commit 067020f4df

@ -1702,6 +1702,8 @@ module Call = struct
$--> NSCollection.copy
; +is_objc_collection &:: "count" <>$ capt_exp $!--> NSCollection.size
; +is_objc_collection &:: "objectEnumerator" <>$ capt_exp $--> NSCollection.iterator
; +PatternMatch.ObjectiveC.conforms_to ~protocol:"NSFastEnumeration"
&:: "objectEnumerator" <>$ capt_exp $--> NSCollection.iterator
; +PatternMatch.ObjectiveC.implements "NSArray"
&:: "objectAtIndexedSubscript:" <>$ capt_var_exn $+ capt_exp $!--> NSCollection.get_at_index
; +PatternMatch.ObjectiveC.implements "NSArray"

@ -0,0 +1,25 @@
/*
* 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 MyEnumerator : NSObject<NSFastEnumeration>
@end
void loop_enumerator_linear(MyEnumerator* enumeration) {
for (id obj in enumeration) {
}
}
void call_loop_enumerator_constant() {
NSArray* arr = @[ @1, @2, @3 ];
loop_enumerator_linear(arr);
}
// We get Top because front-end can't recognize NSFastEnumeration
void loop_id_enumerator_linear_FP(id<NSFastEnumeration> enumeration) {
for (id obj in enumeration) {
}
}

@ -44,6 +44,9 @@ codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_find_key_constant, 1
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_dictionary_constant, 3, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_literal_constant, 45, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear, 7 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSEnumeration.m, call_loop_enumerator_constant, 35, OnUIThread:false, []
codetoanalyze/objc/performance/NSEnumeration.m, loop_enumerator_linear, 5 + 5 ⋅ (enumeration->elements.length.ub + 1), OnUIThread:false, [{enumeration->elements.length.ub + 1},Loop]
codetoanalyze/objc/performance/NSEnumeration.m, loop_id_enumerator_linear_FP, , OnUIThread:false, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSFileManager.m, contents_of_directory_at_url_constant, 11, OnUIThread:false, []
codetoanalyze/objc/performance/NSInteger.m, nsinteger_value_linear, 3 + 3 ⋅ integer + 2 ⋅ (1+max(0, integer)), OnUIThread:false, [{1+max(0, integer)},Loop,{integer},Loop]
codetoanalyze/objc/performance/NSInteger.m, nsnumber_number_with_int_integer_value_constant, 34, OnUIThread:false, []

@ -3,6 +3,7 @@ codetoanalyze/objc/performance/NSArray.m, nsarray_enumerator_linear, 7, INTEGER_
codetoanalyze/objc/performance/NSArray.m, nsarray_init_constant, 3, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/NSArray.m, nsarray_iterate_linear, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,<RHS trace>,Assignment,Binary operation: ([0, +oo] + [1, array->elements.length.ub + 1]):signed64]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerate_constant, 6, BUFFER_OVERRUN_L2, no_bucket, ERROR, [<Offset trace>,Assignment,<Length trace>,Array declaration,Array access: Offset: [1, 3] Size: 2]
codetoanalyze/objc/performance/NSEnumeration.m, loop_id_enumerator_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSFileManager.m, contents_of_directory_at_url_constant, 7, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/NSMutableArray.m, nsarray_new_constant, 2, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_remove_constant, 6, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Length trace>,Array declaration,Through,Through,Through,Through,Array access: Offset: 0 Size: 0]

Loading…
Cancel
Save