diff --git a/infer/src/cost/boundMap.ml b/infer/src/cost/boundMap.ml index 0ebe57413..3c757d220 100644 --- a/infer/src/cost/boundMap.ml +++ b/infer/src/cost/boundMap.ml @@ -58,9 +58,7 @@ let compute_upperbound_map node_cfg inferbo_invariant_map control_invariant_map | Unreachable -> let node_loc = NodeCFG.Node.loc node in L.debug Analysis Medium - "@\n\ - [COST ANALYSIS INTERNAL WARNING:] No 'env' found. This location is \ - unreachable returning cost 0 \n" ; + "@\n[COST ANALYSIS INTERNAL WARNING:] This location is unreachable \n" ; BasicCost.of_unreachable node_loc | ExcRaised -> BasicCost.one () diff --git a/infer/tests/build_systems/differential_of_costs_report_java/Makefile b/infer/tests/build_systems/differential_of_costs_report_java/Makefile index 154432122..1727936bd 100644 --- a/infer/tests/build_systems/differential_of_costs_report_java/Makefile +++ b/infer/tests/build_systems/differential_of_costs_report_java/Makefile @@ -19,10 +19,10 @@ $(CURRENT_REPORT): $(QUIET)$(COPY) src/DiffExample.java.current src/DiffExample.java $(QUIET)$(COPY) src/DiffExampleUIThread.java.current src/DiffExampleUIThread.java $(QUIET)$(call silent_on_success,Testing Cost Differential: current,\ - $(INFER_BIN) --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(CURRENT_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java) + $(INFER_BIN) --no-filtering --cost-only -o $(CURRENT_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java) $(PREVIOUS_REPORT): $(QUIET)$(COPY) src/DiffExample.java.previous src/DiffExample.java $(QUIET)$(COPY) src/DiffExampleUIThread.java.previous src/DiffExampleUIThread.java $(QUIET)$(call silent_on_success,Testing Cost Differential: previous,\ - $(INFER_BIN) --debug --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(PREVIOUS_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java) + $(INFER_BIN) --debug --no-filtering --cost-only -o $(PREVIOUS_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java) diff --git a/infer/tests/build_systems/differential_of_costs_report_java/costs_summary.json.exp b/infer/tests/build_systems/differential_of_costs_report_java/costs_summary.json.exp index 23f586549..394660bb4 100644 --- a/infer/tests/build_systems/differential_of_costs_report_java/costs_summary.json.exp +++ b/infer/tests/build_systems/differential_of_costs_report_java/costs_summary.json.exp @@ -1 +1 @@ -{"top":{"current":2,"previous":1},"unreachable":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":19,"previous":16},{"degree":100,"current":2,"previous":3},{"degree":101,"current":2,"previous":0},{"degree":200,"current":1,"previous":2}]} \ No newline at end of file +{"top":{"current":2,"previous":1},"unreachable":{"current":1,"previous":0},"zero":{"current":1,"previous":0},"degrees":[{"degree":0,"current":20,"previous":18},{"degree":100,"current":2,"previous":3},{"degree":101,"current":2,"previous":0},{"degree":200,"current":1,"previous":2}]} \ No newline at end of file diff --git a/infer/tests/build_systems/differential_of_costs_report_java/introduced.exp b/infer/tests/build_systems/differential_of_costs_report_java/introduced.exp index 6e1321f9d..c496eae26 100644 --- a/infer/tests/build_systems/differential_of_costs_report_java/introduced.exp +++ b/infer/tests/build_systems/differential_of_costs_report_java/introduced.exp @@ -1,4 +1,5 @@ INFINITE_EXECUTION_TIME, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop] EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Previous Cost of f4 is 5 (degree is 0),Updated Cost of f4 is 6 + 5 ⋅ k (degree is 1),{k},Loop] EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Previous Cost of f5 is 9 + 5 ⋅ n (degree is 1),{n},Call to int DiffExample.f1(int),Loop,Updated Cost of f5 is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort] +EXECUTION_TIME_UNREACHABLE_AT_EXIT, no_bucket, src/DiffExample.java, DiffExample.f8():void, 0, [Unreachable node] EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f2(int):void, 0, [Previous Cost of f2 is 3 (degree is 0),Updated Cost of f2 is 5 + 5 ⋅ x (degree is 1),{x},Loop] diff --git a/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.current b/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.current index a25f26752..995ec5495 100644 --- a/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.current +++ b/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.current @@ -6,9 +6,9 @@ */ import java.util.ArrayList; +import com.google.common.base.Preconditions; // This class has the following costs: -// 1 bottom (zero), 2 constant, 1 linear, 1 top // constructor: constant // private access$000 method for accessing f8 // f1: top @@ -18,7 +18,8 @@ import java.util.ArrayList; // f5: n log n // f6: n log n // f7: top by call to f1 -// f8: quadratic +// f8: unreachable +// f9: quadratic public class DiffExample { @@ -28,7 +29,7 @@ public class DiffExample { @Override public String toString() { - f8(z); + f9(z); return super.toString(); } }; @@ -74,8 +75,14 @@ public class DiffExample { f1(k); } + + private void f8() { + int x = 0; + Preconditions.checkArgument(false); + } + // cost: quadratic - private static void f8(int k) { + private static void f9(int k) { for (int i = 0; i < k; i++) { f4(k); } diff --git a/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.previous b/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.previous index 62fd57ec0..dc4680dc0 100644 --- a/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.previous +++ b/infer/tests/build_systems/differential_of_costs_report_java/src/DiffExample.java.previous @@ -8,7 +8,6 @@ import java.util.ArrayList; // This class has the following costs: -// 2 constant, 1 linear, 1 quadratic // constructor: constant // private access$000 method for accessing f4 // f1: linear @@ -67,4 +66,9 @@ public class DiffExample { i++; } } + + private void f8() { + int x = 0; + } + } diff --git a/infer/tests/build_systems/differential_of_costs_report_objc/Makefile b/infer/tests/build_systems/differential_of_costs_report_objc/Makefile index 2e4b05a92..907e9b54a 100644 --- a/infer/tests/build_systems/differential_of_costs_report_objc/Makefile +++ b/infer/tests/build_systems/differential_of_costs_report_objc/Makefile @@ -18,9 +18,9 @@ $(CURRENT_REPORT) $(PREVIOUS_REPORT): $(OBJC_DEPS) $(CURRENT_REPORT): $(QUIET)$(COPY) src/DiffBlock.m.current src/DiffBlock.m $(QUIET)$(call silent_on_success,Testing Cost Differential: current,\ - $(INFER_BIN) --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(CURRENT_DIR) -- clang $(CLANG_OPTIONS) src/*.m) + $(INFER_BIN) --no-filtering --cost-only -o $(CURRENT_DIR) -- clang $(CLANG_OPTIONS) src/*.m) $(PREVIOUS_REPORT): $(QUIET)$(COPY) src/DiffBlock.m.previous src/DiffBlock.m $(QUIET)$(call silent_on_success,Testing Cost Differential: previous,\ - $(INFER_BIN) --debug --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(PREVIOUS_DIR) -- clang $(CLANG_OPTIONS) src/*.m) + $(INFER_BIN) --debug --no-filtering --cost-only -o $(PREVIOUS_DIR) -- clang $(CLANG_OPTIONS) src/*.m)