diff --git a/infer/src/bufferoverrun/bufferOverrunTypModels.ml b/infer/src/bufferoverrun/bufferOverrunTypModels.ml index 8c282429b..7d8432090 100644 --- a/infer/src/bufferoverrun/bufferOverrunTypModels.ml +++ b/infer/src/bufferoverrun/bufferOverrunTypModels.ml @@ -37,5 +37,7 @@ let dispatch : (Tenv.t, typ_model, unit) ProcnameDispatcher.TypName.dispatcher = ; -"std" &:: "vector" < any_typ &+ any_typ >--> std_vector ; +PatternMatch.Java.implements_collection &::.*--> Java.collection ; +PatternMatch.Java.implements_iterator &::.*--> Java.collection + ; +PatternMatch.Java.implements_map &::.*--> Java.collection + ; +PatternMatch.Java.implements_pseudo_collection &::.*--> Java.collection ; +PatternMatch.Java.implements_lang "Integer" &::.*--> Java.integer ; +PatternMatch.Java.implements_org_json "JSONArray" &::.*--> Java.collection ] diff --git a/infer/tests/codetoanalyze/java/performance/Array.java b/infer/tests/codetoanalyze/java/performance/Array.java index ceb2df3db..d5811356e 100644 --- a/infer/tests/codetoanalyze/java/performance/Array.java +++ b/infer/tests/codetoanalyze/java/performance/Array.java @@ -96,6 +96,10 @@ public class Array { for (int i = 0; i < list.toArray().length; i++) {} } + void toArray_map_linear(java.util.Map map) { + for (int i = 0; i < map.values().toArray().length; i++) {} + } + private static final String[] static_final_field = new String[] {"", ""}; void use_static_final_array_field_constant() { diff --git a/infer/tests/codetoanalyze/java/performance/cost-issues.exp b/infer/tests/codetoanalyze/java/performance/cost-issues.exp index 3d7271e47..4ee99a1eb 100644 --- a/infer/tests/codetoanalyze/java/performance/cost-issues.exp +++ b/infer/tests/codetoanalyze/java/performance/cost-issues.exp @@ -24,6 +24,7 @@ codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array. codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.init_array_constant():void, 2568, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.sort_array_nlogn(int):void, 5 + size × log(size), OnUIThread:false, [{size},Modeled call to Arrays.sort,{size},Modeled call to Arrays.sort] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.toArray_linear(java.util.ArrayList):void, 6 + 6 ⋅ list.length + 3 ⋅ (list.length + 1), OnUIThread:false, [{list.length + 1},Loop,{list.length},Loop] +codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.toArray_map_linear(java.util.Map):void, 6 + 6 ⋅ map.length + 6 ⋅ (map.length + 1), OnUIThread:false, [{map.length + 1},Loop,{map.length},Loop] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.use_static_final_array_field_constant():void, 18, OnUIThread:false, [] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.(), 3, OnUIThread:false, [] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.ArrayCost(int[]):void, 8 + 5 ⋅ mag.length, OnUIThread:false, [{mag.length},Loop]