diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index f019b0467..e3ebe8501 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -315,9 +315,15 @@ let should_report (issue_kind: Exceptions.err_kind) issue_type error_desc => } else { let analyzer_is_whitelisted = switch Config.analyzer { - | Some (Checkers | Eradicate | Tracing) => true - | None - | Some (Capture | Compile | Crashcontext | Infer | Linters | Quandary) => false + | Checkers + | Eradicate + | Tracing => true + | Capture + | Compile + | Crashcontext + | Infer + | Linters + | Quandary => false }; if analyzer_is_whitelisted { true @@ -1426,11 +1432,7 @@ let pp_summary_and_issues formats_by_report_kind => { let pdflatex fname => ignore (Sys.command ("pdflatex " ^ fname)); let stats = Stats.create (); let linereader = Printer.LineReader.create (); - let filters = - switch Config.analyzer { - | None => Inferconfig.do_not_filter - | Some analyzer => Inferconfig.create_filters analyzer - }; + let filters = Inferconfig.create_filters Config.analyzer; let iterate_summaries = AnalysisResults.get_summary_iterator (); let top_proc = TopProcedures.create (); let top_proc_set = TopProcedures.top_set top_proc; diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 766f4f66e..16f1c9216 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -115,9 +115,9 @@ let capture build_cmd build_mode = run_command ( infer_py :: Config.anon_args @ - (match Config.analyzer with None -> [] | Some a -> - ["--analyzer"; - IList.assoc (=) a (IList.map (fun (n,a) -> (a,n)) Config.string_to_analyzer)]) @ + ["--analyzer"; + IList.assoc (=) Config.analyzer + (IList.map (fun (n,a) -> (a,n)) Config.string_to_analyzer)] @ (match Config.blacklist with | Some s when in_buck_mode && not (is_analyze_cmd build_cmd) -> ["--blacklist-regex"; s] | _ -> []) @ @@ -173,13 +173,13 @@ let analyze = function Config.print_usage_exit () ); (match Config.analyzer with - | None | Some (Infer | Eradicate | Checkers | Tracing | Crashcontext | Quandary) -> + | Infer | Eradicate | Checkers | Tracing | Crashcontext | Quandary -> (* Still handled by infer.py through capture function above *) () - | Some Linters -> + | Linters -> (* Still handled by infer.py through capture function above *) () - | Some (Capture | Compile) -> + | Capture | Compile -> (* Still handled by infer.py through capture function above *) () ) @@ -187,7 +187,7 @@ let analyze = function let epilogue build_mode = if Config.is_originator then ( StatsAggregator.generate_files () ; - if Config.analyzer = Some Config.Crashcontext then + if Config.analyzer = Config.Crashcontext then Crashcontext.crashcontext_epilogue ~in_buck_mode:(build_mode = Buck); if Config.fail_on_bug then fail_on_issue_epilogue (); diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 1a353a481..38fb04bd9 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1380,7 +1380,6 @@ and analysis_blacklist_files_containing_options = and analysis_suppress_errors_options = IList.map (fun (a, b) -> (a, !b)) analysis_suppress_errors_options and analysis_stops = !analysis_stops -and analyzer = !analyzer and angelic_execution = !angelic_execution and array_level = !array_level and ast_file = !ast_file @@ -1535,17 +1534,19 @@ let clang_frontend_do_capture, clang_frontend_do_lint = | Some `Capture -> true, false (* capture, no lint *) | Some `Lint_and_capture -> true, true (* capture, lint *) | None -> - match analyzer with + match !analyzer with | Some Linters -> false, true (* no capture, lint *) | Some Infer -> true, false (* capture, no lint *) | _ -> true, true (* capture, lint *) +let analyzer = match !analyzer with Some a -> a | None -> Infer + let clang_frontend_action_string = String.concat " and " ((if clang_frontend_do_capture then ["translating"] else []) @ (if clang_frontend_do_lint then ["linting"] else [])) -let dynamic_dispatch = if analyzer = Some Tracing then `Lazy else !dynamic_dispatch +let dynamic_dispatch = if analyzer = Tracing then `Lazy else !dynamic_dispatch let patterns_suppress_warnings = let error msg = diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 8934d91a2..190cee135 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -137,7 +137,7 @@ val analysis_path_regex_blacklist : analyzer -> string list val analysis_blacklist_files_containing : analyzer -> string list val analysis_stops : bool val analysis_suppress_errors : analyzer -> string list -val analyzer : analyzer option +val analyzer : analyzer val angelic_execution : bool val array_level : int val ast_file : string option diff --git a/infer/src/clang/Capture.re b/infer/src/clang/Capture.re index ff790246b..de74ba8f9 100644 --- a/infer/src/clang/Capture.re +++ b/infer/src/clang/Capture.re @@ -168,7 +168,7 @@ let cc1_capture clang_cmd => { filename_to_absolute orig_argv.(Array.length orig_argv - 1) }; Logging.out "@\n*** Beginning capture of file %s ***@\n" source_path; - if (Config.analyzer == Some Config.Compile || CLocation.is_file_blacklisted source_path) { + if (Config.analyzer == Config.Compile || CLocation.is_file_blacklisted source_path) { Logging.out "@\n Skip the analysis of source file %s@\n@\n" source_path; /* We still need to run clang, but we don't have to attach the plugin. */ run_clang (ClangCommand.command_to_run clang_cmd) consume_in diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index dd12f15ef..bb46d506e 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -13,7 +13,7 @@ module CLOpt = CommandLineOption module F = Format let capture_text = - if Config.analyzer = Some Config.Linters then "linting" + if Config.analyzer = Config.Linters then "linting" else "translating" let replace_header_file_with_source_file file_path =