From a9192cffd60b901bb1dbdc8b9014dbea912be6db Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 25 Oct 2016 04:31:09 -0700 Subject: [PATCH] [config] Eliminate ad hoc environment variables Summary: Replace the remaining uses of environment variables with command-line options. Reviewed By: cristianoc Differential Revision: D4072055 fbshipit-source-id: d8f42d5 --- infer/lib/python/inferlib/analyze.py | 3 - infer/src/backend/inferconfig.ml | 3 +- infer/src/backend/ondemand.ml | 4 +- infer/src/backend/preanal.ml | 6 +- infer/src/backend/symExec.ml | 4 +- infer/src/base/Config.ml | 231 +++++++++++------- infer/src/base/Config.mli | 28 ++- infer/src/checkers/repeatedCallsChecker.ml | 5 +- infer/src/eradicate/eradicate.ml | 14 +- infer/src/eradicate/eradicateChecks.ml | 37 +-- infer/src/eradicate/typeCheck.ml | 7 +- infer/src/eradicate/typeState.ml | 2 +- infer/tests/codetoanalyze/c/errors/Makefile | 3 +- .../codetoanalyze/java/eradicate/Makefile | 3 +- 14 files changed, 183 insertions(+), 167 deletions(-) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 4b87f3116..5987fd81a 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -289,9 +289,6 @@ class AnalyzerWrapper(object): javac_original_arguments = \ self.javac.original_arguments if self.javac is not None else [] - if self.args.analyzer == config.ANALYZER_TRACING: - os.environ['INFER_LAZY_DYNAMIC_DISPATCH'] = 'Y' - if self.args.multicore == 1: analysis_start_time = time.time() analyze_cmd = infer_analyze + infer_options diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index b23c52d7f..822642b59 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -229,9 +229,8 @@ let filters_from_inferconfig inferconfig : filters = } (* Create filters based on .inferconfig *) -(* The environment varialble NO_PATH_FILTERING disables path filtering. *) let create_filters analyzer = - if Config.from_env_variable "NO_PATH_FILTERING" then do_not_filter + if not Config.filter_paths then do_not_filter else filters_from_inferconfig (load_filters analyzer) (* Decide whether a checker or error type is enabled or disabled based on*) diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 1652e7976..d99355881 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -14,8 +14,6 @@ open! Utils module L = Logging module F = Format -let trace () = Config.from_env_variable "INFER_TRACE_ONDEMAND" - (** Read the directories to analyze from the ondemand file. *) let read_dirs_to_analyze () = match DB.read_changed_files_index with @@ -116,7 +114,7 @@ let run_proc_analysis tenv ~propagate_exceptions analyze_proc curr_pdesc callee_ (* Dot means start of a procedure *) L.log_progress_procedure (); - if trace () then L.stderr "[%d] run_proc_analysis %a -> %a@." + if Config.trace_ondemand then L.stderr "[%d] run_proc_analysis %a -> %a@." !nesting Procname.pp curr_pname Procname.pp callee_pname; diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index a8c2d41eb..cf4567ecd 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -289,17 +289,17 @@ let do_liveness pdesc tenv = let liveness_proc_cfg = BackwardCfg.from_pdesc pdesc in LivenessAnalysis.exec_cfg liveness_proc_cfg (ProcData.make_default pdesc tenv) -let doit ?(handle_dynamic_dispatch=Config.sound_dynamic_dispatch) pdesc cg tenv = +let doit ?(handle_dynamic_dispatch=Config.dynamic_dispatch_sound) pdesc cg tenv = if not (Cfg.Procdesc.did_preanalysis pdesc) then begin Cfg.Procdesc.signal_did_preanalysis pdesc; if Config.copy_propagation then do_copy_propagation pdesc tenv; let liveness_inv_map = do_liveness pdesc tenv in - if not (Config.lazy_dynamic_dispatch) && Config.copy_propagation + if not Config.dynamic_dispatch_lazy && Config.copy_propagation then remove_dead_frontend_stores pdesc liveness_inv_map; add_nullify_instrs pdesc tenv liveness_inv_map; - if not Config.lazy_dynamic_dispatch + if not Config.dynamic_dispatch_lazy then add_dispatch_calls ~handle_dynamic_dispatch pdesc cg tenv; add_abstraction_instructions pdesc; end diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 7cc7812f0..624e53145 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -553,7 +553,7 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t if !Config.curr_language <> Config.Java then (* default mode for Obj-C/C++/Java virtual calls: resolution only *) [do_resolve callee_pname receiver_exp actual_receiver_typ] - else if Config.sound_dynamic_dispatch then + else if Config.dynamic_dispatch_sound then let targets = if call_flags.CallFlags.cf_virtual then @@ -1059,7 +1059,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path | Sil.Call (ret_id, Exp.Const (Const.Cfun ((Procname.Java callee_pname_java) as callee_pname)), actual_params, loc, call_flags) - when Config.lazy_dynamic_dispatch -> + when Config.dynamic_dispatch_lazy -> let norm_prop, norm_args = normalize_params tenv current_pname prop_ actual_params in let exec_skip_call skipped_pname ret_annots ret_type = skip_call norm_prop path skipped_pname ret_annots loc ret_id (Some ret_type) norm_args in diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 932c1d646..3f72117b9 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -105,7 +105,7 @@ let checks_disabled_by_default = [ let clang_build_output_dir_name = "build_output" -let report_condition_always_true_in_clang = false +let clang_initializer_prefix = "__infer_globals_initializer_" (** Experimental: if true do some specialized analysis of concurrent constructs. *) let csl_analysis = true @@ -126,8 +126,6 @@ let filter_buckets = false let frontend_stats_dir_name = "frontend_stats" -let clang_initializer_prefix = "__infer_globals_initializer_" - let global_tenv_filename = "global.tenv" (** If true, treat calls to no-arg getters as idempotent w.r.t non-nullness *) @@ -176,6 +174,8 @@ let proc_stats_filename = "proc_stats.json" let property_attributes = "property_attributes" +let report_condition_always_true_in_clang = false + (** If true, sanity-check inferred preconditions against Nullable annotations and report inconsistencies *) let report_nullable_inconsistency = true @@ -215,6 +215,8 @@ let undo_join = true let unsafe_unret = "<\"Unsafe_unretained\">" +let use_jar_cache = true + let weak = "<\"Weak\">" let whitelisted_cpp_methods = [ @@ -313,6 +315,9 @@ let os_type = match Sys.os_type with | "Cygwin" -> Cygwin | _ -> Unix + +(** Inferconfig parsing auxiliary functions *) + let patterns_of_json_with_key json_key json = let default_method_pattern = { class_name = ""; @@ -649,11 +654,6 @@ and bugs_json = ~exes:CLOpt.[Print] ~meta:"file" "Create a file containing a list of issues in JSON format" -and frontend_tests = - CLOpt.mk_bool ~long:"frontend-tests" - ~exes:CLOpt.frontend_exes - "Save filename.ext.test.dot with the cfg in dotty format for frontend tests" - and bugs_tests = CLOpt.mk_option ~long:"issues-tests" ~f:create_outfile ~exes:CLOpt.[Print] @@ -674,10 +674,6 @@ and calls_csv = ~exes:CLOpt.[Print] ~meta:"file" "Write individual calls in csv format to a file" -and clang_biniou_file = - CLOpt.mk_string_opt ~long:"clang-biniou-file" ~exes:CLOpt.[Clang] ~meta:"file" - "Specify a file containing the AST of the program, in biniou format" - and changed_files_index = CLOpt.mk_string_opt ~long:"changed-files-index" ~exes:CLOpt.[Toplevel] ~meta:"file" "Specify the file containing the list of files from which reactive analysis should start" @@ -687,6 +683,40 @@ and check_duplicate_symbols = ~exes:CLOpt.[Analyze] "Check if a symbol with the same name is defined in more than one file." +and checkers, crashcontext, eradicate, quandary = + (* Run only the checkers instead of the full analysis *) + let checkers = + CLOpt.mk_bool ~deprecated:["checkers"] ~long:"checkers" + "" + in + (* Activate the crashcontext checker for java stack trace context reconstruction *) + let crashcontext = + CLOpt.mk_bool_group ~deprecated:["crashcontext"] ~long:"crashcontext" + "" + [checkers] + in + (* Activate the eradicate checker for java annotations (also sets --checkers) *) + let eradicate = + CLOpt.mk_bool_group ~deprecated:["eradicate"] ~long:"eradicate" + "" + [checkers] + in + (* Activate the quandary taint analysis *) + let quandary = + CLOpt.mk_bool_group ~deprecated:["quandary"] ~long:"quandary" + "" + [checkers] + in + (checkers, crashcontext, eradicate, quandary) + +and checkers_repeated_calls = + CLOpt.mk_bool ~long:"checkers-repeated-calls" + "Check for repeated calls" + +and clang_biniou_file = + CLOpt.mk_string_opt ~long:"clang-biniou-file" ~exes:CLOpt.[Clang] ~meta:"file" + "Specify a file containing the AST of the program, in biniou format" + and clang_compilation_database = CLOpt.mk_string_opt ~long:"clang-compilation-database" ~exes:CLOpt.[BuckCompilationDatabase] ~meta:"file" @@ -776,35 +806,54 @@ and dotty_cfg_libs = CLOpt.mk_bool ~deprecated:["dotty_no_cfg_libs"] ~long:"dotty-cfg-libs" ~default:true "Print the cfg of the code coming from the libraries" +and dynamic_dispatch_lazy = + CLOpt.mk_bool ~long:"dynamic-dispatch-lazy" + "Handle dynamic dispatch by following the JVM semantics and creating procedure descriptions \ + during the symbolic execution using the type information found in the abstract state" + +and dynamic_dispatch_sound = + CLOpt.mk_bool ~long:"dynamic-dispatch-sound" + "Dynamic dispatch for interface calls in Java" + and enable_checks = CLOpt.mk_string_list ~deprecated:["enable_checks"] ~long:"enable-checks" ~meta:"error name" "Show reports coming from this type of errors" -and checkers, eradicate, crashcontext, quandary = - (* Run only the checkers instead of the full analysis *) - let checkers = - CLOpt.mk_bool ~deprecated:["checkers"] ~long:"checkers" - "" - in - (* Activate the eradicate checker for java annotations (also sets --checkers) *) - let eradicate = - CLOpt.mk_bool_group ~deprecated:["eradicate"] ~long:"eradicate" - "" - [checkers] - in - (* Activate the crashcontext checker for java stack trace context reconstruction *) - let crashcontext = - CLOpt.mk_bool_group ~deprecated:["crashcontext"] ~long:"crashcontext" - "" - [checkers] - in - (* Activate the quandary taint analysis *) - let quandary = - CLOpt.mk_bool_group ~deprecated:["quandary"] ~long:"quandary" - "" - [checkers] - in - (checkers, eradicate, crashcontext, quandary) +and eradicate_condition_redundant = + CLOpt.mk_bool ~long:"eradicate-condition-redundant" + "Condition redundant warnings" + +and eradicate_field_not_mutable = + CLOpt.mk_bool ~long:"eradicate-field-not-mutable" + "Field not mutable warnings" + +and eradicate_field_over_annotated = + CLOpt.mk_bool ~long:"eradicate-field-over-annotated" + "Field over-annotated warnings" + +and eradicate_optional_present = + CLOpt.mk_bool ~long:"eradicate-optional-present" + "Check for @Present annotations" + +and eradicate_propagate_return_nullable = + CLOpt.mk_bool ~long:"eradicate-propagate-return-nullable" + "Propagation of nullable to the return value" + +and eradicate_return_over_annotated = + CLOpt.mk_bool ~long:"eradicate-return-over-annotated" + "Return over-annotated warning" + +and eradicate_debug = + CLOpt.mk_bool ~long:"eradicate-debug" + "Print debug info when errors are found" + +and eradicate_trace = + CLOpt.mk_bool ~long:"eradicate-trace" + "Print step-by-step tracing information" + +and eradicate_verbose = + CLOpt.mk_bool ~long:"eradicate-verbose" + "Print initial and final typestates" (* Use file for the err channel *) and err_file = @@ -821,6 +870,10 @@ and failures_allowed = CLOpt.mk_bool ~deprecated_no:["-no_failures_allowed"] ~long:"failures-allowed" ~default:true "Fail if at least one of the translations fails (clang only)" +and filter_paths = + CLOpt.mk_bool ~long:"filter-paths" ~default:true + "Filters specified in .inferconfig" + and filtering = CLOpt.mk_bool ~long:"filtering" ~short:"f" ~default:true ~exes:CLOpt.[Toplevel] @@ -842,6 +895,11 @@ and frontend_stats = CLOpt.mk_bool ~long:"frontend-stats" ~short:"fs" "Output statistics about the capture phase to *.o.astlog (clang only)" +and frontend_tests = + CLOpt.mk_bool ~long:"frontend-tests" + ~exes:CLOpt.frontend_exes + "Save filename.ext.test.dot with the cfg in dotty format for frontend tests" + and headers = CLOpt.mk_bool ~deprecated:["headers"] ~deprecated_no:["no_headers"] ~long:"headers" ~short:"hd" ~exes:CLOpt.[Clang] @@ -857,6 +915,12 @@ and iterations = "Specify the maximum number of operations for each function, expressed as a multiple of \ symbolic operations and a multiple of seconds of elapsed time" +and java_jar_compiler = + CLOpt.mk_string_opt + ~long:"java-jar-compiler" + ~exes:CLOpt.[Java] + ~meta:"path" "Specifify the Java compiler jar used to generate the bytecode" + and jobs = CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:"j" ~default:ncpu ~exes:CLOpt.[Toplevel] ~meta:"int" "Run the specified number of analysis jobs simultaneously" @@ -891,6 +955,10 @@ and makefile = CLOpt.mk_string ~deprecated:["makefile"] ~long:"makefile" ~default:"" ~meta:"file" "" +and margin = + CLOpt.mk_int ~deprecated:["set_pp_margin"] ~long:"margin" ~default:100 + ~meta:"int" "Set right margin for the pretty printing functions" + and merge = CLOpt.mk_bool ~deprecated:["merge"] ~long:"merge" ~exes:CLOpt.[Toplevel] @@ -950,10 +1018,6 @@ and out_file = CLOpt.mk_string ~deprecated:["out_file"] ~long:"out-file" ~default:"" ~meta:"file" "Specify the file for the non-error logs of the analyzer" -and margin = - CLOpt.mk_int ~deprecated:["set_pp_margin"] ~long:"margin" ~default:100 - ~meta:"int" "Set right margin for the pretty printing functions" - and ( patterns_modeled_expensive, patterns_never_returning_null, @@ -1017,6 +1081,10 @@ and report = CLOpt.mk_option ~deprecated:["report"] ~long:"report" ~f:create_outfile ~meta:"file" "Create a file containing a report of the analysis results" +and report_custom_error = + CLOpt.mk_bool ~long:"report-custom-error" + "" + and reports_include_ml_loc = CLOpt.mk_bool ~deprecated:["with_infer_src_loc"] ~long:"reports-include-ml-loc" "Include the location in the Infer source code from where reports are generated" @@ -1035,16 +1103,16 @@ and seconds_per_iteration = CLOpt.mk_float ~deprecated:["seconds_per_iteration"] ~long:"seconds-per-iteration" ~default:0. ~meta:"float" "Set the number of seconds per iteration (see --iterations)" -and skip_clang_analysis_in_path = - CLOpt.mk_string_list ~long:"skip-clang-analysis-in-path" - ~exes:CLOpt.[Clang] - ~meta:"path prefix" "Ignore files whose path matches the given prefix" - and skip_analysis_in_path = CLOpt.mk_string_list ~long:"skip-analysis-in-path" ~exes:CLOpt.[Clang;Java] ~meta:"path prefix" "Ignore files whose path matches the given prefix" +and skip_clang_analysis_in_path = + CLOpt.mk_string_list ~long:"skip-clang-analysis-in-path" + ~exes:CLOpt.[Clang] + ~meta:"path prefix" "Ignore files whose path matches the given prefix" + and skip_translation_headers = CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers" ~exes:CLOpt.[Clang] @@ -1134,6 +1202,11 @@ and testing_mode = CLOpt.mk_bool ~deprecated:["testing_mode"; "-testing_mode"] ~long:"testing-mode" ~short:"tm" "Mode for testing, where no headers are translated, and dot files are created (clang only)" +and thread_safety = + CLOpt.mk_bool ~long:"thread-safety" + ~exes:CLOpt.[Analyze] + "Run the experimental thread safety checker. (In conjunction with -a checkers)" + and trace_error = CLOpt.mk_bool ~deprecated:["trace_error"] ~long:"trace-error" "Detailed tracing information during error explanation" @@ -1142,6 +1215,9 @@ and trace_join = CLOpt.mk_bool ~deprecated:["trace_join"] ~long:"trace-join" "Detailed tracing information during prop join operations" +and trace_ondemand = + CLOpt.mk_bool ~long:"trace-ondemand" "" + and trace_rearrange = CLOpt.mk_bool ~deprecated:["trace_rearrange"] ~long:"trace-rearrange" "Detailed tracing information during prop re-arrangement operations" @@ -1161,11 +1237,6 @@ and unsafe_malloc = ~exes:CLOpt.[Analyze] "Assume that malloc(3) never returns null." -and thread_safety = - CLOpt.mk_bool ~long:"thread-safety" - ~exes:CLOpt.[Analyze] - "Run the experimental thread safety checker. (In conjunction with -a checkers)" - and use_compilation_database = CLOpt.mk_symbol_opt ~long:"use-compilation-database" "Buck integration using the compilation database, with or without dependencies." @@ -1227,47 +1298,16 @@ and zip_specs_library = CLOpt.mk_string_list ~long:"zip-specs-library" ~short:"ziplib" ~f:resolve ~meta:"zip file" "Search for .spec files in a zip file" -and java_jar_compiler = - CLOpt.mk_string_opt - ~long:"java-jar-compiler" - ~exes:CLOpt.[Java] - ~meta:"path" "Specifify the Java compiler jar used to generate the bytecode" - -(** Configuration values specified by environment variables *) - -let from_env_variable var_name = - try - let _ = Sys.getenv var_name in true - with Not_found -> false - -let get_env_variable var_name = - try - let v = Sys.getenv var_name in - if v = "" then None else Some v - with Not_found -> None - -(** experimental: handle dynamic dispatch by following the JVM semantics and creating - during the symbolic excution procedure descriptions using the types information - found in the abstract state *) -let lazy_dynamic_dispatch = from_env_variable "INFER_LAZY_DYNAMIC_DISPATCH" - -let report_custom_error = from_env_variable "INFER_REPORT_CUSTOM_ERROR" - -(** experimental: dynamic dispatch for interface calls only in Java. off by default because of the - cost *) -let sound_dynamic_dispatch = from_env_variable "INFER_SOUND_DYNAMIC_DISPATCH" - -let use_jar_cache = true (** Parse Command Line Args *) let exe_usage (exe : CLOpt.exe) = match exe with | Analyze -> - version_string ^ "\n\ - Usage: InferAnalyze [options]\n\ - Analyze the files captured in the project results directory, \ - which can be specified with the --results-dir option." + version_string ^ "\n" ^ + "Usage: InferAnalyze [options]\n\ + Analyze the files captured in the project results directory, which can be specified with \ + the --results-dir option." | BuckCompilationDatabase -> "Usage: BuckCompilationDatabase --Xbuck //target \n\ Runs buck with the flavor compilation-database or uber-compilation-database. It then \n\ @@ -1432,9 +1472,8 @@ and changed_files_index = !changed_files_index and calls_csv = !calls_csv and check_duplicate_symbols = !check_duplicate_symbols and checkers = !checkers - -(** should the checkers be run? *) and checkers_enabled = not (!eradicate || !crashcontext || !quandary) +and checkers_repeated_calls = !checkers_repeated_calls and clang_biniou_file = !clang_biniou_file and clang_compilation_database = !clang_compilation_database and clang_frontend_do_capture, clang_frontend_do_lint = @@ -1447,7 +1486,6 @@ and clang_frontend_do_capture, clang_frontend_do_lint = | Some Linters -> false, true (* no capture, lint *) | Some Infer -> true, false (* capture, no lint *) | _ -> true, true (* capture, lint *) - and clang_include_to_override = !clang_include_to_override and cluster_cmdline = !cluster and continue_capture = !continue @@ -1461,11 +1499,23 @@ and dependency_mode = !dependencies and developer_mode = !developer_mode and disable_checks = !disable_checks and dotty_cfg_libs = !dotty_cfg_libs +and dynamic_dispatch_lazy = (!dynamic_dispatch_lazy || !analyzer = Some Tracing) +and dynamic_dispatch_sound = !dynamic_dispatch_sound and enable_checks = !enable_checks and eradicate = !eradicate +and eradicate_condition_redundant = !eradicate_condition_redundant +and eradicate_field_not_mutable = !eradicate_field_not_mutable +and eradicate_field_over_annotated = !eradicate_field_over_annotated +and eradicate_optional_present = !eradicate_optional_present +and eradicate_propagate_return_nullable = !eradicate_propagate_return_nullable +and eradicate_return_over_annotated = !eradicate_return_over_annotated +and eradicate_debug = !eradicate_debug +and eradicate_trace = !eradicate_trace +and eradicate_verbose = !eradicate_verbose and err_file_cmdline = !err_file and fail_on_bug = !fail_on_bug and failures_allowed = !failures_allowed +and filter_paths = !filter_paths and filtering = !filtering and flavors = !flavors and frontend_debug = !frontend_debug @@ -1508,6 +1558,7 @@ and quandary = !quandary and quiet = !quiet and reactive_mode = !reactive and report = !report +and report_custom_error = !report_custom_error and report_runtime_exceptions = !tracing and reports_include_ml_loc = !reports_include_ml_loc and results_dir = !results_dir @@ -1531,6 +1582,7 @@ and test = !test and test_filtering = !test_filtering and testing_mode = !testing_mode and trace_error = !trace_error +and trace_ondemand = !trace_ondemand and trace_join = !trace_join and trace_rearrange = !trace_rearrange and type_size = !type_size @@ -1550,7 +1602,6 @@ let clang_frontend_action_string = ((if clang_frontend_do_capture then ["translating"] else []) @ (if clang_frontend_do_lint then ["linting"] else [])) - let analysis_path_regex_whitelist analyzer = IList.assoc (=) analyzer analysis_path_regex_whitelist_options and analysis_path_regex_blacklist analyzer = diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index c9cf1c3bb..f0ac901c4 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -110,6 +110,7 @@ val perf_stats_prefix : string val proc_stats_filename : string val property_attributes : string val report_condition_always_true_in_clang : bool +val report_custom_error : bool val report_nullable_inconsistency : bool val reporting_stats_dir_name : string val save_compact_summaries : bool @@ -129,18 +130,6 @@ val whitelisted_cpp_methods : string list list val wrappers_dir : string -(** Configuration values specified by environment variables *) - -val from_env_variable : string -> bool -val get_env_variable : string -> string option - -val lazy_dynamic_dispatch : bool -val report_custom_error : bool -val sound_dynamic_dispatch : bool - -val is_originator : bool - - (** Configuration values specified by command-line options *) val anon_args : string list @@ -171,6 +160,7 @@ val calls_csv : outfile option val check_duplicate_symbols : bool val checkers : bool val checkers_enabled : bool +val checkers_repeated_calls : bool val clang_biniou_file : string option val clang_compilation_database : string option val clang_frontend_action_string : string @@ -189,11 +179,23 @@ val dependency_mode : bool val developer_mode : bool val disable_checks : string list val dotty_cfg_libs : bool +val dynamic_dispatch_lazy : bool +val dynamic_dispatch_sound : bool val enable_checks : string list val eradicate : bool +val eradicate_condition_redundant : bool +val eradicate_field_not_mutable : bool +val eradicate_field_over_annotated : bool +val eradicate_optional_present : bool +val eradicate_propagate_return_nullable : bool +val eradicate_return_over_annotated : bool +val eradicate_debug : bool +val eradicate_trace : bool +val eradicate_verbose : bool val err_file_cmdline : string val fail_on_bug : bool val failures_allowed : bool +val filter_paths : bool val filtering : bool val flavors : bool val frontend_debug : bool @@ -201,6 +203,7 @@ val frontend_tests : bool val frontend_stats : bool val headers : bool val infer_cache : string option +val is_originator : bool val iterations : int val java_jar_compiler : string option val javac_verbose_out : string @@ -258,6 +261,7 @@ val test : bool val test_filtering : bool val testing_mode : bool val trace_error : bool +val trace_ondemand : bool val trace_join : bool val trace_rearrange : bool val type_size : bool diff --git a/infer/src/checkers/repeatedCallsChecker.ml b/infer/src/checkers/repeatedCallsChecker.ml index 243f15c2e..eb041c91e 100644 --- a/infer/src/checkers/repeatedCallsChecker.ml +++ b/infer/src/checkers/repeatedCallsChecker.ml @@ -14,9 +14,6 @@ module F = Format let checkers_repeated_calls_name = "CHECKERS_REPEATED_CALLS" -(* activate the check for repeated calls *) -let checkers_repeated_calls = Config.from_env_variable checkers_repeated_calls_name - (** Extension for the repeated calls check. *) module RepeatedCallsExtension : Eradicate.ExtensionT = @@ -170,7 +167,7 @@ let callback_check_repeated_calls callback_args = let checks = { TypeCheck.eradicate = false; - check_extension = checkers_repeated_calls; + check_extension = Config.checkers_repeated_calls; check_ret_type = []; } in MainRepeatedCalls.callback checks callback_args diff --git a/infer/src/eradicate/eradicate.ml b/infer/src/eradicate/eradicate.ml index 109bc9e71..8ff3de3ea 100644 --- a/infer/src/eradicate/eradicate.ml +++ b/infer/src/eradicate/eradicate.ml @@ -18,12 +18,6 @@ open Dataflow (* ERADICATE CHECKER. TODOS:*) (* 1) add support for constructors for anonymous inner classes (currently not checked) *) -(* print initial and final typestates *) -let verbose = Config.from_env_variable "ERADICATE_TYPINGS" - -(* print step-by-step tracing information *) -let trace = Config.from_env_variable "ERADICATE_TRACE" - (* check that nonnullable fields are initialized in constructors *) let check_field_initialization = true @@ -107,7 +101,7 @@ struct ret_ia ret_implicitly_nullable loc in let do_before_dataflow initial_typestate = - if verbose then + if Config.eradicate_verbose then L.stdout "Initial Typestate@\n%a@." (TypeState.pp Extension.ext) initial_typestate in @@ -126,7 +120,7 @@ struct TypeCheck.typecheck_node tenv Extension.ext calls_this checks idenv get_proc_desc curr_pname curr_pdesc find_canonical_duplicate annotated_signature typestate node linereader in - if trace then + if Config.eradicate_trace then IList.iter (fun typestate_succ -> L.stdout "Typestate After Node %a@\n%a@." @@ -314,7 +308,7 @@ struct Initializers.final_constructor_typestates_lazy proc_loc end; - if verbose then + if Config.eradicate_verbose then L.stdout "Final Typestate@\n%a@." (TypeState.pp Extension.ext) typestate in match typestate_opt with @@ -354,7 +348,7 @@ struct | Some annotated_signature -> let loc = Cfg.Procdesc.get_loc proc_desc in let linereader = Printer.LineReader.create () in - if verbose then + if Config.eradicate_verbose then L.stdout "%a@." (Annotations.pp_annotated_signature proc_name) annotated_signature; diff --git a/infer/src/eradicate/eradicateChecks.ml b/infer/src/eradicate/eradicateChecks.ml index f7b57b771..f31740585 100644 --- a/infer/src/eradicate/eradicateChecks.ml +++ b/infer/src/eradicate/eradicateChecks.ml @@ -13,25 +13,6 @@ module L = Logging (** Module for the checks called by Eradicate. *) -(* activate the condition redundant warnings *) -let activate_condition_redundant = Config.from_env_variable "ERADICATE_CONDITION_REDUNDANT" - -(* activate check for @Present annotations *) -let activate_optional_present = Config.from_env_variable "ERADICATE_OPTIONAL_PRESENT" - -(* activate the field not mutable warnings *) -let activate_field_not_mutable = Config.from_env_variable "ERADICATE_FIELD_NOT_MUTABLE" - -(* activate the field over annotated warnings *) -let activate_field_over_annotated = Config.from_env_variable "ERADICATE_FIELD_OVER_ANNOTATED" - -(* activate the return over annotated warning *) -let activate_return_over_annotated = Config.from_env_variable "ERADICATE_RETURN_OVER_ANNOTATED" - -(* activate the propagation of nullable to the return value *) -let activate_propagate_return_nullable = - Config.from_env_variable "ERADICATE_PROPAGATE_RETURN_NULLABLE" - (* do not report RETURN_NOT_NULLABLE if the return is annotated @Nonnull *) let return_nonnull_silent = true @@ -163,7 +144,7 @@ let check_condition tenv case_zero find_canonical_duplicate curr_pname let nonnull = is_fun_nonnull ta in let should_report = TypeAnnotation.get_value Annotations.Nullable ta = false && - (activate_condition_redundant || nonnull) && + (Config.eradicate_condition_redundant || nonnull) && true_branch && (not is_temp || nonnull) && PatternMatch.type_is_class typ && @@ -208,7 +189,7 @@ let check_field_assignment tenv not (Ident.java_fieldname_is_outer_instance fname) && not (field_is_field_injector_readwrite ()) in let should_report_absent = - activate_optional_present && + Config.eradicate_optional_present && TypeAnnotation.get_value Annotations.Present ta_lhs = true && TypeAnnotation.get_value Annotations.Present ta_rhs = false && not (Ident.java_fieldname_is_outer_instance fname) in @@ -216,7 +197,7 @@ let check_field_assignment tenv let field_is_mutable () = match t_ia_opt with | Some (_, ia) -> Annotations.ia_is_mutable ia | _ -> false in - activate_field_not_mutable && + Config.eradicate_field_not_mutable && not (Procname.is_constructor curr_pname) && not (Procname.is_class_initializer curr_pname) && not (field_is_mutable ()) in @@ -317,7 +298,7 @@ let check_constructor_initialization tenv curr_pname; (* Check if field is over-annotated. *) - if activate_field_over_annotated && + if Config.eradicate_field_over_annotated && nullable_annotated && not (may_be_nullable_in_final_typestate ()) then report_error tenv @@ -371,19 +352,19 @@ let check_return_annotation tenv not ret_implicitly_nullable && not (return_nonnull_silent && ret_annotated_nonnull) in let return_value_not_present = - activate_optional_present && + Config.eradicate_optional_present && not final_present && ret_annotated_present in let return_over_annotated = not final_nullable && ret_annotated_nullable && - activate_return_over_annotated in + Config.eradicate_return_over_annotated in if return_not_nullable && Models.Inference.enabled then Models.Inference.proc_mark_return_nullable curr_pname; if return_not_nullable && - activate_propagate_return_nullable + Config.eradicate_propagate_return_nullable then spec_make_return_nullable curr_pname; @@ -432,7 +413,7 @@ let check_call_receiver tenv (typ, TypeAnnotation.const Annotations.Nullable false TypeOrigin.ONone, []) loc in let null_method_call = TypeAnnotation.get_value Annotations.Nullable this_ta in let optional_get_on_absent = - activate_optional_present && + Config.eradicate_optional_present && Models.is_optional_get callee_pname && not (TypeAnnotation.get_value Annotations.Present this_ta) in if null_method_call || optional_get_on_absent then @@ -471,7 +452,7 @@ let check_call_parameters tenv not formal_is_nullable && TypeAnnotation.get_value Annotations.Nullable ta2 in let parameter_absent = - activate_optional_present && + Config.eradicate_optional_present && not param_is_this && PatternMatch.type_is_class t1 && formal_is_present && diff --git a/infer/src/eradicate/typeCheck.ml b/infer/src/eradicate/typeCheck.ml index a95f2db76..a74f21341 100644 --- a/infer/src/eradicate/typeCheck.ml +++ b/infer/src/eradicate/typeCheck.ml @@ -17,9 +17,6 @@ module DExp = DecompiledExp let remove_temps = true (* remove temp ids from typestates *) -(* print debug info when errors are found *) -let debug = Config.from_env_variable "ERADICATE_DEBUG" - (** Module to treat selected complex expressions as constants. *) module ComplexExpressions = struct @@ -637,7 +634,7 @@ let typecheck_instr match TypeState.lookup_pvar pvar typestate'' with | Some (t, ta, _) -> let should_report = - EradicateChecks.activate_condition_redundant && + Config.eradicate_condition_redundant && TypeAnnotation.get_value Annotations.Nullable ta = false && not (TypeAnnotation.origin_is_fun_library ta) in if checks.eradicate && should_report then @@ -786,7 +783,7 @@ let typecheck_instr let typestate2 = if not is_anonymous_inner_class_constructor then begin - if debug then + if Config.eradicate_debug then begin let unique_id = Procname.to_unique_id callee_pname in let classification = diff --git a/infer/src/eradicate/typeState.ml b/infer/src/eradicate/typeState.ml index dfebec6da..e3bc04fcc 100644 --- a/infer/src/eradicate/typeState.ml +++ b/infer/src/eradicate/typeState.ml @@ -120,7 +120,7 @@ let map_join m1 m2 = ) let join ext t1 t2 = - if Config.from_env_variable "ERADICATE_TRACE" + if Config.eradicate_trace then L.stderr "@.@.**********join@.-------@.%a@.------@.%a@.********@.@." (pp ext) t1 (pp ext) t2; diff --git a/infer/tests/codetoanalyze/c/errors/Makefile b/infer/tests/codetoanalyze/c/errors/Makefile index 1616b1d96..8c86b41d6 100644 --- a/infer/tests/codetoanalyze/c/errors/Makefile +++ b/infer/tests/codetoanalyze/c/errors/Makefile @@ -16,6 +16,5 @@ compile: clang $(OPTIONS) $(FILES) analyze: - INFER_REPORT_CUSTOM_ERROR=1 \ - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --check-duplicate-symbols --developer-mode -- clang $(OPTIONS) $(FILES) 2>duplicates.txt) + $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --report-custom-error --check-duplicate-symbols --developer-mode -- clang $(OPTIONS) $(FILES) 2>duplicates.txt) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 diff --git a/infer/tests/codetoanalyze/java/eradicate/Makefile b/infer/tests/codetoanalyze/java/eradicate/Makefile index 21d07cdf5..b105611cf 100644 --- a/infer/tests/codetoanalyze/java/eradicate/Makefile +++ b/infer/tests/codetoanalyze/java/eradicate/Makefile @@ -28,5 +28,4 @@ compile: javac -cp $(CLASSPATH) $(FILES) analyze: - ERADICATE_RETURN_OVER_ANNOTATED=1 \ - $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES)) + $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --eradicate-return-over-annotated -- javac -cp $(CLASSPATH) $(FILES))