[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
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 219832a9a8
commit a9192cffd6

@ -289,9 +289,6 @@ class AnalyzerWrapper(object):
javac_original_arguments = \ javac_original_arguments = \
self.javac.original_arguments if self.javac is not None else [] 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: if self.args.multicore == 1:
analysis_start_time = time.time() analysis_start_time = time.time()
analyze_cmd = infer_analyze + infer_options analyze_cmd = infer_analyze + infer_options

@ -229,9 +229,8 @@ let filters_from_inferconfig inferconfig : filters =
} }
(* Create filters based on .inferconfig *) (* Create filters based on .inferconfig *)
(* The environment varialble NO_PATH_FILTERING disables path filtering. *)
let create_filters analyzer = 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) else filters_from_inferconfig (load_filters analyzer)
(* Decide whether a checker or error type is enabled or disabled based on*) (* Decide whether a checker or error type is enabled or disabled based on*)

@ -14,8 +14,6 @@ open! Utils
module L = Logging module L = Logging
module F = Format module F = Format
let trace () = Config.from_env_variable "INFER_TRACE_ONDEMAND"
(** Read the directories to analyze from the ondemand file. *) (** Read the directories to analyze from the ondemand file. *)
let read_dirs_to_analyze () = let read_dirs_to_analyze () =
match DB.read_changed_files_index with 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 *) (* Dot means start of a procedure *)
L.log_progress_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 !nesting
Procname.pp curr_pname Procname.pp curr_pname
Procname.pp callee_pname; Procname.pp callee_pname;

@ -289,17 +289,17 @@ let do_liveness pdesc tenv =
let liveness_proc_cfg = BackwardCfg.from_pdesc pdesc in let liveness_proc_cfg = BackwardCfg.from_pdesc pdesc in
LivenessAnalysis.exec_cfg liveness_proc_cfg (ProcData.make_default pdesc tenv) 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) if not (Cfg.Procdesc.did_preanalysis pdesc)
then then
begin begin
Cfg.Procdesc.signal_did_preanalysis pdesc; Cfg.Procdesc.signal_did_preanalysis pdesc;
if Config.copy_propagation then do_copy_propagation pdesc tenv; if Config.copy_propagation then do_copy_propagation pdesc tenv;
let liveness_inv_map = do_liveness pdesc tenv in 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; then remove_dead_frontend_stores pdesc liveness_inv_map;
add_nullify_instrs pdesc tenv 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; then add_dispatch_calls ~handle_dynamic_dispatch pdesc cg tenv;
add_abstraction_instructions pdesc; add_abstraction_instructions pdesc;
end end

@ -553,7 +553,7 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t
if !Config.curr_language <> Config.Java then if !Config.curr_language <> Config.Java then
(* default mode for Obj-C/C++/Java virtual calls: resolution only *) (* default mode for Obj-C/C++/Java virtual calls: resolution only *)
[do_resolve callee_pname receiver_exp actual_receiver_typ] [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 = let targets =
if call_flags.CallFlags.cf_virtual if call_flags.CallFlags.cf_virtual
then then
@ -1059,7 +1059,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path
| Sil.Call (ret_id, | Sil.Call (ret_id,
Exp.Const (Const.Cfun ((Procname.Java callee_pname_java) as callee_pname)), Exp.Const (Const.Cfun ((Procname.Java callee_pname_java) as callee_pname)),
actual_params, loc, call_flags) 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 norm_prop, norm_args = normalize_params tenv current_pname prop_ actual_params in
let exec_skip_call skipped_pname ret_annots ret_type = 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 skip_call norm_prop path skipped_pname ret_annots loc ret_id (Some ret_type) norm_args in

@ -105,7 +105,7 @@ let checks_disabled_by_default = [
let clang_build_output_dir_name = "build_output" 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. *) (** Experimental: if true do some specialized analysis of concurrent constructs. *)
let csl_analysis = true let csl_analysis = true
@ -126,8 +126,6 @@ let filter_buckets = false
let frontend_stats_dir_name = "frontend_stats" let frontend_stats_dir_name = "frontend_stats"
let clang_initializer_prefix = "__infer_globals_initializer_"
let global_tenv_filename = "global.tenv" let global_tenv_filename = "global.tenv"
(** If true, treat calls to no-arg getters as idempotent w.r.t non-nullness *) (** 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 property_attributes = "property_attributes"
let report_condition_always_true_in_clang = false
(** If true, sanity-check inferred preconditions against Nullable annotations and report (** If true, sanity-check inferred preconditions against Nullable annotations and report
inconsistencies *) inconsistencies *)
let report_nullable_inconsistency = true let report_nullable_inconsistency = true
@ -215,6 +215,8 @@ let undo_join = true
let unsafe_unret = "<\"Unsafe_unretained\">" let unsafe_unret = "<\"Unsafe_unretained\">"
let use_jar_cache = true
let weak = "<\"Weak\">" let weak = "<\"Weak\">"
let whitelisted_cpp_methods = [ let whitelisted_cpp_methods = [
@ -313,6 +315,9 @@ let os_type = match Sys.os_type with
| "Cygwin" -> Cygwin | "Cygwin" -> Cygwin
| _ -> Unix | _ -> Unix
(** Inferconfig parsing auxiliary functions *)
let patterns_of_json_with_key json_key json = let patterns_of_json_with_key json_key json =
let default_method_pattern = { let default_method_pattern = {
class_name = ""; class_name = "";
@ -649,11 +654,6 @@ and bugs_json =
~exes:CLOpt.[Print] ~exes:CLOpt.[Print]
~meta:"file" "Create a file containing a list of issues in JSON format" ~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 = and bugs_tests =
CLOpt.mk_option ~long:"issues-tests" ~f:create_outfile CLOpt.mk_option ~long:"issues-tests" ~f:create_outfile
~exes:CLOpt.[Print] ~exes:CLOpt.[Print]
@ -674,10 +674,6 @@ and calls_csv =
~exes:CLOpt.[Print] ~exes:CLOpt.[Print]
~meta:"file" "Write individual calls in csv format to a file" ~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 = and changed_files_index =
CLOpt.mk_string_opt ~long:"changed-files-index" ~exes:CLOpt.[Toplevel] ~meta:"file" 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" "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] ~exes:CLOpt.[Analyze]
"Check if a symbol with the same name is defined in more than one file." "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 = and clang_compilation_database =
CLOpt.mk_string_opt ~long:"clang-compilation-database" CLOpt.mk_string_opt ~long:"clang-compilation-database"
~exes:CLOpt.[BuckCompilationDatabase] ~meta:"file" ~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 CLOpt.mk_bool ~deprecated:["dotty_no_cfg_libs"] ~long:"dotty-cfg-libs" ~default:true
"Print the cfg of the code coming from the libraries" "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 = and enable_checks =
CLOpt.mk_string_list ~deprecated:["enable_checks"] ~long:"enable-checks" ~meta:"error name" CLOpt.mk_string_list ~deprecated:["enable_checks"] ~long:"enable-checks" ~meta:"error name"
"Show reports coming from this type of errors" "Show reports coming from this type of errors"
and checkers, eradicate, crashcontext, quandary = and eradicate_condition_redundant =
(* Run only the checkers instead of the full analysis *) CLOpt.mk_bool ~long:"eradicate-condition-redundant"
let checkers = "Condition redundant warnings"
CLOpt.mk_bool ~deprecated:["checkers"] ~long:"checkers"
"" and eradicate_field_not_mutable =
in CLOpt.mk_bool ~long:"eradicate-field-not-mutable"
(* Activate the eradicate checker for java annotations (also sets --checkers) *) "Field not mutable warnings"
let eradicate =
CLOpt.mk_bool_group ~deprecated:["eradicate"] ~long:"eradicate" and eradicate_field_over_annotated =
"" CLOpt.mk_bool ~long:"eradicate-field-over-annotated"
[checkers] "Field over-annotated warnings"
in
(* Activate the crashcontext checker for java stack trace context reconstruction *) and eradicate_optional_present =
let crashcontext = CLOpt.mk_bool ~long:"eradicate-optional-present"
CLOpt.mk_bool_group ~deprecated:["crashcontext"] ~long:"crashcontext" "Check for @Present annotations"
""
[checkers] and eradicate_propagate_return_nullable =
in CLOpt.mk_bool ~long:"eradicate-propagate-return-nullable"
(* Activate the quandary taint analysis *) "Propagation of nullable to the return value"
let quandary =
CLOpt.mk_bool_group ~deprecated:["quandary"] ~long:"quandary" and eradicate_return_over_annotated =
"" CLOpt.mk_bool ~long:"eradicate-return-over-annotated"
[checkers] "Return over-annotated warning"
in
(checkers, eradicate, crashcontext, quandary) 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 *) (* Use file for the err channel *)
and err_file = and err_file =
@ -821,6 +870,10 @@ and failures_allowed =
CLOpt.mk_bool ~deprecated_no:["-no_failures_allowed"] ~long:"failures-allowed" ~default:true CLOpt.mk_bool ~deprecated_no:["-no_failures_allowed"] ~long:"failures-allowed" ~default:true
"Fail if at least one of the translations fails (clang only)" "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 = and filtering =
CLOpt.mk_bool ~long:"filtering" ~short:"f" ~default:true CLOpt.mk_bool ~long:"filtering" ~short:"f" ~default:true
~exes:CLOpt.[Toplevel] ~exes:CLOpt.[Toplevel]
@ -842,6 +895,11 @@ and frontend_stats =
CLOpt.mk_bool ~long:"frontend-stats" ~short:"fs" CLOpt.mk_bool ~long:"frontend-stats" ~short:"fs"
"Output statistics about the capture phase to *.o.astlog (clang only)" "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 = and headers =
CLOpt.mk_bool ~deprecated:["headers"] ~deprecated_no:["no_headers"] ~long:"headers" ~short:"hd" CLOpt.mk_bool ~deprecated:["headers"] ~deprecated_no:["no_headers"] ~long:"headers" ~short:"hd"
~exes:CLOpt.[Clang] ~exes:CLOpt.[Clang]
@ -857,6 +915,12 @@ and iterations =
"Specify the maximum number of operations for each function, expressed as a multiple of \ "Specify the maximum number of operations for each function, expressed as a multiple of \
symbolic operations and a multiple of seconds of elapsed time" 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 = and jobs =
CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:"j" ~default:ncpu CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:"j" ~default:ncpu
~exes:CLOpt.[Toplevel] ~meta:"int" "Run the specified number of analysis jobs simultaneously" ~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:"" CLOpt.mk_string ~deprecated:["makefile"] ~long:"makefile" ~default:""
~meta:"file" "" ~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 = and merge =
CLOpt.mk_bool ~deprecated:["merge"] ~long:"merge" CLOpt.mk_bool ~deprecated:["merge"] ~long:"merge"
~exes:CLOpt.[Toplevel] ~exes:CLOpt.[Toplevel]
@ -950,10 +1018,6 @@ and out_file =
CLOpt.mk_string ~deprecated:["out_file"] ~long:"out-file" ~default:"" CLOpt.mk_string ~deprecated:["out_file"] ~long:"out-file" ~default:""
~meta:"file" "Specify the file for the non-error logs of the analyzer" ~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 ( and (
patterns_modeled_expensive, patterns_modeled_expensive,
patterns_never_returning_null, patterns_never_returning_null,
@ -1017,6 +1081,10 @@ and report =
CLOpt.mk_option ~deprecated:["report"] ~long:"report" ~f:create_outfile CLOpt.mk_option ~deprecated:["report"] ~long:"report" ~f:create_outfile
~meta:"file" "Create a file containing a report of the analysis results" ~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 = and reports_include_ml_loc =
CLOpt.mk_bool ~deprecated:["with_infer_src_loc"] ~long:"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" "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. CLOpt.mk_float ~deprecated:["seconds_per_iteration"] ~long:"seconds-per-iteration" ~default:0.
~meta:"float" "Set the number of seconds per iteration (see --iterations)" ~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 = and skip_analysis_in_path =
CLOpt.mk_string_list ~long:"skip-analysis-in-path" CLOpt.mk_string_list ~long:"skip-analysis-in-path"
~exes:CLOpt.[Clang;Java] ~exes:CLOpt.[Clang;Java]
~meta:"path prefix" "Ignore files whose path matches the given prefix" ~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 = and skip_translation_headers =
CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers" CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers"
~exes:CLOpt.[Clang] ~exes:CLOpt.[Clang]
@ -1134,6 +1202,11 @@ and testing_mode =
CLOpt.mk_bool ~deprecated:["testing_mode"; "-testing_mode"] ~long:"testing-mode" ~short:"tm" 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)" "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 = and trace_error =
CLOpt.mk_bool ~deprecated:["trace_error"] ~long:"trace-error" CLOpt.mk_bool ~deprecated:["trace_error"] ~long:"trace-error"
"Detailed tracing information during error explanation" "Detailed tracing information during error explanation"
@ -1142,6 +1215,9 @@ and trace_join =
CLOpt.mk_bool ~deprecated:["trace_join"] ~long:"trace-join" CLOpt.mk_bool ~deprecated:["trace_join"] ~long:"trace-join"
"Detailed tracing information during prop join operations" "Detailed tracing information during prop join operations"
and trace_ondemand =
CLOpt.mk_bool ~long:"trace-ondemand" ""
and trace_rearrange = and trace_rearrange =
CLOpt.mk_bool ~deprecated:["trace_rearrange"] ~long:"trace-rearrange" CLOpt.mk_bool ~deprecated:["trace_rearrange"] ~long:"trace-rearrange"
"Detailed tracing information during prop re-arrangement operations" "Detailed tracing information during prop re-arrangement operations"
@ -1161,11 +1237,6 @@ and unsafe_malloc =
~exes:CLOpt.[Analyze] ~exes:CLOpt.[Analyze]
"Assume that malloc(3) never returns null." "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 = and use_compilation_database =
CLOpt.mk_symbol_opt ~long:"use-compilation-database" CLOpt.mk_symbol_opt ~long:"use-compilation-database"
"Buck integration using the compilation database, with or without dependencies." "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 CLOpt.mk_string_list ~long:"zip-specs-library" ~short:"ziplib" ~f:resolve
~meta:"zip file" "Search for .spec files in a zip file" ~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 *) (** Parse Command Line Args *)
let exe_usage (exe : CLOpt.exe) = let exe_usage (exe : CLOpt.exe) =
match exe with match exe with
| Analyze -> | Analyze ->
version_string ^ "\n\ version_string ^ "\n" ^
Usage: InferAnalyze [options]\n\ "Usage: InferAnalyze [options]\n\
Analyze the files captured in the project results directory, \ Analyze the files captured in the project results directory, which can be specified with \
which can be specified with the --results-dir option." the --results-dir option."
| BuckCompilationDatabase -> | BuckCompilationDatabase ->
"Usage: BuckCompilationDatabase --Xbuck //target \n\ "Usage: BuckCompilationDatabase --Xbuck //target \n\
Runs buck with the flavor compilation-database or uber-compilation-database. It then \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 calls_csv = !calls_csv
and check_duplicate_symbols = !check_duplicate_symbols and check_duplicate_symbols = !check_duplicate_symbols
and checkers = !checkers and checkers = !checkers
(** should the checkers be run? *)
and checkers_enabled = not (!eradicate || !crashcontext || !quandary) and checkers_enabled = not (!eradicate || !crashcontext || !quandary)
and checkers_repeated_calls = !checkers_repeated_calls
and clang_biniou_file = !clang_biniou_file and clang_biniou_file = !clang_biniou_file
and clang_compilation_database = !clang_compilation_database and clang_compilation_database = !clang_compilation_database
and clang_frontend_do_capture, clang_frontend_do_lint = 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 Linters -> false, true (* no capture, lint *)
| Some Infer -> true, false (* capture, no lint *) | Some Infer -> true, false (* capture, no lint *)
| _ -> true, true (* capture, lint *) | _ -> true, true (* capture, lint *)
and clang_include_to_override = !clang_include_to_override and clang_include_to_override = !clang_include_to_override
and cluster_cmdline = !cluster and cluster_cmdline = !cluster
and continue_capture = !continue and continue_capture = !continue
@ -1461,11 +1499,23 @@ and dependency_mode = !dependencies
and developer_mode = !developer_mode and developer_mode = !developer_mode
and disable_checks = !disable_checks and disable_checks = !disable_checks
and dotty_cfg_libs = !dotty_cfg_libs 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 enable_checks = !enable_checks
and eradicate = !eradicate 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 err_file_cmdline = !err_file
and fail_on_bug = !fail_on_bug and fail_on_bug = !fail_on_bug
and failures_allowed = !failures_allowed and failures_allowed = !failures_allowed
and filter_paths = !filter_paths
and filtering = !filtering and filtering = !filtering
and flavors = !flavors and flavors = !flavors
and frontend_debug = !frontend_debug and frontend_debug = !frontend_debug
@ -1508,6 +1558,7 @@ and quandary = !quandary
and quiet = !quiet and quiet = !quiet
and reactive_mode = !reactive and reactive_mode = !reactive
and report = !report and report = !report
and report_custom_error = !report_custom_error
and report_runtime_exceptions = !tracing and report_runtime_exceptions = !tracing
and reports_include_ml_loc = !reports_include_ml_loc and reports_include_ml_loc = !reports_include_ml_loc
and results_dir = !results_dir and results_dir = !results_dir
@ -1531,6 +1582,7 @@ and test = !test
and test_filtering = !test_filtering and test_filtering = !test_filtering
and testing_mode = !testing_mode and testing_mode = !testing_mode
and trace_error = !trace_error and trace_error = !trace_error
and trace_ondemand = !trace_ondemand
and trace_join = !trace_join and trace_join = !trace_join
and trace_rearrange = !trace_rearrange and trace_rearrange = !trace_rearrange
and type_size = !type_size 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_capture then ["translating"] else [])
@ (if clang_frontend_do_lint then ["linting"] else [])) @ (if clang_frontend_do_lint then ["linting"] else []))
let analysis_path_regex_whitelist analyzer = let analysis_path_regex_whitelist analyzer =
IList.assoc (=) analyzer analysis_path_regex_whitelist_options IList.assoc (=) analyzer analysis_path_regex_whitelist_options
and analysis_path_regex_blacklist analyzer = and analysis_path_regex_blacklist analyzer =

@ -110,6 +110,7 @@ val perf_stats_prefix : string
val proc_stats_filename : string val proc_stats_filename : string
val property_attributes : string val property_attributes : string
val report_condition_always_true_in_clang : bool val report_condition_always_true_in_clang : bool
val report_custom_error : bool
val report_nullable_inconsistency : bool val report_nullable_inconsistency : bool
val reporting_stats_dir_name : string val reporting_stats_dir_name : string
val save_compact_summaries : bool val save_compact_summaries : bool
@ -129,18 +130,6 @@ val whitelisted_cpp_methods : string list list
val wrappers_dir : string 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 *) (** Configuration values specified by command-line options *)
val anon_args : string list val anon_args : string list
@ -171,6 +160,7 @@ val calls_csv : outfile option
val check_duplicate_symbols : bool val check_duplicate_symbols : bool
val checkers : bool val checkers : bool
val checkers_enabled : bool val checkers_enabled : bool
val checkers_repeated_calls : bool
val clang_biniou_file : string option val clang_biniou_file : string option
val clang_compilation_database : string option val clang_compilation_database : string option
val clang_frontend_action_string : string val clang_frontend_action_string : string
@ -189,11 +179,23 @@ val dependency_mode : bool
val developer_mode : bool val developer_mode : bool
val disable_checks : string list val disable_checks : string list
val dotty_cfg_libs : bool val dotty_cfg_libs : bool
val dynamic_dispatch_lazy : bool
val dynamic_dispatch_sound : bool
val enable_checks : string list val enable_checks : string list
val eradicate : bool 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 err_file_cmdline : string
val fail_on_bug : bool val fail_on_bug : bool
val failures_allowed : bool val failures_allowed : bool
val filter_paths : bool
val filtering : bool val filtering : bool
val flavors : bool val flavors : bool
val frontend_debug : bool val frontend_debug : bool
@ -201,6 +203,7 @@ val frontend_tests : bool
val frontend_stats : bool val frontend_stats : bool
val headers : bool val headers : bool
val infer_cache : string option val infer_cache : string option
val is_originator : bool
val iterations : int val iterations : int
val java_jar_compiler : string option val java_jar_compiler : string option
val javac_verbose_out : string val javac_verbose_out : string
@ -258,6 +261,7 @@ val test : bool
val test_filtering : bool val test_filtering : bool
val testing_mode : bool val testing_mode : bool
val trace_error : bool val trace_error : bool
val trace_ondemand : bool
val trace_join : bool val trace_join : bool
val trace_rearrange : bool val trace_rearrange : bool
val type_size : bool val type_size : bool

@ -14,9 +14,6 @@ module F = Format
let checkers_repeated_calls_name = "CHECKERS_REPEATED_CALLS" 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. *) (** Extension for the repeated calls check. *)
module RepeatedCallsExtension : Eradicate.ExtensionT = module RepeatedCallsExtension : Eradicate.ExtensionT =
@ -170,7 +167,7 @@ let callback_check_repeated_calls callback_args =
let checks = let checks =
{ {
TypeCheck.eradicate = false; TypeCheck.eradicate = false;
check_extension = checkers_repeated_calls; check_extension = Config.checkers_repeated_calls;
check_ret_type = []; check_ret_type = [];
} in } in
MainRepeatedCalls.callback checks callback_args MainRepeatedCalls.callback checks callback_args

@ -18,12 +18,6 @@ open Dataflow
(* ERADICATE CHECKER. TODOS:*) (* ERADICATE CHECKER. TODOS:*)
(* 1) add support for constructors for anonymous inner classes (currently not checked) *) (* 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 *) (* check that nonnullable fields are initialized in constructors *)
let check_field_initialization = true let check_field_initialization = true
@ -107,7 +101,7 @@ struct
ret_ia ret_implicitly_nullable loc in ret_ia ret_implicitly_nullable loc in
let do_before_dataflow initial_typestate = let do_before_dataflow initial_typestate =
if verbose then if Config.eradicate_verbose then
L.stdout "Initial Typestate@\n%a@." L.stdout "Initial Typestate@\n%a@."
(TypeState.pp Extension.ext) initial_typestate in (TypeState.pp Extension.ext) initial_typestate in
@ -126,7 +120,7 @@ struct
TypeCheck.typecheck_node TypeCheck.typecheck_node
tenv Extension.ext calls_this checks idenv get_proc_desc curr_pname curr_pdesc tenv Extension.ext calls_this checks idenv get_proc_desc curr_pname curr_pdesc
find_canonical_duplicate annotated_signature typestate node linereader in find_canonical_duplicate annotated_signature typestate node linereader in
if trace then if Config.eradicate_trace then
IList.iter (fun typestate_succ -> IList.iter (fun typestate_succ ->
L.stdout L.stdout
"Typestate After Node %a@\n%a@." "Typestate After Node %a@\n%a@."
@ -314,7 +308,7 @@ struct
Initializers.final_constructor_typestates_lazy Initializers.final_constructor_typestates_lazy
proc_loc proc_loc
end; end;
if verbose then if Config.eradicate_verbose then
L.stdout "Final Typestate@\n%a@." L.stdout "Final Typestate@\n%a@."
(TypeState.pp Extension.ext) typestate in (TypeState.pp Extension.ext) typestate in
match typestate_opt with match typestate_opt with
@ -354,7 +348,7 @@ struct
| Some annotated_signature -> | Some annotated_signature ->
let loc = Cfg.Procdesc.get_loc proc_desc in let loc = Cfg.Procdesc.get_loc proc_desc in
let linereader = Printer.LineReader.create () in let linereader = Printer.LineReader.create () in
if verbose then if Config.eradicate_verbose then
L.stdout "%a@." L.stdout "%a@."
(Annotations.pp_annotated_signature proc_name) (Annotations.pp_annotated_signature proc_name)
annotated_signature; annotated_signature;

@ -13,25 +13,6 @@ module L = Logging
(** Module for the checks called by Eradicate. *) (** 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 *) (* do not report RETURN_NOT_NULLABLE if the return is annotated @Nonnull *)
let return_nonnull_silent = true 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 nonnull = is_fun_nonnull ta in
let should_report = let should_report =
TypeAnnotation.get_value Annotations.Nullable ta = false && TypeAnnotation.get_value Annotations.Nullable ta = false &&
(activate_condition_redundant || nonnull) && (Config.eradicate_condition_redundant || nonnull) &&
true_branch && true_branch &&
(not is_temp || nonnull) && (not is_temp || nonnull) &&
PatternMatch.type_is_class typ && PatternMatch.type_is_class typ &&
@ -208,7 +189,7 @@ let check_field_assignment tenv
not (Ident.java_fieldname_is_outer_instance fname) && not (Ident.java_fieldname_is_outer_instance fname) &&
not (field_is_field_injector_readwrite ()) in not (field_is_field_injector_readwrite ()) in
let should_report_absent = 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_lhs = true &&
TypeAnnotation.get_value Annotations.Present ta_rhs = false && TypeAnnotation.get_value Annotations.Present ta_rhs = false &&
not (Ident.java_fieldname_is_outer_instance fname) in 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 let field_is_mutable () = match t_ia_opt with
| Some (_, ia) -> Annotations.ia_is_mutable ia | Some (_, ia) -> Annotations.ia_is_mutable ia
| _ -> false in | _ -> false in
activate_field_not_mutable && Config.eradicate_field_not_mutable &&
not (Procname.is_constructor curr_pname) && not (Procname.is_constructor curr_pname) &&
not (Procname.is_class_initializer curr_pname) && not (Procname.is_class_initializer curr_pname) &&
not (field_is_mutable ()) in not (field_is_mutable ()) in
@ -317,7 +298,7 @@ let check_constructor_initialization tenv
curr_pname; curr_pname;
(* Check if field is over-annotated. *) (* Check if field is over-annotated. *)
if activate_field_over_annotated && if Config.eradicate_field_over_annotated &&
nullable_annotated && nullable_annotated &&
not (may_be_nullable_in_final_typestate ()) then not (may_be_nullable_in_final_typestate ()) then
report_error tenv report_error tenv
@ -371,19 +352,19 @@ let check_return_annotation tenv
not ret_implicitly_nullable && not ret_implicitly_nullable &&
not (return_nonnull_silent && ret_annotated_nonnull) in not (return_nonnull_silent && ret_annotated_nonnull) in
let return_value_not_present = let return_value_not_present =
activate_optional_present && Config.eradicate_optional_present &&
not final_present && not final_present &&
ret_annotated_present in ret_annotated_present in
let return_over_annotated = let return_over_annotated =
not final_nullable && not final_nullable &&
ret_annotated_nullable && ret_annotated_nullable &&
activate_return_over_annotated in Config.eradicate_return_over_annotated in
if return_not_nullable && Models.Inference.enabled then if return_not_nullable && Models.Inference.enabled then
Models.Inference.proc_mark_return_nullable curr_pname; Models.Inference.proc_mark_return_nullable curr_pname;
if return_not_nullable && if return_not_nullable &&
activate_propagate_return_nullable Config.eradicate_propagate_return_nullable
then then
spec_make_return_nullable curr_pname; 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 (typ, TypeAnnotation.const Annotations.Nullable false TypeOrigin.ONone, []) loc in
let null_method_call = TypeAnnotation.get_value Annotations.Nullable this_ta in let null_method_call = TypeAnnotation.get_value Annotations.Nullable this_ta in
let optional_get_on_absent = let optional_get_on_absent =
activate_optional_present && Config.eradicate_optional_present &&
Models.is_optional_get callee_pname && Models.is_optional_get callee_pname &&
not (TypeAnnotation.get_value Annotations.Present this_ta) in not (TypeAnnotation.get_value Annotations.Present this_ta) in
if null_method_call || optional_get_on_absent then if null_method_call || optional_get_on_absent then
@ -471,7 +452,7 @@ let check_call_parameters tenv
not formal_is_nullable && not formal_is_nullable &&
TypeAnnotation.get_value Annotations.Nullable ta2 in TypeAnnotation.get_value Annotations.Nullable ta2 in
let parameter_absent = let parameter_absent =
activate_optional_present && Config.eradicate_optional_present &&
not param_is_this && not param_is_this &&
PatternMatch.type_is_class t1 && PatternMatch.type_is_class t1 &&
formal_is_present && formal_is_present &&

@ -17,9 +17,6 @@ module DExp = DecompiledExp
let remove_temps = true (* remove temp ids from typestates *) 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 to treat selected complex expressions as constants. *)
module ComplexExpressions = struct module ComplexExpressions = struct
@ -637,7 +634,7 @@ let typecheck_instr
match TypeState.lookup_pvar pvar typestate'' with match TypeState.lookup_pvar pvar typestate'' with
| Some (t, ta, _) -> | Some (t, ta, _) ->
let should_report = let should_report =
EradicateChecks.activate_condition_redundant && Config.eradicate_condition_redundant &&
TypeAnnotation.get_value Annotations.Nullable ta = false && TypeAnnotation.get_value Annotations.Nullable ta = false &&
not (TypeAnnotation.origin_is_fun_library ta) in not (TypeAnnotation.origin_is_fun_library ta) in
if checks.eradicate && should_report then if checks.eradicate && should_report then
@ -786,7 +783,7 @@ let typecheck_instr
let typestate2 = let typestate2 =
if not is_anonymous_inner_class_constructor then if not is_anonymous_inner_class_constructor then
begin begin
if debug then if Config.eradicate_debug then
begin begin
let unique_id = Procname.to_unique_id callee_pname in let unique_id = Procname.to_unique_id callee_pname in
let classification = let classification =

@ -120,7 +120,7 @@ let map_join m1 m2 =
) )
let join ext t1 t2 = let join ext t1 t2 =
if Config.from_env_variable "ERADICATE_TRACE" if Config.eradicate_trace
then L.stderr "@.@.**********join@.-------@.%a@.------@.%a@.********@.@." then L.stderr "@.@.**********join@.-------@.%a@.------@.%a@.********@.@."
(pp ext) t1 (pp ext) t1
(pp ext) t2; (pp ext) t2;

@ -16,6 +16,5 @@ compile:
clang $(OPTIONS) $(FILES) clang $(OPTIONS) $(FILES)
analyze: analyze:
INFER_REPORT_CUSTOM_ERROR=1 \ $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --report-custom-error --check-duplicate-symbols --developer-mode -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --check-duplicate-symbols --developer-mode -- clang $(OPTIONS) $(FILES) 2>duplicates.txt)
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0 grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0

@ -28,5 +28,4 @@ compile:
javac -cp $(CLASSPATH) $(FILES) javac -cp $(CLASSPATH) $(FILES)
analyze: analyze:
ERADICATE_RETURN_OVER_ANNOTATED=1 \ $(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) --eradicate-return-over-annotated -- javac -cp $(CLASSPATH) $(FILES))
$(call silent_on_success,$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES))

Loading…
Cancel
Save