From 0c9b0258579e6b502efa16cf8129862f9a4569eb Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 23 Jan 2018 08:06:29 -0800 Subject: [PATCH] [clopt] move command datatype to new InferCommand Summary: This declutters `CommandLineOption` a little bit, and will be useful in a follow-up diff where `InferCommand.t` will be used from an atd-generated file. Reviewed By: mbouaziz Differential Revision: D6772990 fbshipit-source-id: 3d32d00 --- infer/src/atd/.merlin | 2 + infer/src/atd/InferCommand.ml | 54 ++++++ infer/src/atd/InferCommand.mli | 39 +++++ infer/src/atd/jbuild.in | 3 +- infer/src/backend/InferPrint.ml | 2 +- infer/src/backend/clusterMakefile.ml | 2 +- infer/src/backend/infer.ml | 2 +- infer/src/base/CommandDoc.ml | 31 ++-- infer/src/base/CommandDoc.mli | 2 +- infer/src/base/CommandLineOption.ml | 62 ++----- infer/src/base/CommandLineOption.mli | 45 +---- infer/src/base/Config.ml | 242 ++++++++++++++------------- infer/src/base/Config.mli | 2 +- infer/src/base/EventLogger.ml | 2 +- infer/src/integration/Driver.ml | 2 +- infer/src/integration/Maven.ml | 2 +- 16 files changed, 263 insertions(+), 231 deletions(-) create mode 100644 infer/src/atd/InferCommand.ml create mode 100644 infer/src/atd/InferCommand.mli diff --git a/infer/src/atd/.merlin b/infer/src/atd/.merlin index 86ed88216..c147db547 100644 --- a/infer/src/atd/.merlin +++ b/infer/src/atd/.merlin @@ -3,7 +3,9 @@ FLG -open InferGenerated -g -short-paths -safe-string -principal -strict-formats PKG atd PKG atdgen PKG biniou +PKG core PKG easy-format +PKG ppx_compare PKG str PKG unix PKG yojson diff --git a/infer/src/atd/InferCommand.ml b/infer/src/atd/InferCommand.ml new file mode 100644 index 000000000..5463fe599 --- /dev/null +++ b/infer/src/atd/InferCommand.ml @@ -0,0 +1,54 @@ +(* + * Copyright (c) 2018 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + *) +open Core + +(* NOTE: All variants must be also added to `all_commands` below *) +type t = + | Analyze + | Capture + | Compile + | Diff + | Events + | Explore + | Report + | ReportDiff + | Run + [@@deriving compare] + +let equal = [%compare.equal : t] + +let command_to_string = + [ (Analyze, "analyze") + ; (Capture, "capture") + ; (Compile, "compile") + ; (Diff, "diff") + ; (Events, "events") + ; (Explore, "explore") + ; (Report, "report") + ; (ReportDiff, "reportdiff") + ; (Run, "run") ] + + +let all_commands = List.map ~f:fst command_to_string + +let to_string cmd = List.Assoc.find_exn ~equal command_to_string cmd + +let of_string name = + List.Assoc.find_exn ~equal:String.equal (List.Assoc.inverse command_to_string) name + + +let infer_exe_name = "infer" + +let exe_name_of_command_string name = Printf.sprintf "%s-%s" infer_exe_name name + +let to_exe_name cmd = to_string cmd |> exe_name_of_command_string + +let of_exe_name exe_name = + List.find_map command_to_string ~f:(function cmd, name -> + if String.equal exe_name (exe_name_of_command_string name) then Some cmd else None ) diff --git a/infer/src/atd/InferCommand.mli b/infer/src/atd/InferCommand.mli new file mode 100644 index 000000000..52ab29ecf --- /dev/null +++ b/infer/src/atd/InferCommand.mli @@ -0,0 +1,39 @@ +(* + * Copyright (c) 2018 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + *) + +(** Main modes of operation for infer *) +type t = + | Analyze (** analyze previously captured source files *) + | Capture + (** capture compilation commands and translate source files into infer's intermediate + language *) + | Compile + (** set up the infer environment then run the compilation commands without capturing the + source files *) + | Diff (** orchestrate a diff analysis *) + | Events (** dump logged events into stdout *) + | Explore (** explore infer reports *) + | Report (** post-process infer results and reports *) + | ReportDiff (** compute the difference of two infer reports *) + | Run (** orchestrate the capture, analysis, and reporting of a compilation command *) + [@@deriving compare] + +val of_string : string -> t + +val to_string : t -> string + +val equal : t -> t -> bool + +val all_commands : t list + +val infer_exe_name : string + +val to_exe_name : t -> string + +val of_exe_name : string -> t option diff --git a/infer/src/atd/jbuild.in b/infer/src/atd/jbuild.in index 7b7a7c3e9..96f613697 100644 --- a/infer/src/atd/jbuild.in +++ b/infer/src/atd/jbuild.in @@ -9,7 +9,8 @@ let cflags = common_cflags @ ["-w"; "-27-32-34-35-39"] ((name InferGenerated) (flags (%s)) (ocamlopt_flags (%s)) - (libraries (atdgen)) + (libraries (atdgen core)) + (preprocess (pps (ppx_compare))) )) |} (String.concat " " cflags) diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 15a2f4b4a..7525ddd00 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -750,7 +750,7 @@ let pp_summary_by_report_kind formats_by_report_kind summary error_filter linere pp_stats (error_filter file) linereader summary stats format_list | Calls, _ :: _ -> pp_calls summary format_list - | Summary, _ when CLOpt.equal_command Config.command CLOpt.Report && not Config.quiet -> + | Summary, _ when InferCommand.equal Config.command Report && not Config.quiet -> pp_summary summary | _ -> () diff --git a/infer/src/backend/clusterMakefile.ml b/infer/src/backend/clusterMakefile.ml index 335c04a6d..cc956d828 100644 --- a/infer/src/backend/clusterMakefile.ml +++ b/infer/src/backend/clusterMakefile.ml @@ -27,7 +27,7 @@ let pp_prolog fmt clusters = |> String.concat ~sep:" " |> escape in F.fprintf fmt "INFERANALYZE = '%s' --no-report --results-dir '%s' %s@\n@\n" - (Config.bin_dir ^/ CLOpt.exe_name_of_command CLOpt.Analyze) + (Config.bin_dir ^/ InferCommand.(to_exe_name Analyze)) (escape Config.results_dir) compilation_dbs_cmd ; F.fprintf fmt "CLUSTERS=" ; List.iteri ~f:(fun i _ -> F.fprintf fmt "%a " Cluster.pp_cluster_name (i + 1)) clusters ; diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 02fda1485..dd76daba0 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -77,7 +77,7 @@ let log_environment_info () = let prepare_events_logging () = (* there's no point in logging data from the events command. To fetch them we'd need to run events again... *) - if CLOpt.equal_command Config.command CLOpt.Events then () + if InferCommand.equal Config.command Events then () else let log_identifier_msg = Printf.sprintf "Infer log identifier is %s\n" (EventLogger.get_log_identifier ()) diff --git a/infer/src/base/CommandDoc.ml b/infer/src/base/CommandDoc.ml index b5461eec8..44b8ffabe 100644 --- a/infer/src/base/CommandDoc.ml +++ b/infer/src/base/CommandDoc.ml @@ -22,7 +22,7 @@ let mk_command_doc ~see_also:see_also_commands ?environment:environment_opt ?fil let see_also = let exe_names = List.map see_also_commands ~f:(fun cmd -> - let exe = CLOpt.exe_name_of_command cmd in + let exe = InferCommand.to_exe_name cmd in Printf.sprintf "$(b,%s)(%d)" (Cmdliner.Manpage.escape exe) section ) in [`P (String.concat ~sep:", " exe_names)] @@ -54,7 +54,7 @@ let analyze = ~synopsis:{|$(b,infer) $(b,analyze) $(i,[options]) $(b,infer) $(i,[options])|} ~description:[`P "Analyze the files captured in the project results directory and report."] - ~see_also:CLOpt.([Report; Run]) + ~see_also:InferCommand.([Report; Run]) let capture = @@ -76,7 +76,7 @@ $(b,infer) $(b,capture) $(i,[--no-xcpretty]) $(i,[options]) $(b,--) $(b,xcodebui [ `P "Capture the build command or compilation database specified on the command line: infer intercepts calls to the compiler to read source files, translate them into infer's intermediate representation, and store the result of the translation in the results directory." ] - ~see_also:CLOpt.([Analyze; Compile; Run]) + ~see_also:InferCommand.([Analyze; Compile; Run]) let compile = @@ -104,7 +104,7 @@ let compile = cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. infer capture --compilation-database compile_commands.json|} ] - ~see_also:CLOpt.([Capture]) + ~see_also:InferCommand.([Capture]) let diff = @@ -112,7 +112,7 @@ let diff = ~short_description:"Report the difference between two versions of a project" ~synopsis:"$(b,infer) $(b,diff) $(i,[options])" ~description:[`P "EXPERIMENTAL AND IN NO WAY READY TO USE"] - ~see_also:CLOpt.([ReportDiff; Run]) + ~see_also:InferCommand.([ReportDiff; Run]) let explore = @@ -123,7 +123,7 @@ let explore = [ `P "Show the list of bugs on the console and explore symbolic program traces emitted by infer to explain a report. Can also generate an HTML report from a JSON report." ] - ~see_also:CLOpt.([Report; Run]) + ~see_also:InferCommand.([Report; Run]) let infer = @@ -203,7 +203,7 @@ $(b,infer) $(i,[options])|} "cxx": false, "infer-blacklist-files-containing": ["@generated","@Generated"] }|} - ] ~see_also:CLOpt.all_commands "infer" + ] ~see_also:InferCommand.all_commands "infer" let report = @@ -215,7 +215,7 @@ let report = ; `P "If no specs file are passed on the command line, process all the .specs in the results directory." ] - ~see_also:CLOpt.([ReportDiff; Run]) + ~see_also:InferCommand.([ReportDiff; Run]) let reportdiff = @@ -235,7 +235,7 @@ let reportdiff = ; `P "- $(b,preexisting.json) contains the issues found in both $(i,previous) and $(i,current)." ; `P "All three files follow the same format as normal infer reports." ] - ~see_also:CLOpt.([Report]) + ~see_also:InferCommand.([Report]) let events = @@ -246,7 +246,7 @@ let events = [ `P "Emit to stdout one JSON object per line, each describing a logged event happened during the execution of Infer" ] - ~see_also:CLOpt.([Report; Run]) + ~see_also:InferCommand.([Report; Run]) let run = @@ -260,16 +260,16 @@ $(b,infer) $(i,[options]) $(b,--) $(i,compile command)|} "Calling \"$(b,infer) $(b,run) $(i,[options])\" is equivalent to performing the following sequence of commands:" ; `Pre {|$(b,infer) $(b,capture) $(i,[options]) $(b,infer) $(b,analyze) $(i,[options])|} ] - ~see_also:CLOpt.([Analyze; Capture; Report]) + ~see_also:InferCommand.([Analyze; Capture; Report]) let command_to_data = let mk cmd mk_doc = - let name = CLOpt.name_of_command cmd in - let command_doc = mk_doc (CLOpt.exe_name_of_command cmd) in + let name = InferCommand.to_string cmd in + let command_doc = mk_doc (InferCommand.to_exe_name cmd) in (cmd, {name; command_doc}) in - let open CLOpt in + let open InferCommand in [ mk Analyze analyze ; mk Capture capture ; mk Compile compile @@ -281,5 +281,4 @@ let command_to_data = ; mk Run run ] -let data_of_command command = - List.Assoc.find_exn ~equal:CLOpt.equal_command command_to_data command +let data_of_command command = List.Assoc.find_exn ~equal:InferCommand.equal command_to_data command diff --git a/infer/src/base/CommandDoc.mli b/infer/src/base/CommandDoc.mli index 8ec4a70d0..4020a278d 100644 --- a/infer/src/base/CommandDoc.mli +++ b/infer/src/base/CommandDoc.mli @@ -18,4 +18,4 @@ val inferconfig_file : string val infer : CLOpt.command_doc -val data_of_command : CLOpt.command -> data +val data_of_command : InferCommand.t -> data diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 544ff3e22..33ec8d5df 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -86,48 +86,6 @@ let anon_arg_action_of_parse_mode parse_mode = {parse_subcommands; parse_argfiles; on_unknown} -(* NOTE: All variants must be also added to `all_commands` below *) -type command = - | Analyze - | Capture - | Compile - | Diff - | Events - | Explore - | Report - | ReportDiff - | Run - [@@deriving compare] - -let equal_command = [%compare.equal : command] - -let infer_exe_name = "infer" - -let command_to_name = - [ (Analyze, "analyze") - ; (Capture, "capture") - ; (Compile, "compile") - ; (Diff, "diff") - ; (Events, "events") - ; (Explore, "explore") - ; (Report, "report") - ; (ReportDiff, "reportdiff") - ; (Run, "run") ] - - -let all_commands = List.map ~f:fst command_to_name - -let name_of_command = List.Assoc.find_exn ~equal:equal_command command_to_name - -let exe_name_of_command_name name = Printf.sprintf "%s-%s" infer_exe_name name - -let exe_name_of_command cmd = name_of_command cmd |> exe_name_of_command_name - -let command_of_exe_name exe_name = - List.find_map command_to_name ~f:(fun (cmd, name) -> - if String.equal exe_name (exe_name_of_command_name name) then Some cmd else None ) - - type command_doc = { title: Cmdliner.Manpage.title ; manual_before_options: Cmdliner.Manpage.block list @@ -218,7 +176,7 @@ module SectionMap = Caml.Map.Make (struct end) let help_sections_desc_lists = - List.map all_commands ~f:(fun command -> (command, ref SectionMap.empty)) + List.map InferCommand.all_commands ~f:(fun command -> (command, ref SectionMap.empty)) let visible_descs_list = ref [] @@ -231,7 +189,9 @@ let add parse_mode sections desc = let desc_list = List.Assoc.find_exn ~equal:equal_parse_mode parse_mode_desc_lists parse_mode in desc_list := desc :: !desc_list ; let add_to_section (command, section) = - let sections = List.Assoc.find_exn ~equal:equal_command help_sections_desc_lists command in + let sections = + List.Assoc.find_exn ~equal:InferCommand.equal help_sections_desc_lists command + in let prev_contents = try SectionMap.find section !sections with Not_found -> [] in sections := SectionMap.add section (desc :: prev_contents) !sections in @@ -259,10 +219,10 @@ let add parse_mode sections desc = in (* in the help of `infer` itself, show in which specific commands the option is used *) let commands = - List.map ~f:fst sections |> List.sort ~cmp:compare_command - |> List.remove_consecutive_duplicates ~equal:equal_command + List.map ~f:fst sections |> List.sort ~cmp:InferCommand.compare + |> List.remove_consecutive_duplicates ~equal:InferCommand.equal |> List.map ~f:(fun cmd -> - let exe = exe_name_of_command cmd in + let exe = InferCommand.to_exe_name cmd in Printf.sprintf "$(b,%s)(1)" (Cmdliner.Manpage.escape exe) ) |> oxford_comma in @@ -358,7 +318,7 @@ let curr_command = ref None type 'a t = ?deprecated:string list -> long:Arg.key -> ?short:char -> ?parse_mode:parse_mode - -> ?in_help:(command * string) list -> ?meta:string -> Arg.doc -> 'a + -> ?in_help:(InferCommand.t * string) list -> ?meta:string -> Arg.doc -> 'a let string_json_decoder ~long ~inferconfig_dir:_ json = [dashdash long; YBU.to_string json] @@ -731,7 +691,7 @@ let select_parse_mode ~usage parse_mode = let string_of_command command = - let _, s, _ = List.Assoc.find_exn !subcommands ~equal:equal_command command in + let _, s, _ = List.Assoc.find_exn !subcommands ~equal:InferCommand.equal command in s @@ -1012,7 +972,7 @@ let show_manual ?internal_section format default_doc command_opt = | None -> default_doc | Some command -> - match List.Assoc.find_exn ~equal:equal_command !subcommands command with + match List.Assoc.find_exn ~equal:InferCommand.equal !subcommands command with | Some command_doc, _, _ -> command_doc | None, _, _ -> @@ -1058,7 +1018,7 @@ let show_manual ?internal_section format default_doc command_opt = match command_opt with | Some command -> let sections = - List.Assoc.find_exn ~equal:equal_command help_sections_desc_lists command + List.Assoc.find_exn ~equal:InferCommand.equal help_sections_desc_lists command in SectionMap.fold (fun section descs result -> diff --git a/infer/src/base/CommandLineOption.mli b/infer/src/base/CommandLineOption.mli index 985533888..0c8c93b49 100644 --- a/infer/src/base/CommandLineOption.mli +++ b/infer/src/base/CommandLineOption.mli @@ -20,35 +20,6 @@ type parse_mode = | NoParse (** all arguments are anonymous arguments, no parsing is attempted *) [@@deriving compare] -(** Main modes of operation for infer *) -type command = - | Analyze (** analyze previously captured source files *) - | Capture - (** capture compilation commands and translate source files into infer's intermediate - language *) - | Compile - (** set up the infer environment then run the compilation commands without capturing the - source files *) - | Diff (** orchestrate a diff analysis *) - | Events (** dump logged events into stdout *) - | Explore (** explore infer reports *) - | Report (** post-process infer results and reports *) - | ReportDiff (** compute the difference of two infer reports *) - | Run (** orchestrate the capture, analysis, and reporting of a compilation command *) - [@@deriving compare] - -val equal_command : command -> command -> bool - -val all_commands : command list - -val infer_exe_name : string - -val name_of_command : command -> string - -val exe_name_of_command : command -> string - -val command_of_exe_name : string -> command option - val is_originator : bool val init_work_dir : string @@ -73,7 +44,7 @@ val init_work_dir : string *) type 'a t = ?deprecated:string list -> long:string -> ?short:char -> ?parse_mode:parse_mode - -> ?in_help:(command * string) list -> ?meta:string -> string -> 'a + -> ?in_help:(InferCommand.t * string) list -> ?meta:string -> string -> 'a val mk_set : 'a ref -> 'a -> unit t (** [mk_set variable value] defines a command line option which sets [variable] to [value]. *) @@ -145,7 +116,7 @@ val mk_anon : unit -> string list ref order they appeared on the command line. *) val mk_rest_actions : - ?parse_mode:parse_mode -> ?in_help:(command * string) list -> string -> usage:string + ?parse_mode:parse_mode -> ?in_help:(InferCommand.t * string) list -> string -> usage:string -> (string -> parse_mode) -> string list ref (** [mk_rest_actions doc ~usage command_to_parse_mode] defines a [string list ref] of the command line arguments following ["--"], in the reverse order they appeared on the command line. [usage] @@ -183,8 +154,9 @@ val mk_command_doc : *) val mk_subcommand : - command -> ?on_unknown_arg:[`Add | `Skip | `Reject] -> name:string -> ?deprecated_long:string - -> ?parse_mode:parse_mode -> ?in_help:(command * string) list -> command_doc option -> unit + InferCommand.t -> ?on_unknown_arg:[`Add | `Skip | `Reject] -> name:string + -> ?deprecated_long:string -> ?parse_mode:parse_mode -> ?in_help:(InferCommand.t * string) list + -> command_doc option -> unit (** [mk_subcommand command ~long command_doc] defines the subcommand [command]. A subcommand is activated by passing [name], and by passing [--deprecated_long] if specified. A man page is automatically generated for [command] based on the information in [command_doc], if available @@ -204,8 +176,8 @@ val extend_env_args : string list -> unit (** [extend_env_args args] appends [args] to those passed via [args_env_var] *) val parse : - ?config_file:string -> usage:Arg.usage_msg -> parse_mode -> command option - -> command option * (int -> 'a) + ?config_file:string -> usage:Arg.usage_msg -> parse_mode -> InferCommand.t option + -> InferCommand.t option * (int -> 'a) (** [parse ~usage parse_mode command] parses command line arguments as specified by preceding calls to the [mk_*] functions, and returns: - the command selected by the user on the command line, except if [command] is not None in which @@ -228,7 +200,8 @@ val is_env_var_set : string -> bool (** [is_env_var_set var] is true if $[var]=1 *) val show_manual : - ?internal_section:string -> Cmdliner.Manpage.format -> command_doc -> command option -> unit + ?internal_section:string -> Cmdliner.Manpage.format -> command_doc -> InferCommand.t option + -> unit (** Display the manual of [command] to the user, or [command_doc] if [command] is None. [format] is used as for [Cmdliner.Manpage.print]. If [internal_section] is specified, add a section titled [internal_section] about internal (hidden) options. *) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index f9de6b680..861829600 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -423,7 +423,7 @@ let exe_basename = let infer_is_clang = List.mem ~equal:String.equal clang_exe_aliases exe_basename let initial_command = - match CLOpt.command_of_exe_name exe_basename with Some _ as command -> command | None -> None + match InferCommand.of_exe_name exe_basename with Some _ as command -> command | None -> None let bin_dir = @@ -496,7 +496,7 @@ let exe_usage = let exe_command_name = match initial_command with | Some command -> - Some (CLOpt.name_of_command command) + Some (InferCommand.to_string command) | None -> None in @@ -541,7 +541,7 @@ let all_checkers = ref [] let disable_all_checkers () = List.iter !all_checkers ~f:(fun (var, _, _, _) -> var := false) let () = - let on_unknown_arg_from_command (cmd: CLOpt.command) = + let on_unknown_arg_from_command (cmd: InferCommand.t) = match cmd with | Report -> `Add @@ -549,10 +549,10 @@ let () = `Reject in (* make sure we generate doc for all the commands we know about *) - List.iter CLOpt.all_commands ~f:(fun cmd -> + List.iter InferCommand.all_commands ~f:(fun cmd -> let {CommandDoc.name; command_doc} = CommandDoc.data_of_command cmd in let on_unknown_arg = on_unknown_arg_from_command cmd in - let deprecated_long = if CLOpt.(equal_command ReportDiff) cmd then Some "diff" else None in + let deprecated_long = if InferCommand.(equal ReportDiff) cmd then Some "diff" else None in CLOpt.mk_subcommand cmd ~name ?deprecated_long ~on_unknown_arg (Some command_doc) ) @@ -613,7 +613,7 @@ and ( analysis_blacklist_files_containing_options (let long = "-" ^ suffix in CLOpt.mk_string_list ~long ~meta ~f:(fun _ -> raise (Arg.Bad "invalid option")) - ~in_help:CLOpt.([(Report, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic); (Run, manual_generic)]) help) ; List.map ~f:(fun (name, analyzer) -> (analyzer, mk_option analyzer name)) string_to_analyzer in @@ -650,7 +650,7 @@ and analyzer = () in CLOpt.mk_symbol_opt ~deprecated:["analyzer"] ~long:"analyzer" ~short:'a' - ~in_help:CLOpt.([(Analyze, manual_generic); (Run, manual_generic)]) + ~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) @@ -694,7 +694,9 @@ and ( annotation_reachability , uninit ) = let mk_checker ?(default= false) ?(deprecated= []) ~long doc = let var = - CLOpt.mk_bool ~long ~in_help:CLOpt.([(Analyze, manual_generic)]) ~default ~deprecated doc + CLOpt.mk_bool ~long + ~in_help:InferCommand.([(Analyze, manual_generic)]) + ~default ~deprecated doc in all_checkers := (var, long, doc, default) :: !all_checkers ; var @@ -741,7 +743,7 @@ and ( annotation_reachability let mk_only (var, long, doc, _) = let _ : bool ref = CLOpt.mk_bool_group ~long:(long ^ "-only") - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) ~f:(fun b -> disable_all_checkers () ; var := b ; @@ -757,7 +759,7 @@ and ( annotation_reachability List.iter ~f:mk_only !all_checkers ; let _default_checkers : bool ref = CLOpt.mk_bool_group ~long:"default-checkers" - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) ~default:true ( "Default checkers: " ^ ( List.rev_filter_map @@ -796,7 +798,7 @@ and ( annotation_reachability and annotation_reachability_custom_pairs = CLOpt.mk_json ~long:"annotation-reachability-custom-pairs" - ~in_help:CLOpt.([(Analyze, manual_java)]) + ~in_help:InferCommand.([(Analyze, manual_java)]) {|Specify custom sources/sink for the annotation reachability checker Example format: for custom annotations com.my.annotation.{Source1,Source2,Sink1} { "sources" : ["Source1", "Source2"], "sink" : "Sink1" }|} @@ -804,7 +806,7 @@ Example format: for custom annotations com.my.annotation.{Source1,Source2,Sink1} and append_buck_flavors = CLOpt.mk_string_list ~long:"append-buck-flavors" - ~in_help:CLOpt.([(Capture, manual_buck_flavors)]) + ~in_help:InferCommand.([(Capture, manual_buck_flavors)]) "Additional Buck flavors to append to targets discovered by the $(b,--buck-compilation-database) option." @@ -819,13 +821,13 @@ and array_level = and blacklist = CLOpt.mk_string_opt ~deprecated:["-blacklist-regex"; "-blacklist"] ~long:"buck-blacklist" - ~in_help:CLOpt.([(Run, manual_buck_flavors); (Capture, manual_buck_flavors)]) + ~in_help:InferCommand.([(Run, manual_buck_flavors); (Capture, manual_buck_flavors)]) ~meta:"regex" "Skip analysis of files matched by the specified regular expression" and bootclasspath = CLOpt.mk_string_opt ~long:"bootclasspath" - ~in_help:CLOpt.([(Capture, manual_java)]) + ~in_help:InferCommand.([(Capture, manual_java)]) "Specify the Java bootclasspath" @@ -834,33 +836,33 @@ and buck = CLOpt.mk_bool ~long:"buck" "" and buck_build_args = CLOpt.mk_string_list ~long:"Xbuck" - ~in_help:CLOpt.([(Capture, manual_buck_flavors)]) + ~in_help:InferCommand.([(Capture, manual_buck_flavors)]) "Pass values as command-line arguments to invocations of $(i,`buck build`)" and buck_compilation_database_depth = CLOpt.mk_int_opt ~long:"buck-compilation-database-depth" - ~in_help:CLOpt.([(Capture, manual_buck_compilation_db)]) + ~in_help:InferCommand.([(Capture, manual_buck_compilation_db)]) "Depth of dependencies used by the $(b,--buck-compilation-database deps) option. By default, all recursive dependencies are captured." ~meta:"int" and buck_compilation_database = CLOpt.mk_symbol_opt ~long:"buck-compilation-database" ~deprecated:["-use-compilation-database"] - ~in_help:CLOpt.([(Capture, manual_buck_compilation_db)]) + ~in_help:InferCommand.([(Capture, manual_buck_compilation_db)]) "Buck integration using the compilation database, with or without dependencies." ~symbols:[("no-deps", `NoDeps); ("deps", `DepsTmp)] and buck_out = CLOpt.mk_path_opt ~long:"buck-out" - ~in_help:CLOpt.([(Capture, manual_buck_java)]) + ~in_help:InferCommand.([(Capture, manual_buck_java)]) ~meta:"dir" "Specify the root directory of buck-out" and calls_csv = CLOpt.mk_path_opt ~deprecated:["calls"] ~long:"calls-csv" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"file" "Write individual calls in CSV format to $(i,file)" @@ -871,14 +873,14 @@ and capture = and changed_files_index = CLOpt.mk_path_opt ~long:"changed-files-index" - ~in_help:CLOpt.([(Analyze, manual_generic); (Diff, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic); (Diff, manual_generic)]) ~meta:"file" "Specify the file containing the list of source files from which reactive analysis should start. Source files should be specified relative to project root or be absolute" and clang_biniou_file = CLOpt.mk_path_opt ~long:"clang-biniou-file" - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) ~meta:"file" "Specify a file containing the AST of the program, in biniou format" @@ -886,7 +888,7 @@ and clang_compilation_dbs = ref [] and clang_frontend_action = CLOpt.mk_symbol_opt ~long:"" ~deprecated:["-clang-frontend-action"] - ~in_help:CLOpt.([(Capture, manual_clang); (Run, manual_clang)]) + ~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 @@ -911,20 +913,20 @@ and cluster = and compilation_database = CLOpt.mk_path_list ~long:"compilation-database" ~deprecated:["-clang-compilation-db-files"] - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "File that contain compilation commands (can be specified multiple times)" and compilation_database_escaped = CLOpt.mk_path_list ~long:"compilation-database-escaped" ~deprecated:["-clang-compilation-db-files-escaped"] - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "File that contain compilation commands where all entries are escaped for the shell, eg coming from Xcode (can be specified multiple times)" and compute_analytics = CLOpt.mk_bool ~long:"compute-analytics" ~default:false - ~in_help:CLOpt.([(Capture, manual_clang); (Run, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang); (Run, manual_clang)]) "Emit analytics as info-level issues, like component kit line count and component kit file cyclomatic complexity" @@ -932,32 +934,32 @@ and compute_analytics = If a procedure was changed beforehand, keep the changed marking. *) and continue = CLOpt.mk_bool ~deprecated:["continue"] ~long:"continue" - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) "Continue the capture for the reactive analysis, increasing the changed files/procedures. (If a procedure was changed beforehand, keep the changed marking.)" and current_to_previous_script = CLOpt.mk_string_opt ~long:"current-to-previous-script" - ~in_help:CLOpt.([(Diff, manual_generic)]) + ~in_help:InferCommand.([(Diff, manual_generic)]) ~meta:"shell" "Specify a script to checkout a previous version of the project to compare against, assuming we are on the current version already." and cxx_infer_headers = CLOpt.mk_bool ~long:"cxx-infer-headers" ~default:true - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Include C++ header models during compilation. Infer swaps some C++ headers for its own in order to get a better model of, eg, the standard library. This can sometimes cause compilation failures." and cxx_scope_guards = CLOpt.mk_json ~long:"cxx-scope-guards" - ~in_help:CLOpt.([(Analyze, manual_clang)]) + ~in_help:InferCommand.([(Analyze, manual_clang)]) "Specify scope guard classes that can be read only by destructors without being reported as dead stores." and cxx = CLOpt.mk_bool ~long:"cxx" ~default:true - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Analyze C++ methods" @@ -984,12 +986,12 @@ and ( bo_debug , write_html_whitelist_regex , write_dotty ) = let all_generic_manuals = - List.filter_map CLOpt.all_commands ~f:(fun cmd -> - if CLOpt.equal_command Explore cmd then None else Some (cmd, manual_generic) ) + List.filter_map InferCommand.all_commands ~f:(fun cmd -> + if InferCommand.equal Explore cmd then None else Some (cmd, manual_generic) ) in let bo_debug = CLOpt.mk_int ~default:0 ~long:"bo-debug" - ~in_help:CLOpt.([(Analyze, manual_buffer_overrun)]) + ~in_help:InferCommand.([(Analyze, manual_buffer_overrun)]) "Debug level for buffer-overrun checker (0-4)" and debug_level_analysis = CLOpt.mk_int ~long:"debug-level-analysis" ~default:0 ~in_help:all_generic_manuals @@ -999,15 +1001,15 @@ and ( bo_debug "Debug level for the capture. See $(b,--debug-level) for accepted values." and debug_level_linters = CLOpt.mk_int ~long:"debug-level-linters" ~default:0 - ~in_help:(CLOpt.(Capture, manual_clang_linters) :: all_generic_manuals) + ~in_help:(InferCommand.(Capture, manual_clang_linters) :: all_generic_manuals) "Debug level for the linters. See $(b,--debug-level) for accepted values." and developer_mode = CLOpt.mk_bool ~long:"developer-mode" - ~default:(Option.value_map ~default:false ~f:CLOpt.(equal_command Report) initial_command) + ~default:(Option.value_map ~default:false ~f:InferCommand.(equal Report) initial_command) "Show internal exceptions" and filtering = CLOpt.mk_bool ~deprecated_no:["nf"] ~long:"filtering" ~short:'f' ~default:true - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) "Do not show the experimental and blacklisted issue types" and only_cheap_debug = CLOpt.mk_bool ~long:"only-cheap-debug" ~default:true "Disable expensive debugging output" @@ -1018,7 +1020,7 @@ and ( bo_debug CLOpt.mk_bool ~long:"print-types" ~default:false "Print types in symbolic heaps" and keep_going = CLOpt.mk_bool ~deprecated_no:["-no-failures-allowed"] ~long:"keep-going" - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) "Keep going when the analysis encounters a failure" and reports_include_ml_loc = CLOpt.mk_bool ~deprecated:["with_infer_src_loc"] ~long:"reports-include-ml-loc" @@ -1067,11 +1069,11 @@ and ( bo_debug [developer_mode; print_buckets; reports_include_ml_loc] [filtering; keep_going] and default_linters = CLOpt.mk_bool ~long:"default-linters" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) ~default:true "Use the default linters for the analysis." and frontend_tests = CLOpt.mk_bool_group ~long:"frontend-tests" - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Save filename.ext.test.dot with the cfg in dotty format for frontend tests (also sets $(b,--print-types))" [print_types] [] and models_mode = @@ -1079,7 +1081,7 @@ and ( bo_debug and print_logs = CLOpt.mk_bool ~long:"print-logs" ~in_help: - CLOpt.( + InferCommand.( [ (Analyze, manual_generic) ; (Capture, manual_generic) ; (Run, manual_generic) @@ -1088,7 +1090,7 @@ and ( bo_debug in let linters_developer_mode = CLOpt.mk_bool_group ~long:"linters-developer-mode" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) "Debug mode for developing new linters. (Sets the analyzer to $(b,linters); also sets $(b,--debug), $(b,--debug-level-linters 2), $(b,--developer-mode), and unsets $(b,--allowed-failures) and $(b,--default-linters)." ~f:(fun debug -> debug_level_linters := if debug then 2 else 0 ; @@ -1121,13 +1123,13 @@ and ( bo_debug and dependencies = CLOpt.mk_bool ~deprecated:["dependencies"] ~long:"dependencies" - ~in_help:CLOpt.([(Capture, manual_java)]) + ~in_help:InferCommand.([(Capture, manual_java)]) "Translate all the dependencies during the capture. The classes in the given jar file will be translated. No sources needed." and differential_filter_files = CLOpt.mk_string_opt ~long:"differential-filter-files" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) "Specify the file containing the list of source files for which a differential report is desired. Source files should be specified relative to project root or be absolute" @@ -1146,7 +1148,7 @@ and () = let issue = IssueType.from_string issue_id in IssueType.set_enabled issue b ; issue_id ) ?default ~meta:"issue_type" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) doc in () @@ -1172,7 +1174,7 @@ and dotty_cfg_libs = and dump_duplicate_symbols = CLOpt.mk_bool ~long:"dump-duplicate-symbols" - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Dump all symbols with the same name that are defined in more than one file." @@ -1206,7 +1208,7 @@ and eradicate_verbose = and fail_on_bug = CLOpt.mk_bool ~deprecated:["-fail-on-bug"] ~long:"fail-on-issue" ~default:false - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) (Printf.sprintf "Exit with error code %d if Infer found something to report" fail_on_issue_exit_code) @@ -1219,7 +1221,7 @@ and fcp_syntax_only = CLOpt.mk_bool ~long:"fcp-syntax-only" "Skip creation of ob and file_renamings = CLOpt.mk_path_opt ~long:"file-renamings" - ~in_help:CLOpt.([(ReportDiff, manual_generic)]) + ~in_help:InferCommand.([(ReportDiff, manual_generic)]) "JSON with a list of file renamings to use while computing differential reports" @@ -1229,20 +1231,20 @@ and filter_paths = and filter_report = CLOpt.mk_string_list ~long:"filter-report" - ~in_help:CLOpt.([(Report, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic); (Run, manual_generic)]) "Specify a filter for issues to report. If multiple filters are specified, they are applied in the order in which they are specified. Each filter is applied to each issue detected, and only issues which are accepted by all filters are reported. Each filter is of the form: `::`. The first two components are OCaml Str regular expressions, with an optional `!` character prefix. If a regex has a `!` prefix, the polarity is inverted, and the filter becomes a \"blacklist\" instead of a \"whitelist\". Each filter is interpreted as an implication: an issue matches if it does not match the `issue_type_regex` or if it does match the `filename_regex`. The filenames that are tested by the regex are relative to the `--project-root` directory. The `` is a non-empty string used to explain why the issue was filtered." and flavors = CLOpt.mk_bool ~deprecated:["-use-flavors"] ~long:"flavors" - ~in_help:CLOpt.([(Capture, manual_buck_flavors)]) + ~in_help:InferCommand.([(Capture, manual_buck_flavors)]) "Buck integration using Buck flavors (clang only), eg $(i,`infer --flavors -- buck build //foo:bar#infer`)" and force_delete_results_dir = CLOpt.mk_bool ~long:"force-delete-results-dir" ~default:false ~in_help: - CLOpt.( + InferCommand.( [ (Capture, manual_generic) ; (Compile, manual_generic) ; (Diff, manual_generic) @@ -1253,7 +1255,7 @@ and force_delete_results_dir = and force_integration = CLOpt.mk_symbol_opt ~long:"force-integration" ~meta:"command" ~symbols:(List.Assoc.inverse build_system_exe_assoc) - ~in_help:CLOpt.([(Capture, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Capture, manual_generic); (Run, manual_generic)]) (Printf.sprintf "Proceed as if the first argument after $(b,--) was $(i,command). Possible values: %s." ( List.map build_system_exe_assoc ~f:(fun (_, s) -> Printf.sprintf "$(i,%s)" s) @@ -1262,7 +1264,7 @@ and force_integration = and from_json_report = CLOpt.mk_path_opt ~long:"from-json-report" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"report.json" "Load analysis results from a report file (default is to load the results from the specs files generated by the analysis)." @@ -1274,30 +1276,30 @@ and frontend_stats = and gen_previous_build_command_script = CLOpt.mk_string_opt ~long:"gen-previous-build-command-script" - ~in_help:CLOpt.([(Diff, manual_generic)]) + ~in_help:InferCommand.([(Diff, manual_generic)]) ~meta:"shell" "Specify a script that outputs the build command to capture in the previous version of the project. The script should output the command on stdout. For example \"echo make\"." and generated_classes = CLOpt.mk_path_opt ~long:"generated-classes" - ~in_help:CLOpt.([(Capture, manual_java)]) + ~in_help:InferCommand.([(Capture, manual_java)]) "Specify where to load the generated class files" and headers = CLOpt.mk_bool ~deprecated:["headers"; "hd"] ~deprecated_no:["no_headers"; "nhd"] ~long:"headers" - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Analyze code in header files" and help = let var = ref `None in CLOpt.mk_set var `Help ~long:"help" - ~in_help:(List.map CLOpt.all_commands ~f:(fun command -> (command, manual_generic))) + ~in_help:(List.map InferCommand.all_commands ~f:(fun command -> (command, manual_generic))) "Show this manual" ; CLOpt.mk_set var `HelpFull ~long:"help-full" - ~in_help:(List.map CLOpt.all_commands ~f:(fun command -> (command, manual_generic))) + ~in_help:(List.map InferCommand.all_commands ~f:(fun command -> (command, manual_generic))) (Printf.sprintf "Show this manual with all internal options in the %s section" manual_internal) ; var @@ -1306,12 +1308,14 @@ and help_format = CLOpt.mk_symbol ~long:"help-format" ~symbols:[("auto", `Auto); ("groff", `Groff); ("pager", `Pager); ("plain", `Plain)] ~eq:PVariant.( = ) ~default:`Auto - ~in_help:(List.map CLOpt.all_commands ~f:(fun command -> (command, manual_generic))) + ~in_help:(List.map InferCommand.all_commands ~f:(fun command -> (command, manual_generic))) "Show this help in the specified format. $(b,auto) sets the format to $(b,plain) if the environment variable $(b,TERM) is \"dumb\" or undefined, and to $(b,pager) otherwise." and html = - CLOpt.mk_bool ~long:"html" ~in_help:CLOpt.([(Explore, manual_generic)]) "Generate html report." + CLOpt.mk_bool ~long:"html" + ~in_help:InferCommand.([(Explore, manual_generic)]) + "Generate html report." and icfg_dotty_outfile = @@ -1331,19 +1335,19 @@ and infer_cache = and iphoneos_target_sdk_version = CLOpt.mk_string_opt ~long:"iphoneos-target-sdk-version" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) "Specify the target SDK version to use for iphoneos" and iphoneos_target_sdk_version_path_regex = CLOpt.mk_string_list ~long:"iphoneos-target-sdk-version-path-regex" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) "To pass a specific target SDK version to use for iphoneos in a particular path, with the format path:version (can be specified multiple times)" and issues_fields = CLOpt.mk_symbol_seq ~long:"issues-fields" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~default: [ `Issue_field_file ; `Issue_field_procedure @@ -1355,13 +1359,13 @@ and issues_fields = and issues_tests = CLOpt.mk_path_opt ~long:"issues-tests" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"file" "Write a list of issues in a format suitable for tests to $(i,file)" and issues_txt = CLOpt.mk_path_opt ~deprecated:["bugs_txt"] ~long:"issues-txt" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"file" "Write a list of issues in text format to $(i,file) (default: infer-out/bugs.txt)" @@ -1372,13 +1376,13 @@ and iterations = and java_jar_compiler = CLOpt.mk_path_opt ~long:"java-jar-compiler" - ~in_help:CLOpt.([(Capture, manual_java)]) + ~in_help:InferCommand.([(Capture, manual_java)]) ~meta:"path" "Specify the Java compiler jar used to generate the bytecode" and jobs = CLOpt.mk_int ~deprecated:["-multicore"] ~long:"jobs" ~short:'j' ~default:ncpu - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) ~meta:"int" "Run the specified number of analysis jobs simultaneously" @@ -1392,7 +1396,7 @@ and join_cond = and log_events = CLOpt.mk_bool ~long:"log-events" - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Turn on the feature that logs events in a machine-readable format" @@ -1403,20 +1407,20 @@ and log_file = and linter = CLOpt.mk_string_opt ~long:"linter" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) "From the linters available, only run this one linter. (Useful together with $(b,--linters-developer-mode))" and linters_def_file = CLOpt.mk_path_list ~default:[] ~long:"linters-def-file" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) ~meta:"file" "Specify the file containing linters definition (e.g. 'linters.al')" and linters_def_folder = let linters_def_folder = CLOpt.mk_path_list ~default:[] ~long:"linters-def-folder" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) ~meta:"dir" "Specify the folder containing linters files with extension .al" in let () = @@ -1428,33 +1432,33 @@ and linters_def_folder = and linters_doc_url = CLOpt.mk_string_list ~long:"linters-doc-url" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) "Specify custom documentation URL for some linter that overrides the default one. Useful if your project has specific ways of fixing a lint error that is not true in general or public info. Format: linter_name:doc_url." and linters_ignore_clang_failures = CLOpt.mk_bool ~long:"linters-ignore-clang-failures" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) ~default:false "Continue linting files even if some compilation fails." and linters_validate_syntax_only = CLOpt.mk_bool ~long:"linters-validate-syntax-only" - ~in_help:CLOpt.([(Capture, manual_clang_linters)]) + ~in_help:InferCommand.([(Capture, manual_clang_linters)]) ~default:false "Validate syntax of AL files, then emit possible errors in JSON format to stdout" and load_average = CLOpt.mk_float_opt ~long:"load-average" ~short:'l' - ~in_help:CLOpt.([(Capture, manual_generic)]) + ~in_help:InferCommand.([(Capture, manual_generic)]) ~meta:"float" "Do not start new parallel jobs if the load average is greater than that specified (Buck and make only)" and load_results = CLOpt.mk_path_opt ~deprecated:["load_results"] ~long:"load-results" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"file.iar" "Load analysis results from Infer Analysis Results file file.iar" @@ -1465,20 +1469,20 @@ and margin = and max_nesting = CLOpt.mk_int_opt ~long:"max-nesting" - ~in_help:CLOpt.([(Explore, manual_generic)]) + ~in_help:InferCommand.([(Explore, manual_generic)]) "Level of nested procedure calls to show. Trace elements beyond the maximum nesting level are skipped. If omitted, all levels are shown." and merge = CLOpt.mk_bool ~deprecated:["merge"] ~long:"merge" - ~in_help:CLOpt.([(Analyze, manual_buck_flavors)]) + ~in_help:InferCommand.([(Analyze, manual_buck_flavors)]) "Merge the captured results directories specified in the dependency file" and ml_buckets = CLOpt.mk_symbol_seq ~deprecated:["ml_buckets"; "-ml_buckets"] ~long:"ml-buckets" ~default:[`MLeak_cf] - ~in_help:CLOpt.([(Analyze, manual_clang)]) + ~in_help:InferCommand.([(Analyze, manual_clang)]) {|Specify the memory leak buckets to be checked in C++: - $(b,cpp) from C++ code |} @@ -1507,7 +1511,7 @@ and only_footprint = and only_show = CLOpt.mk_bool ~long:"only-show" - ~in_help:CLOpt.([(Explore, manual_generic)]) + ~in_help:InferCommand.([(Explore, manual_generic)]) "Show the list of reports and exit" @@ -1553,7 +1557,7 @@ and per_procedure_parallelism = and pmd_xml = CLOpt.mk_bool ~long:"pmd-xml" - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Output issues in (PMD) XML format" @@ -1564,14 +1568,14 @@ and precondition_stats = and previous_to_current_script = CLOpt.mk_string_opt ~long:"previous-to-current-script" - ~in_help:CLOpt.([(Diff, manual_generic)]) + ~in_help:InferCommand.([(Diff, manual_generic)]) ~meta:"shell" "Specify a script to checkout the current version of the project. The project is supposed to already be at that current version when running $(b,infer diff); the script is used after having analyzed the current and previous versions of the project, to restore the project to the current version." and print_active_checkers = CLOpt.mk_bool ~long:"print-active-checkers" - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) "Print the active checkers before starting the analysis" @@ -1582,7 +1586,7 @@ and print_builtins = and print_log_identifier = CLOpt.mk_bool ~long:"print-log-identifier" - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Print the unique identifier that is common to all logged events" @@ -1604,7 +1608,7 @@ and procs_csv = and progress_bar = CLOpt.mk_bool ~deprecated:["pb"] ~deprecated_no:["no_progress_bar"; "npb"] ~short:'p' ~long:"progress-bar" ~default:true - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Show a progress bar" @@ -1612,7 +1616,7 @@ and project_root = CLOpt.mk_path ~deprecated:["project_root"; "-project_root"; "pr"] ~long:"project-root" ~short:'C' ~default:CLOpt.init_work_dir ~in_help: - CLOpt.( + InferCommand.( [ (Analyze, manual_generic) ; (Capture, manual_generic) ; (Run, manual_generic) @@ -1622,37 +1626,37 @@ and project_root = and quandary_endpoints = CLOpt.mk_json ~long:"quandary-endpoints" - ~in_help:CLOpt.([(Analyze, manual_quandary)]) + ~in_help:InferCommand.([(Analyze, manual_quandary)]) "Specify endpoint classes for Quandary" and quandary_sanitizers = CLOpt.mk_json ~long:"quandary-sanitizers" - ~in_help:CLOpt.([(Analyze, manual_quandary)]) + ~in_help:InferCommand.([(Analyze, manual_quandary)]) "Specify custom sanitizers for Quandary" and quandary_sources = CLOpt.mk_json ~long:"quandary-sources" - ~in_help:CLOpt.([(Analyze, manual_quandary)]) + ~in_help:InferCommand.([(Analyze, manual_quandary)]) "Specify custom sources for Quandary" and quandary_sinks = CLOpt.mk_json ~long:"quandary-sinks" - ~in_help:CLOpt.([(Analyze, manual_quandary)]) + ~in_help:InferCommand.([(Analyze, manual_quandary)]) "Specify custom sinks for Quandary" and quiet = CLOpt.mk_bool ~long:"quiet" ~short:'q' ~default:false - ~in_help:CLOpt.([(Analyze, manual_generic); (Report, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic); (Report, manual_generic)]) "Do not print specs on standard output (default: only print for the $(b,report) command)" and reactive = CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:'r' - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) "Reactive mode: the analysis starts from the files captured since the $(i,infer) command started" @@ -1663,13 +1667,13 @@ and reactive_capture = and report = CLOpt.mk_bool ~long:"report" ~default:true - ~in_help:CLOpt.([(Analyze, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic); (Run, manual_generic)]) "Run the reporting phase once the analysis has completed" and report_current = CLOpt.mk_path_opt ~long:"report-current" - ~in_help:CLOpt.([(ReportDiff, manual_generic)]) + ~in_help:InferCommand.([(ReportDiff, manual_generic)]) "report of the latest revision" @@ -1677,7 +1681,7 @@ and report_custom_error = CLOpt.mk_bool ~long:"report-custom-error" "" and report_formatter = CLOpt.mk_symbol ~long:"report-formatter" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~default:`Phabricator_formatter ~symbols:[("none", `No_formatter); ("phabricator", `Phabricator_formatter)] ~eq:PVariant.( = ) "Which formatter to use when emitting the report" @@ -1685,7 +1689,7 @@ and report_formatter = and report_hook = CLOpt.mk_string_opt ~long:"report-hook" - ~in_help:CLOpt.([(Analyze, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic); (Run, manual_generic)]) ~default:(lib_dir ^/ "python" ^/ "report.py") ~meta:"script" "Specify a script to be executed after the analysis results are written. This script will be passed, $(b,--issues-json), $(b,--issues-txt), $(b,--issues-xml), $(b,--project-root), and $(b,--results-dir)." @@ -1693,13 +1697,13 @@ and report_hook = and report_previous = CLOpt.mk_path_opt ~long:"report-previous" - ~in_help:CLOpt.([(ReportDiff, manual_generic)]) + ~in_help:InferCommand.([(ReportDiff, manual_generic)]) "Report of the base revision to use for comparison" and rest = CLOpt.mk_rest_actions - ~in_help:CLOpt.([(Capture, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Capture, manual_generic); (Run, manual_generic)]) "Stop argument processing, use remaining arguments as a build command" ~usage:exe_usage (fun build_exe -> match Filename.basename build_exe with "java" | "javac" -> CLOpt.Javac | _ -> CLOpt.NoParse @@ -1710,7 +1714,7 @@ and results_dir = CLOpt.mk_path ~deprecated:["results_dir"; "-out"] ~long:"results-dir" ~short:'o' ~default:(CLOpt.init_work_dir ^/ "infer-out") ~in_help: - CLOpt.( + InferCommand.( [ (Analyze, manual_generic) ; (Capture, manual_generic) ; (Explore, manual_generic) @@ -1721,7 +1725,7 @@ and results_dir = and save_results = CLOpt.mk_path_opt ~deprecated:["save_results"] ~long:"save-results" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~meta:"file.iar" "Save analysis results to Infer Analysis Results file file.iar" @@ -1732,44 +1736,44 @@ and seconds_per_iteration = and select = CLOpt.mk_int_opt ~long:"select" ~meta:"N" - ~in_help:CLOpt.([(Explore, manual_generic)]) + ~in_help:InferCommand.([(Explore, manual_generic)]) "Select bug number $(i,N). If omitted, prompt for input." and siof_safe_methods = CLOpt.mk_string_list ~long:"siof-safe-methods" - ~in_help:CLOpt.([(Analyze, manual_siof)]) + ~in_help:InferCommand.([(Analyze, manual_siof)]) "Methods that are SIOF-safe; \"foo::bar\" will match \"foo::bar()\", \"foo::bar()\", etc. (can be specified multiple times)" and skip_analysis_in_path = CLOpt.mk_string_list ~deprecated:["-skip-clang-analysis-in-path"] ~long:"skip-analysis-in-path" - ~in_help:CLOpt.([(Capture, manual_generic); (Run, manual_generic)]) + ~in_help:InferCommand.([(Capture, manual_generic); (Run, manual_generic)]) ~meta:"path_prefix_OCaml_regex" "Ignore files whose path matches the given prefix (can be specified multiple times)" and skip_analysis_in_path_skips_compilation = CLOpt.mk_bool ~long:"skip-analysis-in-path-skips-compilation" - ~in_help:CLOpt.([(Report, manual_generic)]) + ~in_help:InferCommand.([(Report, manual_generic)]) ~default:false "Whether paths in --skip-analysis-in-path should be compiled or not" and skip_duplicated_types = CLOpt.mk_bool ~long:"skip-duplicated-types" ~default:true - ~in_help:CLOpt.([(ReportDiff, manual_generic)]) + ~in_help:InferCommand.([(ReportDiff, manual_generic)]) "Skip fixed-then-introduced duplicated types while computing differential reports" and skip_translation_headers = CLOpt.mk_string_list ~deprecated:["skip_translation_headers"] ~long:"skip-translation-headers" - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) ~meta:"path_prefix" "Ignore headers whose path matches the given prefix" and source_preview = CLOpt.mk_bool ~long:"source-preview" ~default:true - ~in_help:CLOpt.([(Explore, manual_generic)]) + ~in_help:InferCommand.([(Explore, manual_generic)]) "print code excerpts around trace elements" @@ -1807,7 +1811,7 @@ and specs_library = ~f:(fun file -> specs_library := read_specs_dir_list_file file @ !specs_library ; "" ) - ~in_help:CLOpt.([(Analyze, manual_generic)]) + ~in_help:InferCommand.([(Analyze, manual_generic)]) ~meta:"file" "" in specs_library @@ -1828,14 +1832,14 @@ and sqlite_vfs = and stacktrace = CLOpt.mk_path_opt ~deprecated:["st"] ~long:"stacktrace" - ~in_help:CLOpt.([(Analyze, manual_crashcontext)]) + ~in_help:InferCommand.([(Analyze, manual_crashcontext)]) ~meta:"file" "File path containing a json-encoded Java crash stacktrace. Used to guide the analysis (only with '-a crashcontext'). See tests/codetoanalyze/java/crashcontext/*.json for examples of the expected format." and stacktraces_dir = CLOpt.mk_path_opt ~long:"stacktraces-dir" - ~in_help:CLOpt.([(Analyze, manual_crashcontext)]) + ~in_help:InferCommand.([(Analyze, manual_crashcontext)]) ~meta:"dir" "Directory path containing multiple json-encoded Java crash stacktraces. Used to guide the analysis (only with '-a crashcontext'). See tests/codetoanalyze/java/crashcontext/*.json for examples of the expected format." @@ -1868,7 +1872,7 @@ and testing_mode = and threadsafe_aliases = CLOpt.mk_json ~long:"threadsafe-aliases" - ~in_help:CLOpt.([(Analyze, manual_racerd)]) + ~in_help:InferCommand.([(Analyze, manual_racerd)]) "Specify custom annotations that should be considered aliases of @ThreadSafe" @@ -1915,17 +1919,17 @@ and uninit_interproc = and unsafe_malloc = CLOpt.mk_bool ~long:"unsafe-malloc" - ~in_help:CLOpt.([(Analyze, manual_clang)]) + ~in_help:InferCommand.([(Analyze, manual_clang)]) "Assume that malloc(3) never returns null." and version = let var = ref `None in CLOpt.mk_set var `Full ~deprecated:["version"] ~long:"version" - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Print version information and exit" ; CLOpt.mk_set var `Json ~deprecated:["version_json"] ~long:"version-json" - ~in_help:CLOpt.([(Run, manual_generic)]) + ~in_help:InferCommand.([(Run, manual_generic)]) "Print version information in json format and exit" ; CLOpt.mk_set var `Vcs ~long:"version-vcs" "Print version control system commit and exit" ; var @@ -1947,13 +1951,13 @@ and worklist_mode = and xcode_developer_dir = CLOpt.mk_path_opt ~long:"xcode-developer-dir" - ~in_help:CLOpt.([(Capture, manual_buck_flavors)]) + ~in_help:InferCommand.([(Capture, manual_buck_flavors)]) ~meta:"XCODE_DEVELOPER_DIR" "Specify the path to Xcode developer directory" and xcpretty = CLOpt.mk_bool ~long:"xcpretty" ~default:false - ~in_help:CLOpt.([(Capture, manual_clang)]) + ~in_help:InferCommand.([(Capture, manual_clang)]) "Infer will use xcpretty together with xcodebuild to analyze an iOS app. xcpretty just needs to be in the path, infer command is still just $(i,`infer -- `)." @@ -2147,7 +2151,7 @@ let post_parsing_initialization command_opt = 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 : CLOpt.command option) with + match (command_opt : InferCommand.t option) with | Some Compile -> analyzer := Some CompileOnly | Some Capture -> @@ -2164,7 +2168,7 @@ let post_parsing_initialization command_opt = linters := true | Some (CaptureOnly | Checkers | CompileOnly) | None -> () ) ; - Option.value ~default:CLOpt.Run command_opt + Option.value ~default:InferCommand.Run command_opt let command, parse_args_and_return_usage_exit = @@ -2546,7 +2550,7 @@ and quiet = !quiet and racerd = !racerd -and reactive_mode = !reactive || CLOpt.(equal_command Diff) command +and reactive_mode = !reactive || InferCommand.(equal Diff) command and reactive_capture = !reactive_capture @@ -2684,7 +2688,7 @@ let clang_frontend_action_string = let dynamic_dispatch = CLOpt.mk_bool ~long:"dynamic-dispatch" ~default:biabduction "Specify treatment of dynamic dispatch in Java code: false 'none' treats dynamic dispatch as a call to unknown code and true triggers lazy dynamic dispatch. The latter mode follows the JVM semantics and creates procedure descriptions during symbolic execution using the type information found in the abstract state" - ~in_help:CLOpt.([(Analyze, manual_java)]) + ~in_help:InferCommand.([(Analyze, manual_java)]) let dynamic_dispatch = !dynamic_dispatch diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index f83cc5d42..66e57f291 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -300,7 +300,7 @@ val clang_include_to_override_regex : string option val cluster_cmdline : string option -val command : CLOpt.command +val command : InferCommand.t val compute_analytics : bool diff --git a/infer/src/base/EventLogger.ml b/infer/src/base/EventLogger.ml index acddffc91..1926f9335 100644 --- a/infer/src/base/EventLogger.ml +++ b/infer/src/base/EventLogger.ml @@ -155,7 +155,7 @@ let create_row event = incr sequence_ctr ; let open JsonBuilder in let base = - empty |> add_string ~key:"command" ~data:(CLOpt.name_of_command Config.command) + empty |> add_string ~key:"command" ~data:(InferCommand.to_string Config.command) |> add_string ~key:"event_tag" ~data:(string_of_event event) |> add_string ~key:"hostname" ~data:(Unix.gethostname ()) |> add_string ~key:"infer_commit" ~data:Version.commit diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 319fdc132..ff6d5725a 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -394,7 +394,7 @@ let analyze_and_report ?suppress_console_report ~changed_files mode = in let should_merge = match mode with - | PythonCapture (BBuck, _) when Config.flavors && CLOpt.(equal_command Run) Config.command -> + | PythonCapture (BBuck, _) when Config.flavors && InferCommand.(equal Run) Config.command -> (* if doing capture + analysis of buck with flavors, we always need to merge targets before the analysis phase *) true | _ -> diff --git a/infer/src/integration/Maven.ml b/infer/src/integration/Maven.ml index 4fb7b7489..63b2c275f 100644 --- a/infer/src/integration/Maven.ml +++ b/infer/src/integration/Maven.ml @@ -35,7 +35,7 @@ let infer_profile = |} infer_profile_name - (Config.bin_dir ^/ CLOpt.infer_exe_name)) + (Config.bin_dir ^/ InferCommand.infer_exe_name)) let pom_worklist = ref [CLOpt.init_work_dir]