From a3fd1cad563df109b2a20ab2a426df2e5f57c6ad Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Thu, 22 Oct 2020 07:43:41 -0700 Subject: [PATCH] [cost] Fix function name in model `arrayWithObjects:` Summary: Not sure what's going on. Reviewed By: ezgicicek Differential Revision: D24446585 fbshipit-source-id: 460bb119c --- infer/src/bufferoverrun/bufferOverrunModels.ml | 2 +- infer/tests/codetoanalyze/objc/performance/NSArray.m | 2 +- infer/tests/codetoanalyze/objc/performance/cost-issues.exp | 2 +- infer/tests/codetoanalyze/objc/performance/issues.exp | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/infer/src/bufferoverrun/bufferOverrunModels.ml b/infer/src/bufferoverrun/bufferOverrunModels.ml index 2402ffd0d..2943a3636 100644 --- a/infer/src/bufferoverrun/bufferOverrunModels.ml +++ b/infer/src/bufferoverrun/bufferOverrunModels.ml @@ -1707,7 +1707,7 @@ module Call = struct ; +PatternMatch.ObjectiveC.implements "NSArray" &:: "arrayWithObjects:count:" <>$ capt_exp $+ capt_exp $--> NSCollection.create_from_array ; +PatternMatch.ObjectiveC.implements "NSArray" - &:: "arrayWithObjects" &++> NSCollection.of_list + &:: "arrayWithObjects:" &++> NSCollection.of_list ; +PatternMatch.ObjectiveC.implements "NSArray" &:: "arrayByAddingObjectsFromArray:" <>$ capt_exp $+ capt_exp $--> NSCollection.new_collection_by_add_all diff --git a/infer/tests/codetoanalyze/objc/performance/NSArray.m b/infer/tests/codetoanalyze/objc/performance/NSArray.m index 34d93ff89..9cab94586 100644 --- a/infer/tests/codetoanalyze/objc/performance/NSArray.m +++ b/infer/tests/codetoanalyze/objc/performance/NSArray.m @@ -51,7 +51,7 @@ NSArray* nsarray_init_with_objects_constant() { } } -NSArray* nsarray_array_with_objects_constant_FP() { +NSArray* nsarray_array_with_objects_constant() { NSDate* aDate = [NSDate distantFuture]; NSValue* aValue = @(5); NSString* aString = @"hello"; diff --git a/infer/tests/codetoanalyze/objc/performance/cost-issues.exp b/infer/tests/codetoanalyze/objc/performance/cost-issues.exp index 25d90c747..1df975541 100644 --- a/infer/tests/codetoanalyze/objc/performance/cost-issues.exp +++ b/infer/tests/codetoanalyze/objc/performance/cost-issues.exp @@ -4,7 +4,7 @@ codetoanalyze/objc/performance/NSArray.m, nsarray_access_constant, 50, OnUIThre codetoanalyze/objc/performance/NSArray.m, nsarray_access_linear, 3 + 7 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_add_object_constant, 8, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_add_objects_from_array_linear, 9 + 3 ⋅ append_array->elements.length.ub + append_array->elements.length.ub + 3 ⋅ (append_array->elements.length.ub + 1), OnUIThread:false, [{append_array->elements.length.ub + 1},Loop,{append_array->elements.length.ub},Modeled call to NSArray.arrayByAddingObjectsFromArray:,{append_array->elements.length.ub},Loop] -codetoanalyze/objc/performance/NSArray.m, nsarray_array_with_objects_constant_FP, ⊤, OnUIThread:false, [Unbounded loop,Loop] +codetoanalyze/objc/performance/NSArray.m, nsarray_array_with_objects_constant, 47, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_binary_search_log_FN, 10, OnUIThread:false, [] codetoanalyze/objc/performance/NSArray.m, nsarray_contains_object_linear, 3 + array->elements.length.ub, OnUIThread:false, [{array->elements.length.ub},Modeled call to NSArray.containsObject:] codetoanalyze/objc/performance/NSArray.m, nsarray_copy_linear, 6 + 3 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop] diff --git a/infer/tests/codetoanalyze/objc/performance/issues.exp b/infer/tests/codetoanalyze/objc/performance/issues.exp index 3b5867a0d..93b3487e1 100644 --- a/infer/tests/codetoanalyze/objc/performance/issues.exp +++ b/infer/tests/codetoanalyze/objc/performance/issues.exp @@ -1,4 +1,3 @@ -codetoanalyze/objc/performance/NSArray.m, nsarray_array_with_objects_constant_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop] codetoanalyze/objc/performance/NSArray.m, nsarray_empty_array_constant, 3, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here] codetoanalyze/objc/performance/NSArray.m, nsarray_enumerator_linear, 7, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,,Assignment,Binary operation: ([0, +oo] + [1, array->elements.length.ub + 1]):signed64] codetoanalyze/objc/performance/NSArray.m, nsarray_init_constant, 3, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]