diff --git a/infer/src/bufferoverrun/polynomials.ml b/infer/src/bufferoverrun/polynomials.ml index 1d83dcac1..3af84adac 100644 --- a/infer/src/bufferoverrun/polynomials.ml +++ b/infer/src/bufferoverrun/polynomials.ml @@ -504,7 +504,8 @@ module NonNegativePolynomial = struct let compare_by_degree = - AbstractDomain.StackedUtils.compare ~cmp_above:TopTraces.compare ~cmp_below:(fun p1 p2 -> + let cmp_above _ _ = 0 (* All Top should be considered equal *) in + AbstractDomain.StackedUtils.compare ~cmp_above ~cmp_below:(fun p1 p2 -> Degree.compare (NonNegativeNonTopPolynomial.degree p1) (NonNegativeNonTopPolynomial.degree p2) ) diff --git a/infer/tests/build_systems/differential_of_costs_report/costs_summary.json.exp b/infer/tests/build_systems/differential_of_costs_report/costs_summary.json.exp index a4676cec4..f15470489 100644 --- a/infer/tests/build_systems/differential_of_costs_report/costs_summary.json.exp +++ b/infer/tests/build_systems/differential_of_costs_report/costs_summary.json.exp @@ -1 +1 @@ -{"top":{"current":1,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":3,"previous":2},{"degree":100,"current":1,"previous":2},{"degree":101,"current":2,"previous":0},{"degree":200,"current":0,"previous":2}]} \ No newline at end of file +{"top":{"current":2,"previous":1},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":3,"previous":2},{"degree":100,"current":1,"previous":2},{"degree":101,"current":2,"previous":0},{"degree":200,"current":0,"previous":2}]} \ No newline at end of file diff --git a/infer/tests/build_systems/differential_of_costs_report/introduced.exp b/infer/tests/build_systems/differential_of_costs_report/introduced.exp index 54e38b351..c25d07d89 100644 --- a/infer/tests/build_systems/differential_of_costs_report/introduced.exp +++ b/infer/tests/build_systems/differential_of_costs_report/introduced.exp @@ -1,3 +1,3 @@ -INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Loop at line 25] -PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 44] +INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Loop at line 26] +PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45] PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to List.length,{list.length},Modeled call to List.length] diff --git a/infer/tests/build_systems/differential_of_costs_report/preexisting.exp b/infer/tests/build_systems/differential_of_costs_report/preexisting.exp index e69de29bb..5f021e7da 100644 --- a/infer/tests/build_systems/differential_of_costs_report/preexisting.exp +++ b/infer/tests/build_systems/differential_of_costs_report/preexisting.exp @@ -0,0 +1 @@ +INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f7(int):void, 0, [call to void DiffExample.f1(int),Loop at line 26] diff --git a/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.current b/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.current index 27e409312..7a71243d7 100644 --- a/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.current +++ b/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.current @@ -16,6 +16,7 @@ import java.util.ArrayList; // f4: linear // f5: n log n // f6: n log n +// f7: top by call to f1 public class DiffExample { @@ -55,4 +56,9 @@ public class DiffExample { private void f6(ArrayList list) { f5(list); } + + // cost: top by call to f1 + private static void f7(int k) { + f1(k); + } } diff --git a/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.previous b/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.previous index 3f4c2cae9..8fcea2023 100644 --- a/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.previous +++ b/infer/tests/build_systems/differential_of_costs_report/src/DiffExample.java.previous @@ -13,6 +13,7 @@ // f4: constant // f5: linear // f6: quadratic +// f7: top public class DiffExample { // cost: linear @@ -44,4 +45,12 @@ public class DiffExample { private static void f6(int n) { f2(n); } + + // cost: top + private static void f7(int k) { + int i = 0; + while (i >=0) { + i++; + } + } }