diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index c6a4f9791..02a2997be 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -13,22 +13,6 @@ DESCRIPTION OPTIONS - --analyzer,-a { checkers | infer | capture | compile | crashcontext | - linters } - Specify which analyzer to run (only one at a time is supported): - - biabduction: run the bi-abduction based checker only, in - particular to check for memory errors - - checkers: run the default checkers, including the bi-abduction - based checker for memory errors (default) - - infer: alias for biabduction - - linters: run linters based on the ast only (clang only, - activated by default) - - capture: similar to specifying the capture subcommand - (DEPRECATED) - - compile: similar to specifying the compile subcommand - (DEPRECATED) - - crashcontext: experimental (see --crashcontext) - --no-annotation-reachability Deactivates: the annotation reachability checker. Given a pair of source and sink annotation, e.g. @PerformanceCritical and diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 198766dde..de2794962 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -54,35 +54,6 @@ OPTIONS supported options. The following is a list of all the supported options (see also --help-full for options reserved for internal use). - --analyzer,-a { checkers | infer | capture | compile | crashcontext | - linters } - Specify which analyzer to run (only one at a time is supported): - - biabduction: run the bi-abduction based checker only, in - particular to check for memory errors - - checkers: run the default checkers, including the bi-abduction - based checker for memory errors (default) - - infer: alias for biabduction - - linters: run linters based on the ast only (clang only, - activated by default) - - capture: similar to specifying the capture subcommand - (DEPRECATED) - - compile: similar to specifying the compile subcommand - (DEPRECATED) - - crashcontext: experimental (see --crashcontext) - See also infer-analyze(1) and infer-run(1). - - ---blacklist-files-containing +string - blacklist files containing the specified string for the given - analyzer (see --analyzer for valid values) See also infer-report(1) and infer-run(1). - - ---blacklist-path-regex +path_regex - blacklist the analysis of files whose relative path matches the - specified OCaml-style regex (to whitelist: - ---whitelist-path-regex) See also infer-report(1) and infer-run(1). - - ---suppress-errors +error_name - do not report a type of errors See also infer-report(1) and infer-run(1). - --no-annotation-reachability Deactivates: the annotation reachability checker. Given a pair of source and sink annotation, e.g. @PerformanceCritical and @@ -726,6 +697,15 @@ OPTIONS Deactivates: Run the reporting phase once the analysis has completed (Conversely: --report) See also infer-analyze(1) and infer-run(1). + --report-blacklist-files-containing +string + blacklist files containing the specified string for the given + analyzer (see --analyzer for valid values) See also infer-report(1) and infer-run(1). + + --report-blacklist-path-regex +path_regex + blacklist the analysis of files whose relative path matches the + specified OCaml-style regex (to whitelist: + ---whitelist-path-regex) See also infer-report(1) and infer-run(1). + --report-current path report of the latest revision See also infer-reportdiff(1). @@ -742,6 +722,9 @@ OPTIONS --report-previous path Report of the base revision to use for comparison See also infer-reportdiff(1). + --report-suppress-errors +error_name + do not report a type of errors See also infer-report(1) and infer-run(1). + --results-dir,-o dir Write results and internal files in the specified directory (default: ./infer-out) See also infer-analyze(1), infer-capture(1), infer-explore(1), @@ -921,21 +904,6 @@ INTERNAL OPTIONS Activates: Issue a warning when the analysis stops (Conversely: --no-analysis-stops) - ---blacklist-files-containing-reset - Set ---blacklist-files-containing to the empty list. - - ---blacklist-path-regex-reset - Set ---blacklist-path-regex to the empty list. - - --analyzer-reset - Cancel the effect of --analyzer. - - ---suppress-errors-reset - Set ---suppress-errors to the empty list. - - ---whitelist-path-regex-reset - Set ---whitelist-path-regex to the empty list. - --append-buck-flavors-reset Set --append-buck-flavors to the empty list. @@ -976,21 +944,9 @@ INTERNAL OPTIONS Deactivates: capture and translate source files into infer's intermediate language for analysis (Conversely: --capture) - --capture-blacklist-files-containing-reset - Set --capture-blacklist-files-containing to the empty list. - - --capture-blacklist-path-regex-reset - Set --capture-blacklist-path-regex to the empty list. - --capture-blacklist-reset Cancel the effect of --capture-blacklist. - --capture-suppress-errors-reset - Set --capture-suppress-errors to the empty list. - - --capture-whitelist-path-regex-reset - Set --capture-whitelist-path-regex to the empty list. - --changed-files-index-reset Cancel the effect of --changed-files-index. @@ -1000,18 +956,6 @@ INTERNAL OPTIONS --check-version-reset Cancel the effect of --check-version. - --checkers-blacklist-files-containing-reset - Set --checkers-blacklist-files-containing to the empty list. - - --checkers-blacklist-path-regex-reset - Set --checkers-blacklist-path-regex to the empty list. - - --checkers-suppress-errors-reset - Set --checkers-suppress-errors to the empty list. - - --checkers-whitelist-path-regex-reset - Set --checkers-whitelist-path-regex to the empty list. - --clang-biniou-file-reset Cancel the effect of --clang-biniou-file. @@ -1046,18 +990,6 @@ INTERNAL OPTIONS --compilation-database-reset Set --compilation-database to the empty list. - --compile-blacklist-files-containing-reset - Set --compile-blacklist-files-containing to the empty list. - - --compile-blacklist-path-regex-reset - Set --compile-blacklist-path-regex to the empty list. - - --compile-suppress-errors-reset - Set --compile-suppress-errors to the empty list. - - --compile-whitelist-path-regex-reset - Set --compile-whitelist-path-regex to the empty list. - --costs-current-reset Cancel the effect of --costs-current. @@ -1067,18 +999,6 @@ INTERNAL OPTIONS --coverage analysis mode to maximize coverage (can take longer) - --crashcontext-blacklist-files-containing-reset - Set --crashcontext-blacklist-files-containing to the empty list. - - --crashcontext-blacklist-path-regex-reset - Set --crashcontext-blacklist-path-regex to the empty list. - - --crashcontext-suppress-errors-reset - Set --crashcontext-suppress-errors to the empty list. - - --crashcontext-whitelist-path-regex-reset - Set --crashcontext-whitelist-path-regex to the empty list. - --current-to-previous-script-reset Cancel the effect of --current-to-previous-script. @@ -1205,18 +1125,6 @@ INTERNAL OPTIONS Deactivates: Ignore traces whose length is at most 1 (Conversely: --ignore-trivial-traces) - --infer-blacklist-files-containing-reset - Set --infer-blacklist-files-containing to the empty list. - - --infer-blacklist-path-regex-reset - Set --infer-blacklist-path-regex to the empty list. - - --infer-suppress-errors-reset - Set --infer-suppress-errors to the empty list. - - --infer-whitelist-path-regex-reset - Set --infer-whitelist-path-regex to the empty list. - --invariant-by-default Activates: [Cost]Consider functions to be invariant by default (Conversely: --no-invariant-by-default) @@ -1256,12 +1164,6 @@ INTERNAL OPTIONS --linter-reset Cancel the effect of --linter. - --linters-blacklist-files-containing-reset - Set --linters-blacklist-files-containing to the empty list. - - --linters-blacklist-path-regex-reset - Set --linters-blacklist-path-regex to the empty list. - --linters-def-file-reset Set --linters-def-file to the empty list. @@ -1271,12 +1173,6 @@ INTERNAL OPTIONS --linters-doc-url-reset Set --linters-doc-url to the empty list. - --linters-suppress-errors-reset - Set --linters-suppress-errors to the empty list. - - --linters-whitelist-path-regex-reset - Set --linters-whitelist-path-regex to the empty list. - --load-average-reset Cancel the effect of --load-average. @@ -1404,6 +1300,12 @@ INTERNAL OPTIONS --reanalyze Activates: Rerun the analysis (Conversely: --no-reanalyze) + --report-blacklist-files-containing-reset + Set --report-blacklist-files-containing to the empty list. + + --report-blacklist-path-regex-reset + Set --report-blacklist-path-regex to the empty list. + --report-current-reset Cancel the effect of --report-current. @@ -1413,6 +1315,12 @@ INTERNAL OPTIONS --report-previous-reset Cancel the effect of --report-previous. + --report-suppress-errors-reset + Set --report-suppress-errors to the empty list. + + --report-whitelist-path-regex-reset + Set --report-whitelist-path-regex to the empty list. + --reports-include-ml-loc Activates: Include the location in the Infer source code from where reports are generated (Conversely: diff --git a/infer/man/man1/infer-report.txt b/infer/man/man1/infer-report.txt index 1dcba2891..eaebfee4b 100644 --- a/infer/man/man1/infer-report.txt +++ b/infer/man/man1/infer-report.txt @@ -15,18 +15,6 @@ DESCRIPTION OPTIONS - ---blacklist-files-containing +string - blacklist files containing the specified string for the given - analyzer (see --analyzer for valid values) - - ---blacklist-path-regex +path_regex - blacklist the analysis of files whose relative path matches the - specified OCaml-style regex (to whitelist: - ---whitelist-path-regex) - - ---suppress-errors +error_name - do not report a type of errors - --debug,-g Activates: Debug mode (also sets --debug-level 2, --developer-mode, --no-filtering, --print-buckets, --print-types, @@ -149,10 +137,22 @@ OPTIONS Activates: Do not print specs on standard output (default: only print for the report command) (Conversely: --no-quiet | -Q) + --report-blacklist-files-containing +string + blacklist files containing the specified string for the given + analyzer (see --analyzer for valid values) + + --report-blacklist-path-regex +path_regex + blacklist the analysis of files whose relative path matches the + specified OCaml-style regex (to whitelist: + ---whitelist-path-regex) + --report-formatter { none | phabricator } Which formatter to use when emitting the report (default: phabricator) + --report-suppress-errors +error_name + do not report a type of errors + --results-dir,-o dir Write results and internal files in the specified directory (default: ./infer-out) diff --git a/infer/man/man1/infer-run.txt b/infer/man/man1/infer-run.txt index 11e54dde7..0597df5b5 100644 --- a/infer/man/man1/infer-run.txt +++ b/infer/man/man1/infer-run.txt @@ -16,34 +16,6 @@ DESCRIPTION OPTIONS - --analyzer,-a { checkers | infer | capture | compile | crashcontext | - linters } - Specify which analyzer to run (only one at a time is supported): - - biabduction: run the bi-abduction based checker only, in - particular to check for memory errors - - checkers: run the default checkers, including the bi-abduction - based checker for memory errors (default) - - infer: alias for biabduction - - linters: run linters based on the ast only (clang only, - activated by default) - - capture: similar to specifying the capture subcommand - (DEPRECATED) - - compile: similar to specifying the compile subcommand - (DEPRECATED) - - crashcontext: experimental (see --crashcontext) - - ---blacklist-files-containing +string - blacklist files containing the specified string for the given - analyzer (see --analyzer for valid values) - - ---blacklist-path-regex +path_regex - blacklist the analysis of files whose relative path matches the - specified OCaml-style regex (to whitelist: - ---whitelist-path-regex) - - ---suppress-errors +error_name - do not report a type of errors - --debug,-g Activates: Debug mode (also sets --debug-level 2, --developer-mode, --no-filtering, --print-buckets, --print-types, @@ -139,12 +111,24 @@ OPTIONS Deactivates: Run the reporting phase once the analysis has completed (Conversely: --report) + --report-blacklist-files-containing +string + blacklist files containing the specified string for the given + analyzer (see --analyzer for valid values) + + --report-blacklist-path-regex +path_regex + blacklist the analysis of files whose relative path matches the + specified OCaml-style regex (to whitelist: + ---whitelist-path-regex) + --report-hook script Specify a script to be executed after the analysis results are written. This script will be passed, --issues-json, --issues-txt, --issues-xml, --project-root, and --results-dir. (default: /lib/python/report.py) + --report-suppress-errors +error_name + do not report a type of errors + --results-dir,-o dir Write results and internal files in the specified directory (default: ./infer-out) diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index bffbeb46f..eb48df94f 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -54,35 +54,6 @@ OPTIONS supported options. The following is a list of all the supported options (see also --help-full for options reserved for internal use). - --analyzer,-a { checkers | infer | capture | compile | crashcontext | - linters } - Specify which analyzer to run (only one at a time is supported): - - biabduction: run the bi-abduction based checker only, in - particular to check for memory errors - - checkers: run the default checkers, including the bi-abduction - based checker for memory errors (default) - - infer: alias for biabduction - - linters: run linters based on the ast only (clang only, - activated by default) - - capture: similar to specifying the capture subcommand - (DEPRECATED) - - compile: similar to specifying the compile subcommand - (DEPRECATED) - - crashcontext: experimental (see --crashcontext) - See also infer-analyze(1) and infer-run(1). - - ---blacklist-files-containing +string - blacklist files containing the specified string for the given - analyzer (see --analyzer for valid values) See also infer-report(1) and infer-run(1). - - ---blacklist-path-regex +path_regex - blacklist the analysis of files whose relative path matches the - specified OCaml-style regex (to whitelist: - ---whitelist-path-regex) See also infer-report(1) and infer-run(1). - - ---suppress-errors +error_name - do not report a type of errors See also infer-report(1) and infer-run(1). - --no-annotation-reachability Deactivates: the annotation reachability checker. Given a pair of source and sink annotation, e.g. @PerformanceCritical and @@ -726,6 +697,15 @@ OPTIONS Deactivates: Run the reporting phase once the analysis has completed (Conversely: --report) See also infer-analyze(1) and infer-run(1). + --report-blacklist-files-containing +string + blacklist files containing the specified string for the given + analyzer (see --analyzer for valid values) See also infer-report(1) and infer-run(1). + + --report-blacklist-path-regex +path_regex + blacklist the analysis of files whose relative path matches the + specified OCaml-style regex (to whitelist: + ---whitelist-path-regex) See also infer-report(1) and infer-run(1). + --report-current path report of the latest revision See also infer-reportdiff(1). @@ -742,6 +722,9 @@ OPTIONS --report-previous path Report of the base revision to use for comparison See also infer-reportdiff(1). + --report-suppress-errors +error_name + do not report a type of errors See also infer-report(1) and infer-run(1). + --results-dir,-o dir Write results and internal files in the specified directory (default: ./infer-out) See also infer-analyze(1), infer-capture(1), infer-explore(1), diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index cddfb653a..923cf76fe 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -1030,7 +1030,7 @@ let finalize_and_close_files format_list_by_kind (stats : Stats.t) = let pp_summary_and_issues formats_by_report_kind issue_formats = let stats = Stats.create () in let linereader = Printer.LineReader.create () in - let filters = Inferconfig.create_filters Config.analyzer in + let filters = Inferconfig.create_filters () in let iterate_summaries = get_summary_iterator () in let all_issues = ref [] in iterate_summaries (fun summary -> diff --git a/infer/src/backend/crashcontext.mli b/infer/src/backend/crashcontext.mli index 39503b585..76a8c2ae7 100644 --- a/infer/src/backend/crashcontext.mli +++ b/infer/src/backend/crashcontext.mli @@ -35,7 +35,7 @@ val crashcontext_epilogue : in_buck_mode:bool -> unit Runs crashcontext epilogue code, which takes the per-method summaries produced by crashcontext related analysis (future: analyses) and stitches them together into a final crashcontext.json output file. - This code should run after all checkers when running with '-a crashcontext'. + This code should run after all checkers when running with '--crashcontext'. When running with buck, summaries are stitched across multiple buck targets, so this runs at the end of the parent buck infer process only. TODO: Similar integration with build systems other than buck. diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 2607ee8ab..9abb6ded5 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -288,11 +288,11 @@ let skip_implementation_matcher = FileOrProcMatcher.load_matcher (patterns_of_json_with_key Config.patterns_skip_implementation) -let load_filters analyzer = - { whitelist= Config.analysis_path_regex_whitelist analyzer - ; blacklist= Config.analysis_path_regex_blacklist analyzer - ; blacklist_files_containing= Config.analysis_blacklist_files_containing analyzer - ; suppress_errors= Config.analysis_suppress_errors analyzer } +let load_filters () = + { whitelist= Config.analysis_path_regex_whitelist + ; blacklist= Config.analysis_path_regex_blacklist + ; blacklist_files_containing= Config.analysis_blacklist_files_containing + ; suppress_errors= Config.analysis_suppress_errors } let filters_from_inferconfig inferconfig : filters = @@ -321,32 +321,20 @@ let filters_from_inferconfig inferconfig : filters = {path_filter; error_filter; proc_filter= default_proc_filter} -(* Create filters based on .inferconfig *) -let create_filters analyzer = - if not Config.filter_paths then do_not_filter - else filters_from_inferconfig (load_filters analyzer) +(* Create filters based on configuration options *) +let create_filters () = + if not Config.filter_paths then do_not_filter else filters_from_inferconfig (load_filters ()) -(* This function loads and list the path that are being filtered by the analyzer. The results *) -(* are of the form: path/to/file.java -> {infer, checkers} meaning that analysis results will *) -(* be reported on path/to/file.java both for infer and for the checkers *) +(** This function loads and list the path that are being filtered by the analyzer. The results are + of the form: path/to/file.java -> true/false meaning that analysis results will be reported on + path/to/file.java or not *) let test () = - let filters = - List.map - ~f:(fun (name, analyzer) -> (name, analyzer, create_filters analyzer)) - Config.string_to_analyzer - in - let matching_analyzers path = - List.fold - ~f:(fun l (n, a, f) -> if f.path_filter path then (n, a) :: l else l) - ~init:[] filters - in - Utils.directory_iter - (fun path -> - if DB.is_source_file path then - let source_file = SourceFile.from_abs_path path in - let matching = matching_analyzers source_file in - if matching <> [] then - let matching_s = String.concat ~sep:", " (List.map ~f:fst matching) in - L.result "%s -> {%s}@." (SourceFile.to_rel_path source_file) matching_s ) - (Sys.getcwd ()) + let filters = create_filters () in + let matches path = filters.path_filter path in + Sys.getcwd () + |> Utils.directory_iter (fun path -> + if DB.is_source_file path then + let source_file = SourceFile.from_abs_path path in + let matching = matches source_file in + L.result "%s -> %b@." (SourceFile.to_rel_path source_file) matching ) diff --git a/infer/src/backend/inferconfig.mli b/infer/src/backend/inferconfig.mli index 4df47e9a5..6497637f9 100644 --- a/infer/src/backend/inferconfig.mli +++ b/infer/src/backend/inferconfig.mli @@ -18,7 +18,7 @@ type proc_filter = Typ.Procname.t -> bool type filters = {path_filter: path_filter; error_filter: error_filter; proc_filter: proc_filter} -val create_filters : Config.analyzer -> filters +val create_filters : unit -> filters (** Create filters based on the config file *) val never_return_null_matcher : SourceFile.t -> Typ.Procname.t -> bool diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index e1c66b96b..faca48c50 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -16,22 +16,12 @@ module F = Format module CLOpt = CommandLineOption module L = Die -type analyzer = CaptureOnly | CompileOnly | Checkers | Crashcontext | Linters -[@@deriving compare] +type analyzer = Checkers | Crashcontext | Linters [@@deriving compare] let equal_analyzer = [%compare.equal: analyzer] let string_to_analyzer = - [ ("checkers", Checkers) - ; ("infer", Checkers) - ; ("capture", CaptureOnly) - ; ("compile", CompileOnly) - ; ("crashcontext", Crashcontext) - ; ("linters", Linters) ] - - -let string_of_analyzer a = - List.find_exn ~f:(fun (_, a') -> equal_analyzer a a') string_to_analyzer |> fst + [("checkers", Checkers); ("crashcontext", Crashcontext); ("linters", Linters)] let clang_frontend_action_symbols = @@ -551,62 +541,32 @@ and allow_leak = CLOpt.mk_bool ~deprecated:["leak"] ~long:"allow-leak" "Forget leaked memory during abstraction" -and ( analysis_blacklist_files_containing_options - , analysis_path_regex_blacklist_options - , analysis_path_regex_whitelist_options - , analysis_suppress_errors_options ) = - let mk_filtering_options ~suffix ?(deprecated_suffix = []) ~help ~meta = - (* reuse the same config var for all the forms of the analyzer name (eg infer and biabduction - must map to the same filtering config)*) - let config_vars = ref [] in - let mk_option analyzer analyzer_name = - let long = Printf.sprintf "%s-%s" analyzer_name suffix in - let deprecated = List.map ~f:(Printf.sprintf "%s_%s" analyzer_name) deprecated_suffix in - let source_of_truth = - List.find_map !config_vars ~f:(fun (a, v) -> - if equal_analyzer a analyzer then Some v else None ) - in - (* if the analyzer already has a variable associated to it, make the new name update the same - variable *) - let mirror opt = - Option.iter source_of_truth ~f:(fun var -> var := opt :: !var) ; - opt - in - (* empty doc to hide the options from --help since there are many redundant ones *) - let var = CLOpt.mk_string_list ~deprecated ~long ~meta ~f:mirror "" in - match source_of_truth with - | Some var -> - (* if the analyzer already has a variable associated to it, use it *) - var - | None -> - (* record the variable associated to the analyzer if this is the first time we see this - analyzer *) - config_vars := (analyzer, var) :: !config_vars ; - var +and ( analysis_blacklist_files_containing + , analysis_path_regex_blacklist + , analysis_path_regex_whitelist + , analysis_suppress_errors ) = + let mk_filtering_option ~suffix ~help ~meta = + let deprecated = + List.map ["checkers"; "infer"] ~f:(fun name -> Printf.sprintf "%s-%s" name suffix) in - ignore - (let long = "-" ^ suffix in - CLOpt.mk_string_list ~long ~meta - ~f:(fun _ -> raise (Arg.Bad "invalid option")) - ~in_help:InferCommand.[(Report, manual_generic); (Run, manual_generic)] - help) ; - List.map ~f:(fun (name, analyzer) -> (analyzer, mk_option analyzer name)) string_to_analyzer + let long = Printf.sprintf "report-%s" suffix in + CLOpt.mk_string_list ~deprecated ~long ~meta + ~in_help:InferCommand.[(Report, manual_generic); (Run, manual_generic)] + help in - ( mk_filtering_options ~suffix:"blacklist-files-containing" - ~deprecated_suffix:["blacklist_files_containing"] + ( mk_filtering_option ~suffix:"blacklist-files-containing" ~help: "blacklist files containing the specified string for the given analyzer (see \ $(b,--analyzer) for valid values)" ~meta:"string" - , mk_filtering_options ~suffix:"blacklist-path-regex" ~deprecated_suffix:["blacklist"] + , mk_filtering_option ~suffix:"blacklist-path-regex" ~help: "blacklist the analysis of files whose relative path matches the specified OCaml-style \ regex (to whitelist: $(b,---whitelist-path-regex))" ~meta:"path_regex" - , mk_filtering_options ~suffix:"whitelist-path-regex" ~deprecated_suffix:["whitelist"] ~help:"" - ~meta:"path_regex" - , mk_filtering_options ~suffix:"suppress-errors" ~deprecated_suffix:["suppress_errors"] - ~help:"do not report a type of errors" ~meta:"error_name" ) + , mk_filtering_option ~suffix:"whitelist-path-regex" ~help:"" ~meta:"path_regex" + , mk_filtering_option ~suffix:"suppress-errors" ~help:"do not report a type of errors" + ~meta:"error_name" ) and analysis_stops = @@ -615,38 +575,10 @@ and analysis_stops = and analyzer = - let () = - match Checkers with - (* NOTE: if compilation fails here, it means you have added a new analyzer without updating the - documentation of this option *) - | CaptureOnly | CompileOnly | Checkers | Crashcontext | Linters -> - () - in - CLOpt.mk_symbol_opt ~deprecated:["analyzer"] ~long:"analyzer" ~short:'a' - ~in_help:InferCommand.[(Analyze, manual_generic); (Run, manual_generic)] - {|Specify which analyzer to run (only one at a time is supported): -- $(b,biabduction): run the bi-abduction based checker only, in particular to check for memory errors -- $(b,checkers): run the default checkers, including the bi-abduction based checker for memory errors (default) -- $(b,infer): alias for $(b,biabduction) -- $(b,linters): run linters based on the ast only (clang only, activated by default) -- $(b,capture): similar to specifying the $(b,capture) subcommand (DEPRECATED) -- $(b,compile): similar to specifying the $(b,compile) subcommand (DEPRECATED) -- $(b,crashcontext): experimental (see $(b,--crashcontext))|} - ~f:(function - | (CaptureOnly | CompileOnly) as x -> - let analyzer_str = - List.find_map_exn string_to_analyzer ~f:(fun (s, y) -> - if equal_analyzer x y then Some s else None ) - in - CLOpt.warnf - "WARNING: The analyzer '%s' is deprecated, use the '%s' subcommand instead:@\n\ - @\n \ - infer %s ..." - analyzer_str analyzer_str analyzer_str ; - x - | _ as x -> - x) - ~symbols:string_to_analyzer + CLOpt.mk_symbol ~deprecated:["analyzer"; "-analyzer"; "a"] ~long:"" ~default:Checkers + ~eq:equal_analyzer ~symbols:string_to_analyzer + "DEPRECATED: To enable and disable individual analyses, use the various checkers options. For \ + instance, to enable only the biabduction analysis, run with $(b,--biabduction-only)." and ( annotation_reachability @@ -2320,11 +2252,6 @@ let post_parsing_initialization command_opt = print_endline version_string ; prerr_endline version_string | `Javac when !buck -> (* print buck key *) - let analyzer_name = - List.Assoc.find_exn ~equal:equal_analyzer - (List.map ~f:(fun (n, a) -> (a, n)) string_to_analyzer) - (match !analyzer with Some a -> a | None -> Checkers) - in let infer_version = match inferconfig_file with | Some inferconfig -> @@ -2333,8 +2260,8 @@ let post_parsing_initialization command_opt = | None -> Version.commit in - F.printf "%s/%s@." analyzer_name infer_version ; - F.eprintf "%s/%s@." analyzer_name infer_version + F.printf "infer/%s@." infer_version ; + F.eprintf "infer/%s@." infer_version | `Full -> print_endline version_string | `Javac -> @@ -2421,23 +2348,15 @@ let post_parsing_initialization command_opt = (* set analyzer mode to linters in linters developer mode *) if !linters_developer_mode then linters := true ; if !default_linters then linters_def_file := linters_def_default_file :: !linters_def_file ; - ( if Option.is_none !analyzer then - match (command_opt : InferCommand.t option) with - | Some Compile -> - analyzer := Some CompileOnly - | Some Capture -> - analyzer := Some CaptureOnly - | _ -> - () ) ; ( match !analyzer with - | Some Crashcontext -> + | Crashcontext -> disable_all_checkers () ; crashcontext := true - | Some Linters -> + | Linters -> disable_all_checkers () ; capture := false ; linters := true - | Some (CaptureOnly | Checkers | CompileOnly) | None -> + | Checkers -> () ) ; Option.value ~default:InferCommand.Run command_opt @@ -2495,21 +2414,13 @@ and abs_val = !abs_val and allow_leak = !allow_leak -and analysis_path_regex_whitelist_options = - List.map ~f:(fun (a, b) -> (a, !b)) analysis_path_regex_whitelist_options - +and analysis_path_regex_whitelist = !analysis_path_regex_whitelist -and analysis_path_regex_blacklist_options = - List.map ~f:(fun (a, b) -> (a, !b)) analysis_path_regex_blacklist_options +and analysis_path_regex_blacklist = !analysis_path_regex_blacklist +and analysis_blacklist_files_containing = !analysis_blacklist_files_containing -and analysis_blacklist_files_containing_options = - List.map ~f:(fun (a, b) -> (a, !b)) analysis_blacklist_files_containing_options - - -and analysis_suppress_errors_options = - List.map ~f:(fun (a, b) -> (a, !b)) analysis_suppress_errors_options - +and analysis_suppress_errors = !analysis_suppress_errors and analysis_stops = !analysis_stops @@ -3012,26 +2923,8 @@ and xcpretty = !xcpretty (** Configuration values derived from command-line options *) -let analysis_path_regex_whitelist analyzer = - List.Assoc.find_exn ~equal:equal_analyzer analysis_path_regex_whitelist_options analyzer - - -and analysis_path_regex_blacklist analyzer = - List.Assoc.find_exn ~equal:equal_analyzer analysis_path_regex_blacklist_options analyzer - - -and analysis_blacklist_files_containing analyzer = - List.Assoc.find_exn ~equal:equal_analyzer analysis_blacklist_files_containing_options analyzer - - -and analysis_suppress_errors analyzer = - List.Assoc.find_exn ~equal:equal_analyzer analysis_suppress_errors_options analyzer - - let captured_dir = results_dir ^/ captured_dir_name -let analyzer = match !analyzer with Some a -> a | None -> Checkers - let clang_frontend_action_string = String.concat ~sep:" and " ((if capture then ["translating"] else []) @ if linters then ["linting"] else []) diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 95c7a231a..9665ca5e9 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -11,13 +11,6 @@ open! IStd (** Configuration values: either constant, determined at compile time, or set at startup time by system calls, environment variables, or command line options *) -type analyzer = CaptureOnly | CompileOnly | Checkers | Crashcontext | Linters - -val string_to_analyzer : (string * analyzer) list -(** Association list of analyzers and their names *) - -val string_of_analyzer : analyzer -> string - type os_type = Unix | Win32 | Cygwin type compilation_database_dependencies = @@ -220,17 +213,15 @@ val abs_val : int val allow_leak : bool -val analysis_path_regex_whitelist : analyzer -> string list +val analysis_path_regex_whitelist : string list -val analysis_path_regex_blacklist : analyzer -> string list +val analysis_path_regex_blacklist : string list -val analysis_blacklist_files_containing : analyzer -> string list +val analysis_blacklist_files_containing : string list val analysis_stops : bool -val analysis_suppress_errors : analyzer -> string list - -val analyzer : analyzer +val analysis_suppress_errors : string list val annotation_reachability : bool diff --git a/infer/src/infer.ml b/infer/src/infer.ml index 4adc01556..81cf355c0 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -56,9 +56,6 @@ let setup () = let print_active_checkers () = - (if Config.print_active_checkers && CLOpt.is_originator then L.result else L.environment_info) - "Analyzer: %s@." - Config.(string_of_analyzer analyzer) ; (if Config.print_active_checkers && CLOpt.is_originator then L.result else L.environment_info) "Active checkers: %a@." (Pp.seq ~sep:", " RegisterCheckers.pp_checker) diff --git a/infer/tests/codetoanalyze/java/.inferconfig b/infer/tests/codetoanalyze/java/.inferconfig index 29aaaad8b..4d5a2e581 100644 --- a/infer/tests/codetoanalyze/java/.inferconfig +++ b/infer/tests/codetoanalyze/java/.inferconfig @@ -11,7 +11,7 @@ "method": "get" } ], - "checkers-blacklist-files-containing": [ + "report-blacklist-files-containing": [ "@generated" ], "enable-issue-type": [ diff --git a/infer/tests/codetoanalyze/java/infer/.inferconfig b/infer/tests/codetoanalyze/java/infer/.inferconfig index a7e342c8c..85ac12b5b 100644 --- a/infer/tests/codetoanalyze/java/infer/.inferconfig +++ b/infer/tests/codetoanalyze/java/infer/.inferconfig @@ -11,7 +11,7 @@ "method": "get" } ], - "checkers-blacklist-files-containing": [ + "report-blacklist-files-containing": [ "@generated" ], "skip-translation": [ diff --git a/infer/tests/codetoanalyze/java/tracing/.inferconfig b/infer/tests/codetoanalyze/java/tracing/.inferconfig index a7e342c8c..85ac12b5b 100644 --- a/infer/tests/codetoanalyze/java/tracing/.inferconfig +++ b/infer/tests/codetoanalyze/java/tracing/.inferconfig @@ -11,7 +11,7 @@ "method": "get" } ], - "checkers-blacklist-files-containing": [ + "report-blacklist-files-containing": [ "@generated" ], "skip-translation": [