diff --git a/infer/src/bufferoverrun/itv.ml b/infer/src/bufferoverrun/itv.ml index b383000a7..f526d3e2f 100644 --- a/infer/src/bufferoverrun/itv.ml +++ b/infer/src/bufferoverrun/itv.ml @@ -70,10 +70,13 @@ module SymbolPath = struct let rec pp_partial fmt = function | Pvar pvar -> Pvar.pp_value fmt pvar + (* Temporary fix, see T31250173 *) + | Index p when Language.curr_language_is Java -> + F.fprintf fmt "%a" pp_partial p | Index p -> F.fprintf fmt "%a[*]" pp_partial p | Field (fn, p) -> - F.fprintf fmt "%a.%a" pp_partial p Typ.Fieldname.pp fn + F.fprintf fmt "%a.%s" pp_partial p (Typ.Fieldname.to_flat_string fn) let pp fmt = function diff --git a/infer/tests/codetoanalyze/java/performance/FieldAccess.java b/infer/tests/codetoanalyze/java/performance/FieldAccess.java new file mode 100644 index 000000000..de7c608db --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/FieldAccess.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +package codetoanalyze.java.performance; + + + +public class FieldAccess{ + + public class Test{ + int a; +} + + void iterate_upto_field_size(Test test){ + for (int ci = 0; ci < test.a; ++ci) { + } + } + + +} diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp index 7dbd4ef5b..5902d4bf1 100644 --- a/infer/tests/codetoanalyze/java/performance/issues.exp +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -48,6 +48,8 @@ codetoanalyze/java/performance/Cost_test_deps.java, int Cost_test_deps.two_loops codetoanalyze/java/performance/Cost_test_deps.java, void Cost_test_deps.if_bad(int), 6, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 608] codetoanalyze/java/performance/Cost_test_deps.java, void Cost_test_deps.if_bad(int), 6, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 607] codetoanalyze/java/performance/EvilCfg.java, void EvilCfg.foo(int,int,boolean), 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] +codetoanalyze/java/performance/FieldAccess.java, void FieldAccess.iterate_upto_field_size(FieldAccess$Test), 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 2 + 6 * test.a.ub] +codetoanalyze/java/performance/FieldAccess.java, void FieldAccess.iterate_upto_field_size(FieldAccess$Test), 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 1 + 6 * test.a.ub] codetoanalyze/java/performance/JsonArray.java, void JsonArray.addStringEntry(String), 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] codetoanalyze/java/performance/JsonMap.java, void JsonMap.addEntry(String,JsonType), 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] codetoanalyze/java/performance/JsonMap.java, void JsonMap.addEntry(String,Object), 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, []