diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 24981413a..eaab8e677 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2195,6 +2195,11 @@ and unsafe_malloc = "Assume that malloc(3) never returns null." +and use_cost_threshold = + CLOpt.mk_bool ~long:"use-cost-threshold" ~default:false + "Emit costs issues by comparing costs with a set threshold" + + and version = let var = ref `None in CLOpt.mk_set var `Full ~deprecated:["version"] ~long:"version" @@ -2980,6 +2985,8 @@ and uninit_interproc = !uninit_interproc and unsafe_malloc = !unsafe_malloc +and use_cost_threshold = !use_cost_threshold + and worklist_mode = !worklist_mode and write_dotty = !write_dotty diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index e721d829c..e3c9cea45 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -200,6 +200,8 @@ val undo_join : bool val unsafe_unret : string +val use_cost_threshold : bool + val weak : string val whitelisted_cpp_methods : string list diff --git a/infer/src/checkers/cost.ml b/infer/src/checkers/cost.ml index 5a12be395..9e89609f8 100644 --- a/infer/src/checkers/cost.ml +++ b/infer/src/checkers/cost.ml @@ -629,7 +629,9 @@ module TransferFunctionsWCET = struct (* We don't report when the cost is Top as it corresponds to subsequent 'don't know's. Instead, we report Top cost only at the top level per function when `report_infinity` is set to true *) let should_report_cost cost = - (not (BasicCost.is_top cost)) && not (BasicCost.( <= ) ~lhs:cost ~rhs:expensive_threshold) + Config.use_cost_threshold + && (not (BasicCost.is_top cost)) + && not (BasicCost.( <= ) ~lhs:cost ~rhs:expensive_threshold) let do_report summary loc cost = diff --git a/infer/tests/codetoanalyze/c/performance/Makefile b/infer/tests/codetoanalyze/c/performance/Makefile index e8aabbab0..4b8b4673e 100644 --- a/infer/tests/codetoanalyze/c/performance/Makefile +++ b/infer/tests/codetoanalyze/c/performance/Makefile @@ -8,7 +8,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers # see explanations in cpp/errors/Makefile for the custom isystem CLANG_OPTIONS = -c -INFER_OPTIONS = --cost-only --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --cost-only --debug-exceptions --project-root $(TESTS_DIR) --use-cost-threshold INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.c) diff --git a/infer/tests/codetoanalyze/java/performance/Makefile b/infer/tests/codetoanalyze/java/performance/Makefile index 63496791a..91cdc2d33 100644 --- a/infer/tests/codetoanalyze/java/performance/Makefile +++ b/infer/tests/codetoanalyze/java/performance/Makefile @@ -6,7 +6,7 @@ TESTS_DIR = ../../.. ANALYZER = checkers -INFER_OPTIONS = --cost-only --debug-exceptions +INFER_OPTIONS = --cost-only --debug-exceptions --use-cost-threshold INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.java)