diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 57e71f7ca..566cbaae4 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1552,6 +1552,10 @@ INTERNAL OPTIONS --per-procedure-parallelism. If 0 is specified, each file is divided into --jobs groups of procedures. + --no-process-clang-ast + Deactivates: process the ast to emit some info about the file (Not + available for Java) (Conversely: --process-clang-ast) + --procs-csv file Write statistics for each procedure in CSV format to a file diff --git a/infer/src/backend/PerfStats.ml b/infer/src/backend/PerfStats.ml index 474eff7fa..909e1ec89 100644 --- a/infer/src/backend/PerfStats.ml +++ b/infer/src/backend/PerfStats.ml @@ -32,7 +32,7 @@ type stats_kind = Time of Mtime_clock.counter * Unix.process_times | Memory | Ti type stats_type = | ClangLinters of SourceFile.t | ClangFrontend of SourceFile.t - | ClangFrontendLinters of SourceFile.t + | ClangProcessAST of SourceFile.t | JavaFrontend of SourceFile.t | TotalFrontend | Backend of SourceFile.t @@ -43,7 +43,7 @@ type stats_type = let source_file_of_stats_type = function | ClangLinters source_file | ClangFrontend source_file - | ClangFrontendLinters source_file + | ClangProcessAST source_file | JavaFrontend source_file | Backend source_file -> Some source_file @@ -64,19 +64,9 @@ let relative_path_of_stats_type stats_type = in let dirname = match stats_type with - | ClangLinters _ -> + | ClangLinters _ | ClangFrontend _ | ClangProcessAST _ | JavaFrontend _ | TotalFrontend -> Config.frontend_stats_dir_name - | ClangFrontend _ -> - Config.frontend_stats_dir_name - | ClangFrontendLinters _ -> - Config.frontend_stats_dir_name - | JavaFrontend _ -> - Config.frontend_stats_dir_name - | TotalFrontend -> - Config.frontend_stats_dir_name - | Backend _ -> - Config.backend_stats_dir_name - | TotalBackend -> + | Backend _ | TotalBackend -> Config.backend_stats_dir_name | Reporting -> Config.reporting_stats_dir_name @@ -91,8 +81,8 @@ let string_of_stats_type = function "linters" | ClangFrontend _ -> "clang_frontend" - | ClangFrontendLinters _ -> - "clang_frontend_and_linters" + | ClangProcessAST _ -> + "clang_process_ast" | JavaFrontend _ -> "java_frontend" | TotalFrontend -> diff --git a/infer/src/backend/PerfStats.mli b/infer/src/backend/PerfStats.mli index 1b1f27dcb..d6daef9e5 100644 --- a/infer/src/backend/PerfStats.mli +++ b/infer/src/backend/PerfStats.mli @@ -16,7 +16,7 @@ type stats_kind = Time of Mtime_clock.counter * Unix.process_times | Memory | Ti type stats_type = | ClangLinters of SourceFile.t | ClangFrontend of SourceFile.t - | ClangFrontendLinters of SourceFile.t + | ClangProcessAST of SourceFile.t | JavaFrontend of SourceFile.t | TotalFrontend | Backend of SourceFile.t diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 44674627d..2f0ad0618 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -48,10 +48,6 @@ let equal_analyzer = [%compare.equal: analyzer] let string_to_analyzer = [("checkers", Checkers); ("linters", Linters)] -let clang_frontend_action_symbols = - [("lint", `Lint); ("capture", `Capture); ("lint_and_capture", `Lint_and_capture)] - - let ml_bucket_symbols = [ ("all", `MLeak_all) ; ("cf", `MLeak_cf) @@ -1027,13 +1023,6 @@ and clang_blacklisted_flags_with_arg = and clang_compilation_dbs = ref [] -and clang_frontend_action = - CLOpt.mk_symbol_opt ~long:"" ~deprecated:["-clang-frontend-action"] - ~in_help:InferCommand.[(Capture, manual_clang); (Run, manual_clang)] - (* doc only shows up in deprecation warnings *) - "use --capture and --linters instead" ~symbols:clang_frontend_action_symbols - - and clang_ignore_regex = CLOpt.mk_string_opt ~long:"clang-ignore-regex" ~meta:"dir_OCaml_regex" "The files in this regex will be ignored in the compilation process and an empty file will be \ @@ -1914,6 +1903,12 @@ and procedures_source_file = output of $(b,--procedures)" +and process_clang_ast = + CLOpt.mk_bool ~long:"process-clang-ast" + ~default:true (* To be made false after this is deployed *) + "process the ast to emit some info about the file (Not available for Java)" + + and procs_csv = CLOpt.mk_path_opt ~deprecated:["procs"] ~long:"procs-csv" ~meta:"file" "Write statistics for each procedure in CSV format to a file" @@ -2767,16 +2762,7 @@ and bufferoverrun = !bufferoverrun and call_graph_schedule = !call_graph_schedule -and capture = - (* take `--clang-frontend-action` as the source of truth as long as that option exists *) - match !clang_frontend_action with - | Some (`Capture | `Lint_and_capture) -> - true - | Some `Lint -> - false - | None -> - !capture - +and capture = !capture and capture_blacklist = !capture_blacklist @@ -2949,16 +2935,7 @@ and join_cond = !join_cond and linter = !linter -and linters = - (* take `--clang-frontend-action` as the source of truth as long as that option exists *) - match !clang_frontend_action with - | Some (`Lint | `Lint_and_capture) -> - true - | Some `Capture -> - false - | None -> - !linters - +and linters = !linters and linters_def_file = !linters_def_file @@ -3064,6 +3041,8 @@ and[@warning "-32"] procedures_per_process = !procedures_per_process and procedures_source_file = !procedures_source_file +and process_clang_ast = !process_clang_ast + and progress_bar = if !progress_bar then match !progress_bar_style with @@ -3286,8 +3265,10 @@ and xcpretty = !xcpretty let captured_dir = results_dir ^/ captured_dir_name let clang_frontend_action_string = - String.concat ~sep:" and " - ((if capture then ["translating"] else []) @ if linters then ["linting"] else []) + let text = if capture then ["translating"] else [] in + let text = if linters then "linting" :: text else text in + let text = if process_clang_ast then "processing" :: text else text in + String.concat ~sep:", " text (* Specify treatment of dynamic dispatch in Java code: false 'none' treats dynamic dispatch as diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index e4d6df3f6..3b45b46bc 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -286,8 +286,6 @@ val clang_blacklisted_flags : string list val clang_blacklisted_flags_with_arg : string list -val clang_frontend_action_string : string - val clang_ignore_regex : string option val clang_isystem_to_override_regex : Str.regexp option @@ -544,6 +542,10 @@ val procedures_name : bool val procedures_source_file : bool +val process_clang_ast : bool + +val clang_frontend_action_string : string + val procs_csv : string option val profiler_samples : string option diff --git a/infer/src/clang/Capture.ml b/infer/src/clang/Capture.ml index 04b4abdfa..828d35410 100644 --- a/infer/src/clang/Capture.ml +++ b/infer/src/clang/Capture.ml @@ -22,17 +22,15 @@ let validate_decl_from_channel chan = Clang_ast_b.read_decl chan +(**FIXME(T54413835): Make the perf stats in the frontend work when one runs more than one frontend action *) let register_perf_stats_report source_file = let stats_type = - match (Config.capture, Config.linters) with - | true, true -> - PerfStats.ClangFrontendLinters source_file - | true, false -> - PerfStats.ClangFrontend source_file - | false, true -> - PerfStats.ClangLinters source_file - | false, false -> - Logging.(die UserError) "Clang frontend should be run in capture and/or linters mode." + if Config.capture then PerfStats.ClangFrontend source_file + else if Config.linters then PerfStats.ClangLinters source_file + else if Config.process_clang_ast then PerfStats.ClangProcessAST source_file + else + Logging.(die UserError) + "Clang frontend should be run in capture, linters or process AST mode." in PerfStats.register_report_at_exit stats_type @@ -95,15 +93,13 @@ let run_clang_frontend ast_source = Format.fprintf fmt "stdin of %a" SourceFile.pp trans_unit_ctx.CFrontend_config.source_file in ClangPointers.populate_all_tables ast_decl ; - L.(debug Capture Quiet) "Clang frontend action is %s@\n" Config.clang_frontend_action_string ; L.(debug Capture Medium) - "Start %s of AST from %a@\n" Config.clang_frontend_action_string pp_ast_filename ast_source ; + "Start %s the AST of %a@\n" Config.clang_frontend_action_string pp_ast_filename ast_source ; if Config.linters then AL.do_frontend_checks trans_unit_ctx ast_decl ; - if Config.export_changed_functions then - ProcessAST.export_changed_functions trans_unit_ctx ast_decl ; + if Config.process_clang_ast then ProcessAST.process_ast trans_unit_ctx ast_decl ; if Config.capture then CFrontend.do_source_file trans_unit_ctx ast_decl ; L.(debug Capture Medium) - "End %s of AST file %a... OK!@\n" Config.clang_frontend_action_string pp_ast_filename + "End %s the AST of file %a... OK!@\n" Config.clang_frontend_action_string pp_ast_filename ast_source ; print_elapsed () diff --git a/infer/src/clang/ProcessAST.ml b/infer/src/clang/ProcessAST.ml index d6a4b3ba1..f72b6617c 100644 --- a/infer/src/clang/ProcessAST.ml +++ b/infer/src/clang/ProcessAST.ml @@ -21,3 +21,7 @@ let export_changed_functions trans_unit_ctx ast_decl = ~f in call_f () + + +let process_ast trans_unit_ctx ast_decl = + if Config.export_changed_functions then export_changed_functions trans_unit_ctx ast_decl diff --git a/infer/src/clang/ProcessAST.mli b/infer/src/clang/ProcessAST.mli index 824778b39..a5637c291 100644 --- a/infer/src/clang/ProcessAST.mli +++ b/infer/src/clang/ProcessAST.mli @@ -6,5 +6,4 @@ *) open! IStd -val export_changed_functions : - CFrontend_config.translation_unit_context -> Clang_ast_t.decl -> unit +val process_ast : CFrontend_config.translation_unit_context -> Clang_ast_t.decl -> unit