From bd74512c1a707967f2f85c6537510a8e609b79bb Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 18 Oct 2017 09:25:26 -0700 Subject: [PATCH] [cli] support all the analyzer forms in the filtering options Summary: This makes `--biabduction-blacklist-path-regex` and others work as expected. Reviewed By: mbouaziz Differential Revision: D6088625 fbshipit-source-id: 8f1daa3 --- infer/src/base/Config.ml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 56c9fccd4..9abb88772 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -575,11 +575,32 @@ and ( analysis_blacklist_files_containing_options , analysis_path_regex_whitelist_options , analysis_suppress_errors_options ) = let mk_filtering_options ~suffix ?(deprecated_suffix= []) ~help ~meta = - let mk_option analyzer_name = + (* 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 *) - CLOpt.mk_string_list ~deprecated ~long ~meta "" + 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 in ignore (let long = "-" ^ suffix in @@ -587,7 +608,7 @@ and ( analysis_blacklist_files_containing_options ~f:(fun _ -> raise (Arg.Bad "invalid option")) ~in_help:CLOpt.([(Report, manual_generic); (Run, manual_generic)]) help) ; - List.map ~f:(fun (name, analyzer) -> (analyzer, mk_option name)) string_to_analyzer + List.map ~f:(fun (name, analyzer) -> (analyzer, mk_option analyzer name)) string_to_analyzer in ( mk_filtering_options ~suffix:"blacklist-files-containing" ~deprecated_suffix:["blacklist_files_containing"]