[config] Use not-reversed list types for `Config` variables

Summary:
In `Config`, the lists generated by `mk_string_list`, `mk_path_list`, `mk_rest_actions` are reversed implicitly, which made it hard for developers to use them correctly. What the previous and this diff will do is to change the list variables of the `Config` to not-reversed one.

* diff1: First diff adds `RevList` to distinguish reversed lists explicitly. All usages of the reversed list should be changed to use `RevList`'s lib calls.

* diff2: Then this diff will change types of `Config` variables to not-reversed, normal list.

Reviewed By: ngorogiannis

Differential Revision: D25562303

fbshipit-source-id: 4cbc6d234
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 153005c3cb
commit b4b75c4ffb

@ -108,7 +108,7 @@ module Match = struct
let of_fuzzy_qual_names ?prefix fuzzy_qual_names = let of_fuzzy_qual_names ?prefix fuzzy_qual_names =
RevList.rev_map fuzzy_qual_names ~f:qualifiers_of_fuzzy_qual_name List.rev_map fuzzy_qual_names ~f:qualifiers_of_fuzzy_qual_name
|> qualifiers_list_matcher ?prefix |> qualifiers_list_matcher ?prefix

@ -87,7 +87,7 @@ val pp : Format.formatter -> t -> unit
module Match : sig module Match : sig
type quals_matcher type quals_matcher
val of_fuzzy_qual_names : ?prefix:bool -> string RevList.t -> quals_matcher val of_fuzzy_qual_names : ?prefix:bool -> string list -> quals_matcher
val match_qualifiers : quals_matcher -> t -> bool val match_qualifiers : quals_matcher -> t -> bool
end end

@ -30,14 +30,14 @@ let do_not_filter : filters =
type filter_config = type filter_config =
{ whitelist: string RevList.t { whitelist: string list
; blacklist: string RevList.t ; blacklist: string list
; blacklist_files_containing: string RevList.t ; blacklist_files_containing: string list
; suppress_errors: string RevList.t } ; suppress_errors: string list }
let is_matching patterns source_file = let is_matching patterns source_file =
let path = SourceFile.to_rel_path source_file in let path = SourceFile.to_rel_path source_file in
RevList.exists List.exists
~f:(fun pattern -> ~f:(fun pattern ->
try Int.equal (Str.search_forward pattern path 0) 0 with Caml.Not_found -> false ) try Int.equal (Str.search_forward pattern path 0) 0 with Caml.Not_found -> false )
patterns patterns
@ -77,20 +77,19 @@ module FileContainsStringMatcher = struct
Utils.with_file_in path ~f:(fun file_in -> not (loop regexp_not file_in)) ) Utils.with_file_in path ~f:(fun file_in -> not (loop regexp_not file_in)) )
let create_matcher (s_patterns : contains_pattern RevList.t) = let create_matcher (s_patterns : contains_pattern list) =
if RevList.is_empty s_patterns then default_matcher if List.is_empty s_patterns then default_matcher
else else
let source_map = ref SourceFile.Map.empty in let source_map = ref SourceFile.Map.empty in
let not_contains_patterns = let not_contains_patterns =
RevList.exists ~f:(fun {not_contains} -> Option.is_some not_contains) s_patterns List.exists ~f:(fun {not_contains} -> Option.is_some not_contains) s_patterns
in in
let disjunctive_regexp = let disjunctive_regexp =
Str.regexp Str.regexp (String.concat ~sep:"\\|" (List.map ~f:(fun {contains} -> contains) s_patterns))
(String.concat ~sep:"\\|" (RevList.rev_map ~f:(fun {contains} -> contains) s_patterns))
in in
let cond check_regexp = let cond check_regexp =
if not_contains_patterns then if not_contains_patterns then
RevList.exists List.exists
~f:(fun {contains; not_contains} -> ~f:(fun {contains; not_contains} ->
check_regexp (Str.regexp contains) (Option.map not_contains ~f:Str.regexp) ) check_regexp (Str.regexp contains) (Option.map not_contains ~f:Str.regexp) )
s_patterns s_patterns
@ -125,10 +124,10 @@ module FileOrProcMatcher = struct
let default_matcher : matcher = fun _ _ -> false let default_matcher : matcher = fun _ _ -> false
let create_method_matcher m_patterns = let create_method_matcher m_patterns =
if RevList.is_empty m_patterns then default_matcher if List.is_empty m_patterns then default_matcher
else else
let pattern_map = let pattern_map =
RevList.fold List.fold
~f:(fun map pattern -> ~f:(fun map pattern ->
let previous = let previous =
try String.Map.find_exn map pattern.class_name try String.Map.find_exn map pattern.class_name
@ -162,6 +161,7 @@ module FileOrProcMatcher = struct
in in
List.fold ~f:collect ~init:(RevList.empty, RevList.empty) patterns List.fold ~f:collect ~init:(RevList.empty, RevList.empty) patterns
in in
let s_patterns, m_patterns = (RevList.to_list s_patterns, RevList.to_list m_patterns) in
let s_matcher = let s_matcher =
let matcher = FileContainsStringMatcher.create_matcher s_patterns in let matcher = FileContainsStringMatcher.create_matcher s_patterns in
fun source_file _ -> matcher source_file fun source_file _ -> matcher source_file
@ -331,15 +331,15 @@ let load_filters () =
let filters_from_inferconfig inferconfig : filters = let filters_from_inferconfig inferconfig : filters =
let path_filter = let path_filter =
let whitelist_filter : path_filter = let whitelist_filter : path_filter =
if RevList.is_empty inferconfig.whitelist then default_path_filter if List.is_empty inferconfig.whitelist then default_path_filter
else is_matching (RevList.map ~f:Str.regexp inferconfig.whitelist) else is_matching (List.map ~f:Str.regexp inferconfig.whitelist)
in in
let blacklist_filter : path_filter = let blacklist_filter : path_filter =
is_matching (RevList.map ~f:Str.regexp inferconfig.blacklist) is_matching (List.map ~f:Str.regexp inferconfig.blacklist)
in in
let blacklist_files_containing_filter : path_filter = let blacklist_files_containing_filter : path_filter =
FileContainsStringMatcher.create_matcher FileContainsStringMatcher.create_matcher
(RevList.map (List.map
~f:(fun s -> {contains= s; not_contains= None}) ~f:(fun s -> {contains= s; not_contains= None})
inferconfig.blacklist_files_containing) inferconfig.blacklist_files_containing)
in in
@ -352,7 +352,7 @@ let filters_from_inferconfig inferconfig : filters =
let error_filter = function let error_filter = function
| error_name -> | error_name ->
let error_str = error_name.IssueType.unique_id in let error_str = error_name.IssueType.unique_id in
not (RevList.exists ~f:(String.equal error_str) inferconfig.suppress_errors) not (List.exists ~f:(String.equal error_str) inferconfig.suppress_errors)
in in
{path_filter; error_filter; proc_filter= default_proc_filter} {path_filter; error_filter; proc_filter= default_proc_filter}

@ -123,12 +123,12 @@ end = struct
List.concat_map lock_models ~f:(fun mdl -> List.concat_map lock_models ~f:(fun mdl ->
List.map (f mdl) ~f:(fun mtd -> mdl.classname ^ "::" ^ mtd) ) List.map (f mdl) ~f:(fun mtd -> mdl.classname ^ "::" ^ mtd) )
in in
mk_matcher (RevList.of_list lock_methods) mk_matcher lock_methods
in in
( mk_model_matcher ~f:(fun mdl -> mdl.lock) ( mk_model_matcher ~f:(fun mdl -> mdl.lock)
, mk_model_matcher ~f:(fun mdl -> mdl.unlock) , mk_model_matcher ~f:(fun mdl -> mdl.unlock)
, mk_model_matcher ~f:(fun mdl -> mdl.trylock) , mk_model_matcher ~f:(fun mdl -> mdl.trylock)
, mk_matcher (RevList.of_list ["std::lock"]) ) , mk_matcher ["std::lock"] )
(** C++ guard classes used for scope-based lock management. NB we pretend all classes below (** C++ guard classes used for scope-based lock management. NB we pretend all classes below
@ -192,11 +192,11 @@ end = struct
let is_guard_constructor, is_guard_destructor, is_guard_unlock, is_guard_lock, is_guard_trylock = let is_guard_constructor, is_guard_destructor, is_guard_unlock, is_guard_lock, is_guard_trylock =
let make ~f = let make ~f =
let constructors = List.map guards ~f in let constructors = List.map guards ~f in
mk_matcher (RevList.of_list constructors) mk_matcher constructors
in in
let make_trylock ~f = let make_trylock ~f =
let methods = List.concat_map guards ~f in let methods = List.concat_map guards ~f in
mk_matcher (RevList.of_list methods) mk_matcher methods
in in
( make ~f:get_guard_constructor ( make ~f:get_guard_constructor
, make ~f:get_guard_destructor , make ~f:get_guard_destructor

@ -331,14 +331,13 @@ let context_with_ck_set context decl_list =
let find_linters_files () = let find_linters_files () =
RevList.rev_concat_map List.concat_map
~f:(fun folder -> Utils.find_files ~path:folder ~extension:".al") ~f:(fun folder -> Utils.find_files ~path:folder ~extension:".al")
Config.linters_def_folder Config.linters_def_folder
let linters_files = let linters_files =
RevList.dedup_and_sort ~compare:String.compare List.dedup_and_sort ~compare:String.compare (find_linters_files () @ Config.linters_def_file)
(RevList.rev_append (find_linters_files ()) Config.linters_def_file)
let is_decl_allowed lcxt decl = let is_decl_allowed lcxt decl =

@ -29,7 +29,7 @@ let validate_al_files () =
None None
with CTLExceptions.ALFileException exc_info -> Some (CTLExceptions.json_of_exc_info exc_info) with CTLExceptions.ALFileException exc_info -> Some (CTLExceptions.json_of_exc_info exc_info)
in in
match RevList.rev_filter_map ~f:validate_al_file Config.linters_def_file with match List.filter_map ~f:validate_al_file Config.linters_def_file with
| [] -> | [] ->
Ok () Ok ()
| _ as errors -> | _ as errors ->

@ -231,9 +231,10 @@ end = struct
let is_whitelisted = let is_whitelisted =
if RevList.is_empty Config.write_html_whitelist_regex then fun _ -> true match Config.write_html_whitelist_regex with
else | [] ->
let reg_list = RevList.to_list Config.write_html_whitelist_regex in fun _ -> true
| _ as reg_list ->
let regex = Str.regexp (String.concat ~sep:"\\|" reg_list) in let regex = Str.regexp (String.concat ~sep:"\\|" reg_list) in
fun file -> fun file ->
let fname = SourceFile.to_rel_path file in let fname = SourceFile.to_rel_path file in

@ -809,12 +809,11 @@ let string_of_command command =
let mk_rest_actions ?(parse_mode = InferCommand) ?(in_help = []) doc ~usage decode_action = let mk_rest_actions ?(parse_mode = InferCommand) ?(in_help = []) doc ~usage decode_action =
let rest = ref RevList.empty in let rest = ref [] in
let spec = let spec =
String String
(fun arg -> (fun arg ->
rest := rest := Array.to_list (Array.slice !args_to_parse (!arg_being_parsed + 1) 0) ;
RevList.of_list (Array.to_list (Array.slice !args_to_parse (!arg_being_parsed + 1) 0)) ;
select_parse_mode ~usage (decode_action arg) |> ignore ) select_parse_mode ~usage (decode_action arg) |> ignore )
in in
add parse_mode in_help add parse_mode in_help

@ -147,7 +147,7 @@ val mk_rest_actions :
-> string -> string
-> usage:string -> usage:string
-> (string -> parse_mode) -> (string -> parse_mode)
-> string RevList.t ref -> string list ref
(** [mk_rest_actions doc ~usage command_to_parse_mode] defines a [string list ref] of the command (** [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] line arguments following ["--"], in the reverse order they appeared on the command line. [usage]
is the usage message in case of parse errors or if --help is passed. For example, calling is the usage message in case of parse errors or if --help is passed. For example, calling

@ -2731,7 +2731,7 @@ and annotation_reachability_cxx_sources = !annotation_reachability_cxx_sources
and annotation_reachability_custom_pairs = !annotation_reachability_custom_pairs and annotation_reachability_custom_pairs = !annotation_reachability_custom_pairs
and append_buck_flavors = !append_buck_flavors and append_buck_flavors = RevList.to_list !append_buck_flavors
and array_level = !array_level and array_level = !array_level
@ -2745,11 +2745,11 @@ and bo_field_depth_limit = !bo_field_depth_limit
and buck = !buck and buck = !buck
and buck_blacklist = !buck_blacklist and buck_blacklist = RevList.to_list !buck_blacklist
and buck_build_args = !buck_build_args and buck_build_args = RevList.to_list !buck_build_args
and buck_build_args_no_inline_rev = !buck_build_args_no_inline_rev and buck_build_args_no_inline = RevList.to_list !buck_build_args_no_inline_rev
and buck_cache_mode = (!buck || !genrule_mode) && not !debug and buck_cache_mode = (!buck || !genrule_mode) && not !debug
@ -2777,7 +2777,7 @@ and buck_mode : BuckMode.t option =
Some JavaFlavor Some JavaFlavor
and buck_targets_blacklist = !buck_targets_blacklist and buck_targets_blacklist = RevList.to_list !buck_targets_blacklist
and call_graph_schedule = !call_graph_schedule and call_graph_schedule = !call_graph_schedule
@ -2786,7 +2786,7 @@ and capture = !capture
and capture_blacklist = !capture_blacklist and capture_blacklist = !capture_blacklist
and censor_report = and censor_report =
RevList.map !censor_report ~f:(fun str -> RevList.rev_map !censor_report ~f:(fun str ->
match String.split str ~on:':' with match String.split str ~on:':' with
| [issue_type_re; filename_re; reason_str] | [issue_type_re; filename_re; reason_str]
when not String.(is_empty issue_type_re || is_empty filename_re || is_empty reason_str) -> when not String.(is_empty issue_type_re || is_empty filename_re || is_empty reason_str) ->
@ -2822,11 +2822,11 @@ and clang_compilation_dbs = !clang_compilation_dbs
and clang_compound_literal_init_limit = !clang_compound_literal_init_limit and clang_compound_literal_init_limit = !clang_compound_literal_init_limit
and clang_extra_flags = !clang_extra_flags and clang_extra_flags = RevList.to_list !clang_extra_flags
and clang_blacklisted_flags = !clang_blacklisted_flags and clang_blacklisted_flags = RevList.to_list !clang_blacklisted_flags
and clang_blacklisted_flags_with_arg = !clang_blacklisted_flags_with_arg and clang_blacklisted_flags_with_arg = RevList.to_list !clang_blacklisted_flags_with_arg
and clang_ignore_regex = !clang_ignore_regex and clang_ignore_regex = !clang_ignore_regex
@ -2935,7 +2935,7 @@ and genrule_mode = !genrule_mode
and get_linter_doc_url = process_linters_doc_url !linters_doc_url and get_linter_doc_url = process_linters_doc_url !linters_doc_url
and help_checker = and help_checker =
RevList.map !help_checker ~f:(fun checker_string -> RevList.rev_map !help_checker ~f:(fun checker_string ->
match Checker.from_id checker_string with match Checker.from_id checker_string with
| Some checker -> | Some checker ->
checker checker
@ -2947,7 +2947,7 @@ and help_checker =
and help_issue_type = and help_issue_type =
RevList.map !help_issue_type ~f:(fun id -> RevList.rev_map !help_issue_type ~f:(fun id ->
match IssueType.find_from_string ~id with match IssueType.find_from_string ~id with
| Some issue_type -> | Some issue_type ->
issue_type issue_type
@ -2993,9 +2993,9 @@ and join_cond = !join_cond
and linter = !linter and linter = !linter
and linters_def_file = !linters_def_file and linters_def_file = RevList.to_list !linters_def_file
and linters_def_folder = !linters_def_folder and linters_def_folder = RevList.to_list !linters_def_folder
and linters_developer_mode = !linters_developer_mode and linters_developer_mode = !linters_developer_mode
@ -3009,7 +3009,7 @@ and list_issue_types = !list_issue_types
and liveness_dangerous_classes = !liveness_dangerous_classes and liveness_dangerous_classes = !liveness_dangerous_classes
and liveness_ignored_constant = !liveness_ignored_constant and liveness_ignored_constant = RevList.to_list !liveness_ignored_constant
and load_average = and load_average =
match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average
@ -3127,13 +3127,13 @@ and pulse_isl = !pulse_isl
and pulse_max_disjuncts = !pulse_max_disjuncts and pulse_max_disjuncts = !pulse_max_disjuncts
and pulse_model_abort = !pulse_model_abort and pulse_model_abort = RevList.to_list !pulse_model_abort
and pulse_model_alloc_pattern = Option.map ~f:Str.regexp !pulse_model_alloc_pattern and pulse_model_alloc_pattern = Option.map ~f:Str.regexp !pulse_model_alloc_pattern
and pulse_model_release_pattern = Option.map ~f:Str.regexp !pulse_model_release_pattern and pulse_model_release_pattern = Option.map ~f:Str.regexp !pulse_model_release_pattern
and pulse_model_return_nonnull = !pulse_model_return_nonnull and pulse_model_return_nonnull = RevList.to_list !pulse_model_return_nonnull
and pulse_model_skip_pattern = Option.map ~f:Str.regexp !pulse_model_skip_pattern and pulse_model_skip_pattern = Option.map ~f:Str.regexp !pulse_model_skip_pattern
@ -3186,7 +3186,7 @@ and relative_path_backtrack = !relative_path_backtrack
and report = !report and report = !report
and report_blacklist_files_containing = !report_blacklist_files_containing and report_blacklist_files_containing = RevList.to_list !report_blacklist_files_containing
and report_console_limit = !report_console_limit and report_console_limit = !report_console_limit
@ -3200,13 +3200,13 @@ and report_formatter = !report_formatter
and report_immutable_modifications = !report_immutable_modifications and report_immutable_modifications = !report_immutable_modifications
and report_path_regex_blacklist = !report_path_regex_blacklist and report_path_regex_blacklist = RevList.to_list !report_path_regex_blacklist
and report_path_regex_whitelist = !report_path_regex_whitelist and report_path_regex_whitelist = RevList.to_list !report_path_regex_whitelist
and report_previous = !report_previous and report_previous = !report_previous
and report_suppress_errors = !report_suppress_errors and report_suppress_errors = RevList.to_list !report_suppress_errors
and reports_include_ml_loc = !reports_include_ml_loc and reports_include_ml_loc = !reports_include_ml_loc
@ -3240,15 +3240,15 @@ and print_jbir = !print_jbir
and siof_check_iostreams = !siof_check_iostreams and siof_check_iostreams = !siof_check_iostreams
and siof_safe_methods = !siof_safe_methods and siof_safe_methods = RevList.to_list !siof_safe_methods
and skip_analysis_in_path = !skip_analysis_in_path and skip_analysis_in_path = RevList.to_list !skip_analysis_in_path
and skip_analysis_in_path_skips_compilation = !skip_analysis_in_path_skips_compilation and skip_analysis_in_path_skips_compilation = !skip_analysis_in_path_skips_compilation
and skip_duplicated_types = !skip_duplicated_types and skip_duplicated_types = !skip_duplicated_types
and skip_translation_headers = !skip_translation_headers and skip_translation_headers = RevList.to_list !skip_translation_headers
and source_preview = !source_preview and source_preview = !source_preview
@ -3264,7 +3264,7 @@ and source_files_procedure_names = !source_files_procedure_names
and source_files_freshly_captured = !source_files_freshly_captured and source_files_freshly_captured = !source_files_freshly_captured
and sources = !sources and sources = RevList.to_list !sources
and sourcepath = !sourcepath and sourcepath = !sourcepath
@ -3321,7 +3321,7 @@ and topl_max_conjuncts = !topl_max_conjuncts
and topl_max_disjuncts = !topl_max_disjuncts and topl_max_disjuncts = !topl_max_disjuncts
and topl_properties = !topl_properties and topl_properties = RevList.to_list !topl_properties
and trace_error = !trace_error and trace_error = !trace_error
@ -3357,7 +3357,7 @@ and write_dotty = !write_dotty
and write_html = !write_html and write_html = !write_html
and write_html_whitelist_regex = !write_html_whitelist_regex and write_html_whitelist_regex = RevList.to_list !write_html_whitelist_regex
and write_website = !write_website and write_website = !write_website

@ -39,7 +39,7 @@ val anonymous_block_num_sep : string
val anonymous_block_prefix : string val anonymous_block_prefix : string
val append_buck_flavors : string RevList.t val append_buck_flavors : string list
val assign : string val assign : string
@ -132,7 +132,7 @@ val kotlin_source_extension : string
val sourcepath : string option val sourcepath : string option
val sources : string RevList.t val sources : string list
val trace_absarray : bool val trace_absarray : bool
@ -174,11 +174,11 @@ val bootclasspath : string option
val buck : bool val buck : bool
val buck_blacklist : string RevList.t val buck_blacklist : string list
val buck_build_args : string RevList.t val buck_build_args : string list
val buck_build_args_no_inline_rev : string RevList.t val buck_build_args_no_inline : string list
val buck_cache_mode : bool val buck_cache_mode : bool
@ -188,7 +188,7 @@ val buck_mode : BuckMode.t option
val buck_out_gen : string val buck_out_gen : string
val buck_targets_blacklist : string RevList.t val buck_targets_blacklist : string list
val call_graph_schedule : bool val call_graph_schedule : bool
@ -196,7 +196,7 @@ val capture : bool
val capture_blacklist : string option val capture_blacklist : string option
val censor_report : ((bool * Str.regexp) * (bool * Str.regexp) * string) RevList.t val censor_report : ((bool * Str.regexp) * (bool * Str.regexp) * string) list
val changed_files_index : string option val changed_files_index : string option
@ -206,11 +206,11 @@ val clang_ast_file : [`Biniou of string | `Yojson of string] option
val clang_compound_literal_init_limit : int val clang_compound_literal_init_limit : int
val clang_extra_flags : string RevList.t val clang_extra_flags : string list
val clang_blacklisted_flags : string RevList.t val clang_blacklisted_flags : string list
val clang_blacklisted_flags_with_arg : string RevList.t val clang_blacklisted_flags_with_arg : string list
val clang_ignore_regex : string option val clang_ignore_regex : string option
@ -310,9 +310,9 @@ val genrule_mode : bool
val get_linter_doc_url : linter_id:string -> string option val get_linter_doc_url : linter_id:string -> string option
val help_checker : Checker.t RevList.t val help_checker : Checker.t list
val help_issue_type : IssueType.t RevList.t val help_issue_type : IssueType.t list
val hoisting_report_only_expensive : bool val hoisting_report_only_expensive : bool
@ -362,9 +362,9 @@ val keep_going : bool
val linter : string option val linter : string option
val linters_def_file : string RevList.t val linters_def_file : string list
val linters_def_folder : string RevList.t val linters_def_folder : string list
val linters_developer_mode : bool val linters_developer_mode : bool
@ -378,7 +378,7 @@ val list_issue_types : bool
val liveness_dangerous_classes : Yojson.Basic.t val liveness_dangerous_classes : Yojson.Basic.t
val liveness_ignored_constant : string RevList.t val liveness_ignored_constant : string list
val max_nesting : int option val max_nesting : int option
@ -471,13 +471,13 @@ val pulse_isl : bool [@@warning "-32"]
val pulse_max_disjuncts : int val pulse_max_disjuncts : int
val pulse_model_abort : string RevList.t val pulse_model_abort : string list
val pulse_model_alloc_pattern : Str.regexp option val pulse_model_alloc_pattern : Str.regexp option
val pulse_model_release_pattern : Str.regexp option val pulse_model_release_pattern : Str.regexp option
val pulse_model_return_nonnull : string RevList.t val pulse_model_return_nonnull : string list
val pulse_model_skip_pattern : Str.regexp option val pulse_model_skip_pattern : Str.regexp option
@ -509,7 +509,7 @@ val reactive_mode : bool
val reanalyze : bool val reanalyze : bool
val report_blacklist_files_containing : string RevList.t val report_blacklist_files_containing : string list
val report_console_limit : int option val report_console_limit : int option
@ -517,17 +517,17 @@ val report_current : string option
val report_formatter : [`No_formatter | `Phabricator_formatter] val report_formatter : [`No_formatter | `Phabricator_formatter]
val report_path_regex_blacklist : string RevList.t val report_path_regex_blacklist : string list
val report_path_regex_whitelist : string RevList.t val report_path_regex_whitelist : string list
val report_previous : string option val report_previous : string option
val report_suppress_errors : string RevList.t val report_suppress_errors : string list
val reports_include_ml_loc : bool val reports_include_ml_loc : bool
val rest : string RevList.t val rest : string list
val results_dir : string val results_dir : string
@ -547,15 +547,15 @@ val show_buckets : bool
val siof_check_iostreams : bool val siof_check_iostreams : bool
val siof_safe_methods : string RevList.t val siof_safe_methods : string list
val skip_analysis_in_path : string RevList.t val skip_analysis_in_path : string list
val skip_analysis_in_path_skips_compilation : bool val skip_analysis_in_path_skips_compilation : bool
val skip_duplicated_types : bool val skip_duplicated_types : bool
val skip_translation_headers : string RevList.t val skip_translation_headers : string list
val source_files : bool val source_files : bool
@ -607,7 +607,7 @@ val topl_max_conjuncts : int
val topl_max_disjuncts : int val topl_max_disjuncts : int
val topl_properties : string RevList.t val topl_properties : string list
val trace_error : bool val trace_error : bool
@ -641,7 +641,7 @@ val write_dotty : bool
val write_html : bool val write_html : bool
val write_html_whitelist_regex : string RevList.t val write_html_whitelist_regex : string list
val write_website : string option val write_website : string option

@ -14,7 +14,7 @@ module L = Logging
module F = Format module F = Format
module DExp = DecompiledExp module DExp = DecompiledExp
let vector_matcher = QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list ["std::vector"]) let vector_matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["std::vector"]
let is_one_of_classes = QualifiedCppName.Match.match_qualifiers let is_one_of_classes = QualifiedCppName.Match.match_qualifiers

@ -50,8 +50,7 @@ let models = List.map ~f:parse_siof_model [("std::ios_base::Init::Init", standar
let is_modelled = let is_modelled =
let models_matcher = let models_matcher =
List.map models ~f:(fun {qual_name} -> qual_name) List.map models ~f:(fun {qual_name} -> qual_name) |> QualifiedCppName.Match.of_fuzzy_qual_names
|> RevList.of_list |> QualifiedCppName.Match.of_fuzzy_qual_names
in in
fun pname -> fun pname ->
Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers models_matcher Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers models_matcher
@ -76,8 +75,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let filter_global_accesses initialized = let filter_global_accesses initialized =
let initialized_matcher = let initialized_matcher =
Domain.VarNames.elements initialized Domain.VarNames.elements initialized |> QualifiedCppName.Match.of_fuzzy_qual_names
|> RevList.of_list |> QualifiedCppName.Match.of_fuzzy_qual_names
in in
Staged.stage (fun (* gvar \notin initialized, up to some fuzzing *) Staged.stage (fun (* gvar \notin initialized, up to some fuzzing *)
gvar -> gvar ->
@ -155,7 +153,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let init = let init =
List.find_map_exn models ~f:(fun {qual_name; initialized_globals} -> List.find_map_exn models ~f:(fun {qual_name; initialized_globals} ->
if if
QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list [qual_name]) QualifiedCppName.Match.of_fuzzy_qual_names [qual_name]
|> Fn.flip QualifiedCppName.Match.match_qualifiers |> Fn.flip QualifiedCppName.Match.match_qualifiers
(Procname.get_qualifiers callee_pname) (Procname.get_qualifiers callee_pname)
then Some initialized_globals then Some initialized_globals

@ -54,15 +54,13 @@ end
module CheckerMode : LivenessConfig = struct module CheckerMode : LivenessConfig = struct
let blacklisted_destructor_matcher = let blacklisted_destructor_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names QualifiedCppName.Match.of_fuzzy_qual_names
(RevList.of_list
(string_list_of_json ~option_name:"liveness-dangerous-classes" ~init:[] (string_list_of_json ~option_name:"liveness-dangerous-classes" ~init:[]
Config.liveness_dangerous_classes)) Config.liveness_dangerous_classes)
(** hardcoded list of wrappers, mostly because they are impossible to specify as config options *) (** hardcoded list of wrappers, mostly because they are impossible to specify as config options *)
let standard_wrappers_matcher = let standard_wrappers_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names QualifiedCppName.Match.of_fuzzy_qual_names ["std::unique_ptr"; "std::shared_ptr"]
(RevList.of_list ["std::unique_ptr"; "std::shared_ptr"])
let is_blacklisted_class_name class_name = let is_blacklisted_class_name class_name =
@ -178,7 +176,7 @@ let matcher_scope_guard =
let default_scope_guards = ["CKComponentKey"; "CKComponentScope"] in let default_scope_guards = ["CKComponentKey"; "CKComponentScope"] in
string_list_of_json ~option_name:"cxx-scope_guards" ~init:default_scope_guards string_list_of_json ~option_name:"cxx-scope_guards" ~init:default_scope_guards
Config.cxx_scope_guards Config.cxx_scope_guards
|> RevList.of_list |> QualifiedCppName.Match.of_fuzzy_qual_names |> QualifiedCppName.Match.of_fuzzy_qual_names
module CapturedByRefTransferFunctions (CFG : ProcCfg.S) = struct module CapturedByRefTransferFunctions (CFG : ProcCfg.S) = struct
@ -218,7 +216,7 @@ module IntLitSet = Caml.Set.Make (IntLit)
let ignored_constants = let ignored_constants =
let int_lit_constants = let int_lit_constants =
RevList.map List.map
~f:(fun el -> ~f:(fun el ->
try IntLit.of_string el try IntLit.of_string el
with Invalid_argument _ -> with Invalid_argument _ ->
@ -226,7 +224,7 @@ let ignored_constants =
"Ill-formed option '%s' for --liveness-ignored-constant: an integer was expected" el ) "Ill-formed option '%s' for --liveness-ignored-constant: an integer was expected" el )
Config.liveness_ignored_constant Config.liveness_ignored_constant
in in
IntLitSet.of_seq (RevList.to_rev_seq int_lit_constants) IntLitSet.of_list int_lit_constants
let checker {IntraproceduralAnalysis.proc_desc; err_log} = let checker {IntraproceduralAnalysis.proc_desc; err_log} =

@ -331,7 +331,7 @@ let get_superclass_decls decl =
let translate_as_type_ptr_matcher = let translate_as_type_ptr_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list ["infer_traits::TranslateAsType"]) QualifiedCppName.Match.of_fuzzy_qual_names ["infer_traits::TranslateAsType"]
let get_translate_as_friend_decl decl_list = let get_translate_as_friend_decl decl_list =

@ -114,16 +114,15 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?(
(Exn.to_string e) ; (Exn.to_string e) ;
aux in_argfiles' (false, at_argfile :: res_rev, changed) tl ) aux in_argfiles' (false, at_argfile :: res_rev, changed) tl )
| flag :: tl | flag :: tl
when RevList.mem ~equal:String.equal Config.clang_blacklisted_flags flag when List.mem ~equal:String.equal Config.clang_blacklisted_flags flag
|| String.lsplit2 ~on:'=' flag || String.lsplit2 ~on:'=' flag
|> function |> function
| Some (flag, _arg) -> | Some (flag, _arg) ->
RevList.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag
| None -> | None ->
false -> false ->
aux in_argfiles (false, res_rev, true) tl aux in_argfiles (false, res_rev, true) tl
| flag :: tl when RevList.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag | flag :: tl when List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag ->
->
(* remove the flag and its arg separately in case we are at the end of an argfile *) (* remove the flag and its arg separately in case we are at the end of an argfile *)
aux in_argfiles (true, res_rev, true) tl aux in_argfiles (true, res_rev, true) tl
| arg :: tl -> | arg :: tl ->
@ -205,7 +204,7 @@ let mk ~is_driver quoting_style ~prog ~args =
(* Some arguments break the compiler so they need to be removed even before the normalization step *) (* Some arguments break the compiler so they need to be removed even before the normalization step *)
let sanitized_args = filter_and_replace_unsupported_args args in let sanitized_args = filter_and_replace_unsupported_args args in
let sanitized_args = let sanitized_args =
if is_driver then sanitized_args @ RevList.to_list Config.clang_extra_flags else sanitized_args if is_driver then sanitized_args @ Config.clang_extra_flags else sanitized_args
in in
{exec= prog; orig_argv= sanitized_args; argv= sanitized_args; quoting_style; is_driver} {exec= prog; orig_argv= sanitized_args; argv= sanitized_args; quoting_style; is_driver}

@ -106,7 +106,7 @@ let return_param = "__return_param"
let self = "self" let self = "self"
let std_addressof = QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list ["std::addressof"]) let std_addressof = QualifiedCppName.Match.of_fuzzy_qual_names ["std::addressof"]
let string_with_utf8_m = "stringWithUTF8String:" let string_with_utf8_m = "stringWithUTF8String:"

@ -300,11 +300,9 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
method should be translated based on method and class whitelists *) method should be translated based on method and class whitelists *)
let is_whitelisted_cpp_method = let is_whitelisted_cpp_method =
let method_matcher = let method_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list Config.whitelisted_cpp_methods) QualifiedCppName.Match.of_fuzzy_qual_names Config.whitelisted_cpp_methods
in
let class_matcher =
QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list Config.whitelisted_cpp_classes)
in in
let class_matcher = QualifiedCppName.Match.of_fuzzy_qual_names Config.whitelisted_cpp_classes in
fun qual_name -> fun qual_name ->
(* either the method is explictely whitelisted, or the whole class is whitelisted *) (* either the method is explictely whitelisted, or the whole class is whitelisted *)
QualifiedCppName.Match.match_qualifiers method_matcher qual_name QualifiedCppName.Match.match_qualifiers method_matcher qual_name

@ -24,7 +24,7 @@ let source_file_in_project source_file =
let file_in_project = SourceFile.is_under_project_root source_file in let file_in_project = SourceFile.is_under_project_root source_file in
let rel_source_file = SourceFile.to_string source_file in let rel_source_file = SourceFile.to_string source_file in
let file_should_be_skipped = let file_should_be_skipped =
RevList.exists List.exists
~f:(fun path -> String.is_prefix ~prefix:path rel_source_file) ~f:(fun path -> String.is_prefix ~prefix:path rel_source_file)
Config.skip_translation_headers Config.skip_translation_headers
in in
@ -83,7 +83,7 @@ let should_translate_lib translation_unit source_range decl_trans_context ~trans
let is_file_blacklisted file = let is_file_blacklisted file =
let paths = Config.skip_analysis_in_path in let paths = Config.skip_analysis_in_path in
let is_file_blacklisted = let is_file_blacklisted =
RevList.exists ~f:(fun path -> Str.string_match (Str.regexp ("^.*/" ^ path)) file 0) paths List.exists ~f:(fun path -> Str.string_match (Str.regexp ("^.*/" ^ path)) file 0) paths
in in
is_file_blacklisted is_file_blacklisted

@ -45,7 +45,7 @@ let test_fuzzy_match =
; ("test_std_fuzzy_no_match1", ["std::foo"], ["std"; "__1"; "__2"; "foo"], false) ; ("test_std_fuzzy_no_match1", ["std::foo"], ["std"; "__1"; "__2"; "foo"], false)
; ("test_std_fuzzy_no_match2", ["std::foo"], ["std"; "__1"; "foo"; "bad"], false) ] ; ("test_std_fuzzy_no_match2", ["std::foo"], ["std"; "__1"; "foo"; "bad"], false) ]
|> List.map ~f:(fun (name, fuzzy_qual_names, qualifiers, expected_output) -> |> List.map ~f:(fun (name, fuzzy_qual_names, qualifiers, expected_output) ->
name >:: create_test (RevList.of_list fuzzy_qual_names) qualifiers expected_output ) name >:: create_test fuzzy_qual_names qualifiers expected_output )
let tests = "qualified_cpp_name_fuzzy_match" >::: test_fuzzy_match let tests = "qualified_cpp_name_fuzzy_match" >::: test_fuzzy_match

@ -119,7 +119,7 @@ let is_cpp_container_read =
QualifiedCppName.extract_last pname_qualifiers QualifiedCppName.extract_last pname_qualifiers
|> Option.exists ~f:(fun (last, _) -> String.equal last "operator[]") |> Option.exists ~f:(fun (last, _) -> String.equal last "operator[]")
in in
let matcher = QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list ["std::map::find"]) in let matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["std::map::find"] in
fun pname -> fun pname ->
let pname_qualifiers = Procname.get_qualifiers pname in let pname_qualifiers = Procname.get_qualifiers pname in
QualifiedCppName.Match.match_qualifiers matcher pname_qualifiers QualifiedCppName.Match.match_qualifiers matcher pname_qualifiers
@ -128,8 +128,7 @@ let is_cpp_container_read =
let is_cpp_container_write = let is_cpp_container_write =
let matcher = let matcher =
QualifiedCppName.Match.of_fuzzy_qual_names QualifiedCppName.Match.of_fuzzy_qual_names ["std::map::operator[]"; "std::map::erase"]
(RevList.of_list ["std::map::operator[]"; "std::map::erase"])
in in
fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Procname.get_qualifiers pname) fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Procname.get_qualifiers pname)
@ -163,7 +162,6 @@ let should_skip =
let matcher = let matcher =
lazy lazy
(QualifiedCppName.Match.of_fuzzy_qual_names ~prefix:true (QualifiedCppName.Match.of_fuzzy_qual_names ~prefix:true
(RevList.of_list
[ "folly::AtomicStruct" [ "folly::AtomicStruct"
; "folly::fbstring_core" ; "folly::fbstring_core"
; "folly::Future" ; "folly::Future"
@ -174,7 +172,7 @@ let should_skip =
; "folly::ThreadLocal" ; "folly::ThreadLocal"
; "folly::detail::SingletonHolder" ; "folly::detail::SingletonHolder"
; "std::atomic" ; "std::atomic"
; "std::vector" ])) ; "std::vector" ])
in in
function function
| Procname.ObjC_Cpp cpp_pname as pname -> | Procname.ObjC_Cpp cpp_pname as pname ->

@ -168,15 +168,14 @@ let () =
if if
Config.( Config.(
list_checkers || list_issue_types || Option.is_some write_website list_checkers || list_issue_types || Option.is_some write_website
|| (not (RevList.is_empty help_checker)) || (not (List.is_empty help_checker))
|| not (RevList.is_empty help_issue_type)) || not (List.is_empty help_issue_type))
then ( then (
if Config.list_checkers then Help.list_checkers () ; if Config.list_checkers then Help.list_checkers () ;
if Config.list_issue_types then Help.list_issue_types () ; if Config.list_issue_types then Help.list_issue_types () ;
if not (RevList.is_empty Config.help_checker) then if not (List.is_empty Config.help_checker) then Help.show_checkers Config.help_checker ;
Help.show_checkers (RevList.to_list Config.help_checker) ; if not (List.is_empty Config.help_issue_type) then
if not (RevList.is_empty Config.help_issue_type) then Help.show_issue_types Config.help_issue_type ;
Help.show_issue_types (RevList.to_list Config.help_issue_type) ;
Option.iter Config.write_website ~f:(fun website_root -> Help.write_website ~website_root) ; Option.iter Config.write_website ~f:(fun website_root -> Help.write_website ~website_root) ;
() ) () )
else else

@ -97,7 +97,7 @@ module Target = struct
let add_flavor (mode : BuckMode.t) (command : InferCommand.t) ~extra_flavors target = let add_flavor (mode : BuckMode.t) (command : InferCommand.t) ~extra_flavors target =
let target = RevList.fold ~f:add_flavor_internal ~init:target extra_flavors in let target = List.fold_left ~f:add_flavor_internal ~init:target extra_flavors in
match (mode, command) with match (mode, command) with
| ClangCompilationDB _, _ -> | ClangCompilationDB _, _ ->
add_flavor_internal target "compilation-database" add_flavor_internal target "compilation-database"
@ -137,10 +137,10 @@ let config =
| None -> | None ->
[] ) [] )
@ @
if RevList.is_empty Config.buck_blacklist then [] if List.is_empty Config.buck_blacklist then []
else else
[ Printf.sprintf "*//infer.blacklist_regex=(%s)" [ Printf.sprintf "*//infer.blacklist_regex=(%s)"
(String.concat ~sep:")|(" (RevList.to_list Config.buck_blacklist)) ] (String.concat ~sep:")|(" Config.buck_blacklist) ]
in in
fun buck_mode -> fun buck_mode ->
let args = let args =
@ -295,9 +295,7 @@ module Query = struct
let bounded_args = let bounded_args =
store_args_in_file ~identifier:"buck_query_args" (buck_config @ buck_output_options @ [query]) store_args_in_file ~identifier:"buck_query_args" (buck_config @ buck_output_options @ [query])
in in
let cmd = let cmd = "buck" :: "query" :: (Config.buck_build_args_no_inline @ bounded_args) in
"buck" :: "query" :: RevList.rev_append2 Config.buck_build_args_no_inline_rev bounded_args
in
wrap_buck_call ~label:"query" cmd |> parse_query_output ?buck_mode wrap_buck_call ~label:"query" cmd |> parse_query_output ?buck_mode
end end
@ -368,10 +366,10 @@ let config =
| None -> | None ->
[] ) [] )
@ @
if RevList.is_empty Config.buck_blacklist then [] if List.is_empty Config.buck_blacklist then []
else else
[ Printf.sprintf "*//infer.blacklist_regex=(%s)" [ Printf.sprintf "*//infer.blacklist_regex=(%s)"
(String.concat ~sep:")|(" (RevList.to_list Config.buck_blacklist)) ] (String.concat ~sep:")|(" Config.buck_blacklist) ]
in in
fun buck_mode -> fun buck_mode ->
let args = let args =
@ -455,13 +453,10 @@ let parse_command_and_targets (buck_mode : BuckMode.t) original_buck_args =
let expanded_buck_args = inline_argument_files original_buck_args in let expanded_buck_args = inline_argument_files original_buck_args in
let command, args = split_buck_command expanded_buck_args in let command, args = split_buck_command expanded_buck_args in
let buck_targets_blacklist_regexp = let buck_targets_blacklist_regexp =
if RevList.is_empty Config.buck_targets_blacklist then None if List.is_empty Config.buck_targets_blacklist then None
else else
Some Some
(Str.regexp (Str.regexp ("\\(" ^ String.concat ~sep:"\\)\\|\\(" Config.buck_targets_blacklist ^ "\\)"))
( "\\("
^ String.concat ~sep:"\\)\\|\\(" (RevList.to_list Config.buck_targets_blacklist)
^ "\\)" ))
in in
let rec parse_cmd_args parsed_args = function let rec parse_cmd_args parsed_args = function
| [] -> | [] ->

@ -14,7 +14,7 @@ module Target : sig
val to_string : t -> string val to_string : t -> string
val add_flavor : BuckMode.t -> InferCommand.t -> extra_flavors:string RevList.t -> t -> t val add_flavor : BuckMode.t -> InferCommand.t -> extra_flavors:string list -> t -> t
end end
val wrap_buck_call : val wrap_buck_call :

@ -26,8 +26,7 @@ let add_flavors_to_buck_arguments buck_mode ~extra_flavors original_buck_args =
let capture_buck_args () = let capture_buck_args () =
("--show-output" :: (if Config.keep_going then ["--keep-going"] else [])) ("--show-output" :: (if Config.keep_going then ["--keep-going"] else []))
@ (match Config.load_average with Some l -> ["-L"; Float.to_string l] | None -> []) @ (match Config.load_average with Some l -> ["-L"; Float.to_string l] | None -> [])
@ Buck.config ClangFlavors @ Buck.config ClangFlavors @ Config.buck_build_args
@ RevList.to_list Config.buck_build_args
let run_buck_build prog buck_build_args = let run_buck_build prog buck_build_args =
@ -109,15 +108,15 @@ let capture build_cmd =
in in
Unix.putenv ~key:CLOpt.args_env_var ~data:infer_args_with_buck ; Unix.putenv ~key:CLOpt.args_env_var ~data:infer_args_with_buck ;
let {command; rev_not_targets; targets} = let {command; rev_not_targets; targets} =
add_flavors_to_buck_arguments ClangFlavors ~extra_flavors:RevList.empty buck_args add_flavors_to_buck_arguments ClangFlavors ~extra_flavors:[] buck_args
in in
if List.is_empty targets then () if List.is_empty targets then ()
else else
let all_args = List.rev_append rev_not_targets targets in let all_args = List.rev_append rev_not_targets targets in
let updated_buck_cmd = let updated_buck_cmd =
command command
:: RevList.rev_append2 Config.buck_build_args_no_inline_rev :: ( Config.buck_build_args_no_inline
(Buck.store_args_in_file ~identifier:"clang_flavor_build" all_args) @ Buck.store_args_in_file ~identifier:"clang_flavor_build" all_args )
in in
L.debug Capture Quiet "Processed buck command '%a'@\n" (Pp.seq F.pp_print_string) L.debug Capture Quiet "Processed buck command '%a'@\n" (Pp.seq F.pp_print_string)
updated_buck_cmd ; updated_buck_cmd ;

@ -10,7 +10,7 @@ open! IStd
type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list} type flavored_arguments = {command: string; rev_not_targets: string list; targets: string list}
val add_flavors_to_buck_arguments : val add_flavors_to_buck_arguments :
BuckMode.t -> extra_flavors:string RevList.t -> string list -> flavored_arguments BuckMode.t -> extra_flavors:string list -> string list -> flavored_arguments
(** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer. (** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer.
For instance, in clang capture mode, the buck command: build //foo/bar:baz#some,flavor becomes: For instance, in clang capture mode, the buck command: build //foo/bar:baz#some,flavor becomes:
build //foo/bar:baz#infer-capture-all,some,flavor *) build //foo/bar:baz#infer-capture-all,some,flavor *)

@ -170,8 +170,8 @@ let capture buck_mode build_cmd =
let updated_buck_cmd = let updated_buck_cmd =
(* make buck tell us where in buck-out are the capture directories for merging *) (* make buck tell us where in buck-out are the capture directories for merging *)
(prog :: command :: "--build-report" :: build_report_file :: Buck.config buck_mode) (prog :: command :: "--build-report" :: build_report_file :: Buck.config buck_mode)
@ RevList.rev_append2 Config.buck_build_args_no_inline_rev @ Config.buck_build_args_no_inline
(Buck.store_args_in_file ~identifier:"genrule_build" all_args) @ Buck.store_args_in_file ~identifier:"genrule_build" all_args
in in
L.(debug Capture Quiet) L.(debug Capture Quiet)
"Processed buck command '%a'@." (Pp.seq F.pp_print_string) updated_buck_cmd ; "Processed buck command '%a'@." (Pp.seq F.pp_print_string) updated_buck_cmd ;

@ -14,7 +14,7 @@ let capture build_cmd =
L.progress "Querying buck for java flavor capture targets...@." ; L.progress "Querying buck for java flavor capture targets...@." ;
let time0 = Mtime_clock.counter () in let time0 = Mtime_clock.counter () in
let BuckFlavors.{command; rev_not_targets; targets} = let BuckFlavors.{command; rev_not_targets; targets} =
BuckFlavors.add_flavors_to_buck_arguments JavaFlavor ~extra_flavors:RevList.empty buck_cmd BuckFlavors.add_flavors_to_buck_arguments JavaFlavor ~extra_flavors:[] buck_cmd
in in
L.progress "Found %d java flavor capture targets in %a.@." (List.length targets) Mtime.Span.pp L.progress "Found %d java flavor capture targets in %a.@." (List.length targets) Mtime.Span.pp
(Mtime_clock.count time0) ; (Mtime_clock.count time0) ;
@ -25,8 +25,8 @@ let capture build_cmd =
let updated_buck_cmd = let updated_buck_cmd =
(* make buck tell us where in buck-out are the capture directories for merging *) (* make buck tell us where in buck-out are the capture directories for merging *)
(prog :: command :: "--build-report" :: build_report_file :: Buck.config JavaFlavor) (prog :: command :: "--build-report" :: build_report_file :: Buck.config JavaFlavor)
@ RevList.rev_append2 Config.buck_build_args_no_inline_rev @ Config.buck_build_args_no_inline
(Buck.store_args_in_file ~identifier:"java_flavor_build" all_args) @ Buck.store_args_in_file ~identifier:"java_flavor_build" all_args
in in
L.(debug Capture Quiet) L.(debug Capture Quiet)
"Processed buck command '%a'@." (Pp.seq F.pp_print_string) updated_buck_cmd ; "Processed buck command '%a'@." (Pp.seq F.pp_print_string) updated_buck_cmd ;

@ -21,8 +21,7 @@ let create_cmd (source_file, (compilation_data : CompilationDatabase.compilation
( source_file ( source_file
, { CompilationDatabase.directory= compilation_data.directory , { CompilationDatabase.directory= compilation_data.directory
; executable= swap_executable compilation_data.executable ; executable= swap_executable compilation_data.executable
; escaped_arguments= ; escaped_arguments= ["@" ^ arg_file; "-fsyntax-only"] @ Config.clang_extra_flags } )
["@" ^ arg_file; "-fsyntax-only"] @ RevList.to_list Config.clang_extra_flags } )
let invoke_cmd (source_file, (cmd : CompilationDatabase.compilation_data)) = let invoke_cmd (source_file, (cmd : CompilationDatabase.compilation_data)) =
@ -84,8 +83,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args =
| {command= "build" as command; rev_not_targets; targets} -> | {command= "build" as command; rev_not_targets; targets} ->
let targets_args = Buck.store_args_in_file ~identifier:"compdb_build_args" targets in let targets_args = Buck.store_args_in_file ~identifier:"compdb_build_args" targets in
let build_args = let build_args =
command (command :: List.rev_append rev_not_targets Config.buck_build_args_no_inline)
:: List.rev_append rev_not_targets (RevList.to_list Config.buck_build_args_no_inline_rev)
@ (* Infer doesn't support C++ modules nor precompiled headers yet (T35656509) *) @ (* Infer doesn't support C++ modules nor precompiled headers yet (T35656509) *)
"--config" :: "*//cxx.pch_enabled=false" :: "--config" :: "*//cxx.modules_default=false" "--config" :: "*//cxx.pch_enabled=false" :: "--config" :: "*//cxx.modules_default=false"
:: "--config" :: "*//cxx.modules=False" :: targets_args :: "--config" :: "*//cxx.modules=False" :: targets_args
@ -97,7 +95,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args =
prog :: "targets" prog :: "targets"
:: List.rev_append :: List.rev_append
(Buck.filter_compatible `Targets rev_not_targets) (Buck.filter_compatible `Targets rev_not_targets)
(RevList.to_list Config.buck_build_args_no_inline_rev) Config.buck_build_args_no_inline
@ ("--show-output" :: targets_args) @ ("--show-output" :: targets_args)
in in
let on_target_lines = function let on_target_lines = function

@ -372,8 +372,7 @@ let mode_of_build_command build_cmd (buck_mode : BuckMode.t option) =
| BBuck, Some CombinedGenrule -> | BBuck, Some CombinedGenrule ->
BuckCombinedGenrule {build_cmd} BuckCombinedGenrule {build_cmd}
| BBuck, Some (ClangCompilationDB deps) -> | BBuck, Some (ClangCompilationDB deps) ->
BuckCompilationDB BuckCompilationDB {deps; prog; args= List.append args Config.buck_build_args}
{deps; prog; args= List.append args (RevList.to_list Config.buck_build_args)}
| BBuck, Some ClangFlavors when Config.is_checker_enabled Linters -> | BBuck, Some ClangFlavors when Config.is_checker_enabled Linters ->
L.user_warning L.user_warning
"WARNING: the linters require --buck-compilation-database to be set.@ Alternatively, \ "WARNING: the linters require --buck-compilation-database to be set.@ Alternatively, \
@ -427,7 +426,7 @@ let mode_from_command_line =
assert_supported_mode `Java "Buck genrule" ; assert_supported_mode `Java "Buck genrule" ;
BuckGenrule {prog= path} BuckGenrule {prog= path}
| None -> | None ->
mode_of_build_command (RevList.to_list Config.rest) Config.buck_mode ) mode_of_build_command Config.rest Config.buck_mode )
let run_prologue mode = let run_prologue mode =

@ -100,7 +100,7 @@ let censored_reason (issue_type : IssueType.t) source_file =
in in
Option.some_if (not accepted) reason Option.some_if (not accepted) reason
in in
RevList.find_map Config.censor_report ~f:rejected_by List.find_map Config.censor_report ~f:rejected_by
let potential_exception_message = "potential exception at line" let potential_exception_message = "potential exception at line"

@ -27,14 +27,3 @@ let rev_partition_map t ~f =
loop t fst (y :: snd) ) loop t fst (y :: snd) )
in in
loop t [] [] loop t [] []
let rev_concat_map rev ~f =
let rec aux acc = function [] -> acc | hd :: tl -> aux (rev_append (f hd) acc) tl in
aux [] rev
let rev_append2 = rev_append
let rec to_rev_seq rev =
match rev with [] -> fun () -> Seq.Nil | hd :: tl -> fun () -> Seq.Cons (hd, to_rev_seq tl)

@ -10,39 +10,28 @@ open! IStd
type 'a t type 'a t
val empty : 'a t val empty : 'a t
(** Return empty list *)
val is_empty : 'a t -> bool
val cons : 'a -> 'a t -> 'a t val cons : 'a -> 'a t -> 'a t
(** Add an element to the end of list *)
val to_list : 'a t -> 'a list val to_list : 'a t -> 'a list
(** Return normal-ordered list *)
val of_list : 'a list -> 'a t val of_list : 'a list -> 'a t
(** Make reverse-ordered list from normal-ordered one *)
val fold : 'a t -> init:'b -> f:('b -> 'a -> 'b) -> 'b
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool
val exists : 'a t -> f:('a -> bool) -> bool val exists : 'a t -> f:('a -> bool) -> bool
(** Similar to [List.exists] *)
val map : 'a t -> f:('a -> 'b) -> 'b t val map : 'a t -> f:('a -> 'b) -> 'b t
(** Similar to [List.map] *)
val rev_map : 'a t -> f:('a -> 'b) -> 'b list val rev_map : 'a t -> f:('a -> 'b) -> 'b list
(** Similar to [List.rev_map], so return normal-ordered list *)
val rev_map_append : 'a t -> 'b list -> f:('a -> 'b) -> 'b list val rev_map_append : 'a t -> 'b list -> f:('a -> 'b) -> 'b list
(** Similar to [List.rev_map_append] *)
val rev_partition_map : 'a t -> f:('a -> ('b, 'c) Either.t) -> 'b list * 'c list val rev_partition_map : 'a t -> f:('a -> ('b, 'c) Either.t) -> 'b list * 'c list
(** Similar to [List.partition_map], but return normal-ordered lists *)
val find_map : 'a t -> f:('a -> 'b option) -> 'b option
val rev_filter_map : 'a t -> f:('a -> 'b option) -> 'b list
val rev_concat_map : 'a t -> f:('a -> 'b list) -> 'b list
val rev_append : 'a list -> 'a t -> 'a t
val rev_append2 : 'a t -> 'a list -> 'a list
val dedup_and_sort : compare:('a -> 'a -> int) -> 'a t -> 'a list
val to_rev_seq : 'a t -> 'a Seq.t

@ -173,7 +173,7 @@ let search_classes path =
let search_sources () = let search_sources () =
let initial_map = let initial_map =
RevList.fold ~f:(fun map path -> add_source_file path map) ~init:String.Map.empty Config.sources List.fold ~f:(fun map path -> add_source_file path map) ~init:String.Map.empty Config.sources
in in
match Config.sourcepath with match Config.sourcepath with
| None -> | None ->

@ -82,7 +82,7 @@ let do_all_files sources program =
let tenv = load_tenv () in let tenv = load_tenv () in
let skip source_file = let skip source_file =
let is_path_matching path = let is_path_matching path =
RevList.exists List.exists
~f:(fun pattern -> Str.string_match (Str.regexp pattern) path 0) ~f:(fun pattern -> Str.string_match (Str.regexp pattern) path 0)
Config.skip_analysis_in_path Config.skip_analysis_in_path
in in

@ -982,7 +982,7 @@ module ProcNameDispatcher = struct
in in
let get_cpp_matchers config ~model = let get_cpp_matchers config ~model =
let cpp_separator_regex = Str.regexp_string "::" in let cpp_separator_regex = Str.regexp_string "::" in
RevList.rev_filter_map List.filter_map
~f:(fun m -> ~f:(fun m ->
match Str.split cpp_separator_regex m with match Str.split cpp_separator_regex m with
| [] -> | [] ->

@ -77,7 +77,7 @@ include TaintAnalysis.Make (struct
when folly::Subprocess calls exec), in addition some folly functions are heavily optimized in when folly::Subprocess calls exec), in addition some folly functions are heavily optimized in
a way that obscures what they're actually doing (e.g., they use assembly code). it's better a way that obscures what they're actually doing (e.g., they use assembly code). it's better
to write models for these functions or treat them as unknown *) to write models for these functions or treat them as unknown *)
let models_matcher = QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list ["folly"]) let models_matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["folly"]
let get_model pname ret_typ actuals tenv summary = let get_model pname ret_typ actuals tenv summary =
(* hack for default C++ constructors, which get translated as an empty body (and will thus (* hack for default C++ constructors, which get translated as an empty body (and will thus

@ -10,7 +10,7 @@ module F = Format
module L = Logging module L = Logging
let parse_clang_procedure procedure kinds index = let parse_clang_procedure procedure kinds index =
try Some (QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list [procedure]), kinds, index) try Some (QualifiedCppName.Match.of_fuzzy_qual_names [procedure], kinds, index)
with QualifiedCppName.ParseError _ -> with QualifiedCppName.ParseError _ ->
(* Java and Clang sources/sinks live in the same inferconfig entry. If we try to parse a Java (* Java and Clang sources/sinks live in the same inferconfig entry. If we try to parse a Java
procedure that happens to be an invalid Clang qualified name (e.g., MyClass.<init>), procedure that happens to be an invalid Clang qualified name (e.g., MyClass.<init>),
@ -423,8 +423,7 @@ module CppSanitizer = struct
let external_sanitizers = let external_sanitizers =
List.map List.map
~f:(fun {QuandaryConfig.Sanitizer.procedure; kind} -> ~f:(fun {QuandaryConfig.Sanitizer.procedure; kind} ->
(QualifiedCppName.Match.of_fuzzy_qual_names (RevList.of_list [procedure]), of_string kind) (QualifiedCppName.Match.of_fuzzy_qual_names [procedure], of_string kind) )
)
(QuandaryConfig.Sanitizer.of_json Config.quandary_sanitizers) (QuandaryConfig.Sanitizer.of_json Config.quandary_sanitizers)

@ -23,7 +23,7 @@ let parse topl_file =
with Sys_error msg -> L.die UserError "@[topl:%s: %s@]@\n@?" topl_file msg with Sys_error msg -> L.die UserError "@[topl:%s: %s@]@\n@?" topl_file msg
let properties = lazy (RevList.rev_concat_map ~f:parse Config.topl_properties) let properties = lazy (List.concat_map ~f:parse Config.topl_properties)
let automaton = lazy (ToplAutomaton.make (Lazy.force properties)) let automaton = lazy (ToplAutomaton.make (Lazy.force properties))

Loading…
Cancel
Save