From 9a06a859e216b55494ca90ba9415778bff709023 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Feb 2017 01:33:26 -0800 Subject: [PATCH] Deprecate IList part 3. Reviewed By: jberdine Differential Revision: D4597907 fbshipit-source-id: 4c888a5 --- infer/src/IR/Cfg.re | 10 +-- infer/src/IR/Cg.re | 2 +- infer/src/IR/Io_infer.ml | 8 +- infer/src/IR/Procdesc.re | 6 +- infer/src/IR/Procname.re | 6 +- infer/src/IR/Sil.re | 12 +-- infer/src/IR/StructTyp.re | 2 +- infer/src/IR/Subtype.re | 2 +- infer/src/backend/Attribute.ml | 4 +- infer/src/backend/BuiltinDefn.ml | 6 +- infer/src/backend/InferPrint.re | 16 ++-- infer/src/backend/PerfStats.ml | 2 +- infer/src/backend/abs.ml | 28 +++---- infer/src/backend/absarray.ml | 8 +- infer/src/backend/builtin.ml | 2 +- infer/src/backend/dom.ml | 46 +++++------ infer/src/backend/dotty.ml | 6 +- infer/src/backend/errdesc.ml | 10 +-- infer/src/backend/infer.ml | 8 +- infer/src/backend/inferconfig.ml | 2 +- infer/src/backend/interproc.ml | 6 +- infer/src/backend/match.ml | 12 +-- infer/src/backend/paths.ml | 11 +-- infer/src/backend/preanal.ml | 10 +-- infer/src/backend/printer.ml | 6 +- infer/src/backend/prop.ml | 76 +++++++++---------- infer/src/backend/propgraph.ml | 2 +- infer/src/backend/propset.ml | 4 +- infer/src/backend/prover.ml | 41 +++++----- infer/src/backend/rearrange.ml | 33 ++++---- infer/src/backend/specs.ml | 4 +- infer/src/backend/state.ml | 2 +- infer/src/backend/symExec.ml | 14 ++-- infer/src/backend/tabulation.ml | 24 +++--- infer/src/base/CommandLineOption.ml | 16 ++-- infer/src/base/Config.ml | 20 ++--- infer/src/base/DB.ml | 6 +- infer/src/base/IList.ml | 72 +++--------------- infer/src/base/IList.mli | 33 -------- infer/src/base/PrettyPrintable.ml | 2 +- infer/src/base/Utils.ml | 2 +- infer/src/checkers/SiofDomain.ml | 2 +- infer/src/checkers/SiofTrace.ml | 4 +- infer/src/checkers/ThreadSafety.ml | 2 +- infer/src/checkers/Trace.ml | 14 ++-- infer/src/checkers/annotationReachability.ml | 4 +- infer/src/checkers/checkers.ml | 2 +- infer/src/checkers/patternMatch.ml | 4 +- infer/src/checkers/procCfg.ml | 12 +-- infer/src/clang/ClangCommand.re | 10 +-- infer/src/clang/ClangWrapper.re | 2 +- infer/src/clang/ComponentKit.ml | 4 +- infer/src/clang/cEnum_decl.ml | 2 +- infer/src/clang/cFrontend_decl.ml | 2 +- infer/src/clang/cGeneral_utils.ml | 2 +- infer/src/clang/cMethod_trans.ml | 4 +- infer/src/clang/cTL.ml | 4 +- infer/src/clang/cTrans.ml | 23 +++--- infer/src/clang/cTrans_utils.ml | 12 +-- infer/src/eradicate/AnnotatedSignature.ml | 2 +- infer/src/eradicate/eradicate.ml | 4 +- infer/src/eradicate/eradicateChecks.ml | 2 +- infer/src/eradicate/models.ml | 2 +- infer/src/eradicate/typeCheck.ml | 8 +- infer/src/harness/inhabit.ml | 4 +- .../integration/CaptureCompilationDatabase.ml | 2 +- infer/src/java/jClasspath.ml | 2 +- infer/src/java/jTrans.ml | 6 +- infer/src/java/jTransExn.ml | 2 +- infer/src/unit/TaintTests.ml | 2 +- infer/src/unit/analyzerTester.ml | 2 +- .../src/unit/clang/CiOSVersionNumbersTests.ml | 2 +- infer/src/unit/procCfgTests.ml | 2 +- infer/src/unit/schedulerTests.ml | 2 +- 74 files changed, 325 insertions(+), 410 deletions(-) diff --git a/infer/src/IR/Cfg.re b/infer/src/IR/Cfg.re index f7ac82a9f..6df00c230 100644 --- a/infer/src/IR/Cfg.re +++ b/infer/src/IR/Cfg.re @@ -58,7 +58,7 @@ let iter_all_nodes sorted::sorted=false f cfg => { ) cfg.proc_desc_table [] |> - IList.sort [%compare : (Procdesc.t, Procdesc.Node.t)] |> + List.sort cmp::[%compare : (Procdesc.t, Procdesc.Node.t)] |> List.iter f::(fun (d, n) => f d n) } }; @@ -191,9 +191,9 @@ let inline_synthetic_method ret_id etl pdesc loc_call :option Sil.instr => { Bool.equal (is_none ret_id) (is_none ret_id') && Int.equal (List.length etl' + 1) (List.length etl) => let etl1 = - switch (IList.rev etl) { + switch (List.rev etl) { /* remove last element */ - | [_, ...l] => IList.rev l + | [_, ...l] => List.rev l | [] => assert false }; let instr' = Sil.Call ret_id (Exp.Const (Const.Cfun pn)) etl1 loc_call cf; @@ -434,7 +434,7 @@ let specialize_types_proc callee_pdesc resolved_pdesc substitutions => { let rec convert_node node => { let loc = Procdesc.Node.get_loc node and kind = convert_node_kind (Procdesc.Node.get_kind node) - and instrs = List.fold f::convert_instr init::[] (Procdesc.Node.get_instrs node) |> IList.rev; + and instrs = List.fold f::convert_instr init::[] (Procdesc.Node.get_instrs node) |> List.rev; Procdesc.create_node resolved_pdesc loc kind instrs } and loop callee_nodes => @@ -486,7 +486,7 @@ let specialize_types callee_pdesc resolved_pname args => { args; let resolved_attributes = { ...callee_attributes, - formals: IList.rev resolved_params, + formals: List.rev resolved_params, proc_name: resolved_pname }; AttributesTable.store_attributes resolved_attributes; diff --git a/infer/src/IR/Cg.re b/infer/src/IR/Cg.re index 92002aee0..0e4a15a5e 100644 --- a/infer/src/IR/Cg.re +++ b/infer/src/IR/Cg.re @@ -190,7 +190,7 @@ let node_map_iter f g => { let table = ref []; Procname.Hash.iter (fun node info => table := [(node, info), ...!table]) g.node_map; let cmp (n1: Procname.t, _) (n2: Procname.t, _) => Procname.compare n1 n2; - List.iter f::(fun (n, info) => f n info) (IList.sort cmp !table) + List.iter f::(fun (n, info) => f n info) (List.sort cmp::cmp !table) }; let get_nodes (g: t) => { diff --git a/infer/src/IR/Io_infer.ml b/infer/src/IR/Io_infer.ml index 140087230..a4c91cbc7 100644 --- a/infer/src/IR/Io_infer.ml +++ b/infer/src/IR/Io_infer.ml @@ -19,9 +19,9 @@ module Html = struct (** Create a new html file *) let create pk path = - let fname, dir_path = match IList.rev path with + let fname, dir_path = match List.rev path with | fname :: path_rev -> - fname, IList.rev ((fname ^ ".html") :: path_rev) + fname, List.rev ((fname ^ ".html") :: path_rev) | [] -> raise (Failure "Html.create") in let fd = DB.Results_dir.create_file pk dir_path in @@ -127,9 +127,9 @@ struct (** Get the full html filename from a path *) let get_full_fname source path = - let dir_path = match IList.rev path with + let dir_path = match List.rev path with | fname :: path_rev -> - IList.rev ((fname ^ ".html") :: path_rev) + List.rev ((fname ^ ".html") :: path_rev) | [] -> raise (Failure "Html.open_out") in DB.Results_dir.path_to_filename (DB.Results_dir.Abs_source_dir source) dir_path diff --git a/infer/src/IR/Procdesc.re b/infer/src/IR/Procdesc.re index cf27ec5dc..72d02ced1 100644 --- a/infer/src/IR/Procdesc.re +++ b/infer/src/IR/Procdesc.re @@ -166,7 +166,7 @@ let module Node = { /** Get the source location of the last instruction in the node */ let get_last_loc n => - switch (IList.rev (get_instrs n)) { + switch (List.rev (get_instrs n)) { | [instr, ..._] => Sil.instr_get_loc instr | [] => n.loc }; @@ -395,7 +395,7 @@ let is_body_empty pdesc => List.is_empty (Node.get_succs (get_start_node pdesc)) let is_java_synchronized pdesc => pdesc.attributes.is_java_synchronized_method; -let iter_nodes f pdesc => List.iter f::f (IList.rev (get_nodes pdesc)); +let iter_nodes f pdesc => List.iter f::f (List.rev (get_nodes pdesc)); let fold_calls f acc pdesc => { let do_node a node => @@ -415,7 +415,7 @@ let iter_instrs f pdesc => { iter_nodes do_node pdesc }; -let fold_nodes f acc pdesc => List.fold f::f init::acc (IList.rev (get_nodes pdesc)); +let fold_nodes f acc pdesc => List.fold f::f init::acc (List.rev (get_nodes pdesc)); let fold_instrs f acc pdesc => { let fold_node acc node => diff --git a/infer/src/IR/Procname.re b/infer/src/IR/Procname.re index 51ca72e32..03c669a5e 100644 --- a/infer/src/IR/Procname.re +++ b/infer/src/IR/Procname.re @@ -343,10 +343,10 @@ let java_is_anonymous_inner_class = let java_remove_hidden_inner_class_parameter = fun | Java js => - switch (IList.rev js.parameters) { + switch (List.rev js.parameters) { | [(_, s), ...par'] => if (is_anonymous_inner_class_name s) { - Some (Java {...js, parameters: IList.rev par'}) + Some (Java {...js, parameters: List.rev par'}) } else { None } @@ -397,7 +397,7 @@ let java_is_autogen_method = let java_is_vararg = fun | Java js => - switch (IList.rev js.parameters) { + switch (List.rev js.parameters) { | [(_, "java.lang.Object[]"), ..._] => true | _ => false } diff --git a/infer/src/IR/Sil.re b/infer/src/IR/Sil.re index 34bfc0a3a..3a5746e46 100644 --- a/infer/src/IR/Sil.re +++ b/infer/src/IR/Sil.re @@ -1256,7 +1256,7 @@ let atom_fpv = | Aeq e1 e2 => exp_fpv e1 @ exp_fpv e2 | Aneq e1 e2 => exp_fpv e1 @ exp_fpv e2 | Apred _ es - | Anpred _ es => List.fold f::(fun fpv e => IList.rev_append (exp_fpv e) fpv) init::[] es; + | Anpred _ es => List.fold f::(fun fpv e => List.rev_append (exp_fpv e) fpv) init::[] es; let rec strexp_fpv = fun @@ -1374,7 +1374,7 @@ let rec remove_duplicates_from_sorted special_equal => /** Convert a [fav] to a list of identifiers while preserving the order that the identifiers were added to [fav]. */ -let fav_to_list fav => IList.rev !fav; +let fav_to_list fav => List.rev !fav; /** Pretty print a fav. */ @@ -1657,7 +1657,7 @@ let sub_check_duplicated_ids sub => { For all (id1, e1), (id2, e2) in the input list, if id1 = id2, then e1 = e2. */ let sub_of_list sub => { - let sub' = IList.sort compare_ident_exp sub; + let sub' = List.sort cmp::compare_ident_exp sub; let sub'' = remove_duplicates_from_sorted equal_ident_exp sub'; if (sub_check_duplicated_ids sub'') { assert false @@ -1668,7 +1668,7 @@ let sub_of_list sub => { /** like sub_of_list, but allow duplicate ids and only keep the first occurrence */ let sub_of_list_duplicates sub => { - let sub' = IList.sort compare_ident_exp sub; + let sub' = List.sort cmp::compare_ident_exp sub; let rec remove_duplicate_ids = fun | [(id1, e1), (id2, e2), ...l] => @@ -1748,12 +1748,12 @@ let sub_filter_pair = List.filter; /** [sub_range_partition filter sub] partitions [sub] according to whether range expressions satisfy [filter]. */ -let sub_range_partition filter (sub: subst) => IList.partition (fun (_, e) => filter e) sub; +let sub_range_partition filter (sub: subst) => List.partition_tf f::(fun (_, e) => filter e) sub; /** [sub_domain_partition filter sub] partitions [sub] according to whether domain identifiers satisfy [filter]. */ -let sub_domain_partition filter (sub: subst) => IList.partition (fun (i, _) => filter i) sub; +let sub_domain_partition filter (sub: subst) => List.partition_tf f::(fun (i, _) => filter i) sub; /** Return the list of identifiers in the domain of the substitution. */ diff --git a/infer/src/IR/StructTyp.re b/infer/src/IR/StructTyp.re index 4a3194b1b..627cc476f 100644 --- a/infer/src/IR/StructTyp.re +++ b/infer/src/IR/StructTyp.re @@ -95,7 +95,7 @@ let rec get_extensible_array_element_typ lookup::lookup (typ: Typ.t) => | Tstruct name => switch (lookup name) { | Some {fields} => - switch (IList.last fields) { + switch (List.last fields) { | Some (_, fld_typ, _) => get_extensible_array_element_typ lookup::lookup fld_typ | None => None } diff --git a/infer/src/IR/Subtype.re b/infer/src/IR/Subtype.re index e225d454b..afd4ab71b 100644 --- a/infer/src/IR/Subtype.re +++ b/infer/src/IR/Subtype.re @@ -205,7 +205,7 @@ let normalize_subtypes t_opt c1 c2 flag1 flag2 => { | Some t => switch t { | Exact => Some (t, new_flag) - | Subtypes l => Some (Subtypes (IList.sort Typename.compare l), new_flag) + | Subtypes l => Some (Subtypes (List.sort cmp::Typename.compare l), new_flag) } | None => None } diff --git a/infer/src/backend/Attribute.ml b/infer/src/backend/Attribute.ml index 8ccbb48ee..be294545a 100644 --- a/infer/src/backend/Attribute.ml +++ b/infer/src/backend/Attribute.ml @@ -65,7 +65,7 @@ let get_all (prop: 'a Prop.t) = let res = ref [] in let do_atom a = if is_pred a then res := a :: !res in List.iter ~f:do_atom prop.pi; - IList.rev !res + List.rev !res (** Get all the attributes of the prop *) let get_for_symb prop att = @@ -263,7 +263,7 @@ let deallocate_stack_vars tenv (p: 'a Prop.t) pvars = | Sil.Hpointsto (Exp.Lvar v, _, _) -> List.exists ~f:(Pvar.equal v) pvars | _ -> false in - let sigma_stack, sigma_other = IList.partition filter p.sigma in + let sigma_stack, sigma_other = List.partition_tf ~f:filter p.sigma in let fresh_address_vars = ref [] in (* fresh vars substituted for the address of stack vars *) let stack_vars_address_in_post = ref [] in (* stack vars whose address is still present *) let exp_replace = List.map ~f:(function diff --git a/infer/src/backend/BuiltinDefn.ml b/infer/src/backend/BuiltinDefn.ml index 649e5cdc3..a07559ba8 100644 --- a/infer/src/backend/BuiltinDefn.ml +++ b/infer/src/backend/BuiltinDefn.ml @@ -116,7 +116,7 @@ let execute___set_array_length { Builtin.tenv; pdesc; prop_; path; ret_id; args; let pname = Procdesc.get_proc_name pdesc in let n_lexp, prop__ = check_arith_norm_exp tenv pname lexp prop_a in let n_len, prop = check_arith_norm_exp tenv pname len prop__ in - let hpred, sigma' = IList.partition (function + let hpred, sigma' = List.partition_tf ~f:(function | Sil.Hpointsto(e, _, _) -> Exp.equal e n_lexp | _ -> false) prop.Prop.sigma in (match hpred with @@ -216,7 +216,7 @@ let execute___get_type_of { Builtin.pdesc; tenv; prop_; path; ret_id; args; } let replace_ptsto_texp tenv prop root_e texp = let process_sigma sigma = let sigma1, sigma2 = - IList.partition (function + List.partition_tf ~f:(function | Sil.Hpointsto(e, _, _) -> Exp.equal e root_e | _ -> false) sigma in match sigma1 with @@ -705,7 +705,7 @@ let _execute_free_nonzero mk pdesc tenv instr prop lexp typ loc = let prop_list = List.fold ~f:(_execute_free tenv mk loc) ~init:[] (Rearrange.rearrange pdesc tenv lexp typ prop loc) in - IList.rev prop_list + List.rev prop_list end with Rearrange.ARRAY_ACCESS -> if (Int.equal Config.array_level 0) then assert false diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index 0418bf469..126d36045 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -113,7 +113,7 @@ let loc_trace_to_jsonbug_record trace_list ekind => description: trace_item.Errlog.lt_description, node_tags: node_tags_to_records trace_item.Errlog.lt_node_tags }; - let record_list = IList.rev (List.rev_map f::trace_item_to_record trace_list); + let record_list = List.rev (List.rev_map f::trace_item_to_record trace_list); record_list }; @@ -630,7 +630,7 @@ let module IssuesXml = { node_tags_to_xml lt.Errlog.lt_node_tags ] }; - IList.rev (List.rev_map f::loc_to_xml ltr) + List.rev (List.rev_map f::loc_to_xml ltr) }; /** print issues from summary in xml */ @@ -772,7 +772,7 @@ let module Stats = { res := [line, "", ...!res] }; List.iter f::loc_to_string ltr; - IList.rev !res + List.rev !res }; let process_err_log error_filter linereader err_log stats => { let found_errors = ref false; @@ -791,7 +791,7 @@ let module Stats = { [F.asprintf "%t" pp1, F.asprintf "%t" pp2, F.asprintf "%t" pp3] }; let trace = loc_trace_to_string_list linereader 1 ltr; - stats.saved_errors = IList.rev_append (error_strs @ trace @ [""]) stats.saved_errors + stats.saved_errors = List.rev_append (error_strs @ trace @ [""]) stats.saved_errors | Exceptions.Kwarning => stats.nwarnings = stats.nwarnings + 1 | Exceptions.Kinfo => stats.ninfos = stats.ninfos + 1 | Exceptions.Kadvice => stats.nadvice = stats.nadvice + 1 @@ -845,7 +845,7 @@ let module Stats = { F.fprintf fmt "Infos: %d@\n" stats.ninfos; F.fprintf fmt "@\n -------------------@\n"; F.fprintf fmt "@\nDetailed Errors@\n@\n"; - List.iter f::(fun s => F.fprintf fmt "%s@\n" s) (IList.rev stats.saved_errors) + List.iter f::(fun s => F.fprintf fmt "%s@\n" s) (List.rev stats.saved_errors) }; }; @@ -1124,7 +1124,7 @@ let pp_json_report_by_report_kind formats_by_report_kind fname => }; let sorted_report = { let report = Jsonbug_j.report_of_string (String.concat sep::"\n" report_lines); - IList.sort tests_jsonbug_compare report + List.sort cmp::tests_jsonbug_compare report }; let pp_report_by_report_kind (report_kind, format_list) => switch (report_kind, format_list) { @@ -1229,12 +1229,12 @@ let module AnalysisResults = { summ2.Specs.attributes.ProcAttributes.loc.Location.line } }; - IList.sort summ_cmp !summaries + List.sort cmp::summ_cmp !summaries }; /** Create an iterator which loads spec files one at a time */ let iterator_of_spec_files () => { - let sorted_spec_files = IList.sort String.compare (spec_files_from_cmdline ()); + let sorted_spec_files = List.sort cmp::String.compare (spec_files_from_cmdline ()); let do_spec f fname => switch (Specs.load_summary (DB.filename_from_string fname)) { | None => diff --git a/infer/src/backend/PerfStats.ml b/infer/src/backend/PerfStats.ml index 6fbc33437..e7e7a095d 100644 --- a/infer/src/backend/PerfStats.ml +++ b/infer/src/backend/PerfStats.ml @@ -73,7 +73,7 @@ let from_json json = } let aggregate s = - let mk_stats f = StatisticsToolbox.compute_statistics (List.map ~f:f s) in + let mk_stats f = StatisticsToolbox.compute_statistics (List.map ~f s) in let aggr_rtime = mk_stats (fun stats -> stats.rtime) in let aggr_utime = mk_stats (fun stats -> stats.utime) in let aggr_stime = mk_stats (fun stats -> stats.stime) in diff --git a/infer/src/backend/abs.ml b/infer/src/backend/abs.ml index 13e004a75..ccda69a31 100644 --- a/infer/src/backend/abs.ml +++ b/infer/src/backend/abs.ml @@ -242,7 +242,7 @@ let mk_rule_ptspts_dll tenv impl_ok1 impl_ok2 para = let ids_shared = let svars = para.Sil.svars_dll in let f _ = Ident.create_fresh Ident.kprimed in - List.map ~f:f svars in + List.map ~f svars in let exp_iF = Exp.Var id_iF in let exp_iF' = Exp.Var id_iF' in let exp_oB = Exp.Var id_oB in @@ -290,7 +290,7 @@ let mk_rule_ptsdll_dll tenv k2 impl_ok1 impl_ok2 para = let ids_shared = let svars = para.Sil.svars_dll in let f _ = Ident.create_fresh Ident.kprimed in - List.map ~f:f svars in + List.map ~f svars in let exp_iF = Exp.Var id_iF in let exp_iF' = Exp.Var id_iF' in let exp_oB = Exp.Var id_oB in @@ -326,7 +326,7 @@ let mk_rule_dllpts_dll tenv k1 impl_ok1 impl_ok2 para = let ids_shared = let svars = para.Sil.svars_dll in let f _ = Ident.create_fresh Ident.kprimed in - List.map ~f:f svars in + List.map ~f svars in let exp_iF = Exp.Var id_iF in let exp_iF' = Exp.Var id_iF' in let exp_oB = Exp.Var id_oB in @@ -360,7 +360,7 @@ let mk_rule_dlldll_dll tenv k1 k2 impl_ok1 impl_ok2 para = let ids_shared = let svars = para.Sil.svars_dll in let f _ = Ident.create_fresh Ident.kprimed in - List.map ~f:f svars in + List.map ~f svars in let exp_iF = Exp.Var id_iF in let exp_iF' = Exp.Var id_iF' in let exp_oB = Exp.Var id_oB in @@ -488,9 +488,9 @@ let discover_para_candidates tenv p = get_edges_strexp rec_flds root se; get_edges_sigma sigma_rest in let rec find_all_consecutive_edges found edges_seen = function - | [] -> IList.rev found + | [] -> List.rev found | (e1, e2) :: edges_notseen -> - let edges_others = (IList.rev edges_seen) @ edges_notseen in + let edges_others = List.rev_append edges_seen edges_notseen in let edges_matched = List.filter ~f:(fun (e1', _) -> Exp.equal e2 e1') edges_others in let new_found = let f found_acc (_, e3) = (e1, e2, e3) :: found_acc in @@ -509,12 +509,12 @@ let discover_para_dll_candidates tenv p = match se with | Sil.Eexp _ | Sil.Earray _ -> () | Sil.Estruct (fsel, _) -> - let fsel' = List.filter ~f:(fun (fld, _) -> is_rec_fld fld) fsel in + let fsel' = List.rev_filter ~f:(fun (fld, _) -> is_rec_fld fld) fsel in let convert_to_exp acc (_, se) = match se with | Sil.Eexp (e, _) -> e:: acc | _ -> assert false in - let links = IList.rev (List.fold ~f:convert_to_exp ~init:[] fsel') in + let links = List.fold ~f:convert_to_exp ~init:[] fsel' in let rec iter_pairs = function | [] -> () | x:: l -> (List.iter ~f:(fun y -> add_edge (root, x, y)) l; iter_pairs l) in @@ -528,9 +528,9 @@ let discover_para_dll_candidates tenv p = get_edges_strexp rec_flds root se; get_edges_sigma sigma_rest in let rec find_all_consecutive_edges found edges_seen = function - | [] -> IList.rev found + | [] -> List.rev found | (iF, blink, flink) :: edges_notseen -> - let edges_others = (IList.rev edges_seen) @ edges_notseen in + let edges_others = List.rev_append edges_seen edges_notseen in let edges_matched = List.filter ~f:(fun (e1', _, _) -> Exp.equal flink e1') edges_others in let new_found = let f found_acc (_, _, flink2) = (iF, blink, flink, flink2) :: found_acc in @@ -635,7 +635,7 @@ let eqs_solve ids_in eqs_in = let sigma_special_cases_eqs sigma = let rec f ids_acc eqs_acc sigma_acc = function | [] -> - [(IList.rev ids_acc, IList.rev eqs_acc, IList.rev sigma_acc)] + [(List.rev ids_acc, List.rev eqs_acc, List.rev sigma_acc)] | Sil.Hpointsto _ as hpred :: sigma_rest -> f ids_acc eqs_acc (hpred:: sigma_acc) sigma_rest | Sil.Hlseg(_, para, e1, e2, es) as hpred :: sigma_rest -> @@ -668,7 +668,7 @@ let sigma_special_cases ids sigma : (Ident.t list * Sil.hpred list) list = | Some (ids_res, sub) -> (ids_res, List.map ~f:(Sil.hpred_sub sub) sigma_cur) :: acc in List.fold ~f ~init:[] special_cases_eqs in - IList.rev special_cases_rev + List.rev special_cases_rev let hpara_special_cases hpara : Sil.hpara list = let update_para (evars', body') = { hpara with Sil.evars = evars'; Sil.body = body'} in @@ -780,7 +780,7 @@ let abstract_pure_part tenv p ~(from_abstract_footprint: bool) = | Sil.Aeq _ | Aneq _ | Apred _ | Anpred _ -> pi ) ~init:[] pi_filtered in - IList.rev new_pure in + List.rev new_pure in let new_pure = do_pure (Prop.get_pure p) in let eprop' = Prop.set p ~pi:new_pure ~sub:Sil.sub_empty in @@ -1072,7 +1072,7 @@ let check_junk ?original_prop pname tenv prop = hpred_is_loop || List.exists ~f:predicate entries in let rec remove_junk_recursive sigma_done sigma_todo = match sigma_todo with - | [] -> IList.rev sigma_done + | [] -> List.rev sigma_done | hpred :: sigma_todo' -> let entries = hpred_entries hpred in if should_remove_hpred entries then diff --git a/infer/src/backend/absarray.ml b/infer/src/backend/absarray.ml index 74298c022..167ba6f59 100644 --- a/infer/src/backend/absarray.ml +++ b/infer/src/backend/absarray.ml @@ -159,7 +159,7 @@ end = struct let find tenv (sigma : sigma) (pred : strexp_data -> bool) : t list = let found = ref [] in let rec find_offset_sexp sigma_other hpred root offs se (typ: Typ.t) = - let offs' = IList.rev offs in + let offs' = List.rev offs in let path = (root, offs') in if pred (path, se, typ) then found := (sigma, hpred, offs') :: !found else begin @@ -429,7 +429,7 @@ let keep_only_indices tenv match se with | Sil.Earray (len, esel, inst) -> let esel', esel_leftover' = - IList.partition (fun (e, _) -> List.exists ~f:(Exp.equal e) indices) esel in + List.partition_tf ~f:(fun (e, _) -> List.exists ~f:(Exp.equal e) indices) esel in if List.is_empty esel_leftover' then (sigma, false) else begin let se' = Sil.Earray (len, esel', inst) in @@ -479,7 +479,7 @@ let strexp_do_abstract tenv prune_and_blur Sil.d_exp_list (keep_only_indices tenv) (blur_array_indices tenv) in let partition_abstract should_keep abstract ksel default_keys = - let keep_ksel, remove_ksel = IList.partition should_keep ksel in + let keep_ksel, remove_ksel = List.partition_tf ~f:should_keep ksel in let keep_keys, _, _ = List.map ~f:fst keep_ksel, List.map ~f:fst remove_ksel, List.map ~f:fst ksel in let keep_keys' = if List.is_empty keep_keys then default_keys else keep_keys in @@ -491,7 +491,7 @@ let strexp_do_abstract tenv let default_indices = match List.map ~f:fst esel with | [] -> [] - | indices -> [List.hd_exn (IList.rev indices)] (* keep last key at least *) in + | indices -> [List.last_exn indices] (* keep last key at least *) in partition_abstract should_keep abstract esel default_indices in let do_footprint () = match se_in with diff --git a/infer/src/backend/builtin.ml b/infer/src/backend/builtin.ml index df770783d..92bfe46fa 100644 --- a/infer/src/backend/builtin.ml +++ b/infer/src/backend/builtin.ml @@ -55,7 +55,7 @@ let register proc_name sym_exe_fun : registered = let pp_registered fmt () = let builtin_names = ref [] in Procname.Hash.iter (fun name _ -> builtin_names := name :: !builtin_names) builtin_functions; - builtin_names := IList.sort Procname.compare !builtin_names; + builtin_names := List.sort ~cmp:Procname.compare !builtin_names; let pp pname = Format.fprintf fmt "%a@\n" Procname.pp pname in Format.fprintf fmt "Registered builtins:@\n @["; List.iter ~f:pp !builtin_names; diff --git a/infer/src/backend/dom.ml b/infer/src/backend/dom.ml index 3a10bf457..68d68feef 100644 --- a/infer/src/backend/dom.ml +++ b/infer/src/backend/dom.ml @@ -35,15 +35,15 @@ let equal_sigma sigma1 sigma2 = | hpred1:: sigma1_rest', hpred2:: sigma2_rest' -> if Sil.equal_hpred hpred1 hpred2 then f sigma1_rest' sigma2_rest' else (L.d_strln "failure reason 2"; raise Sil.JoinFail) in - let sigma1_sorted = IList.sort Sil.compare_hpred sigma1 in - let sigma2_sorted = IList.sort Sil.compare_hpred sigma2 in + let sigma1_sorted = List.sort ~cmp:Sil.compare_hpred sigma1 in + let sigma2_sorted = List.sort ~cmp:Sil.compare_hpred sigma2 in f sigma1_sorted sigma2_sorted let sigma_get_start_lexps_sort sigma = let exp_compare_neg e1 e2 = - (Exp.compare e1 e2) in let filter e = Sil.fav_for_all (Sil.exp_fav e) Ident.is_normal in let lexps = Sil.hpred_list_get_lexps filter sigma in - IList.sort exp_compare_neg lexps + List.sort ~cmp:exp_compare_neg lexps (** {2 Utility functions for side} *) @@ -172,7 +172,7 @@ end = struct let check side es = let f = function Exp.Var id -> can_rename id | _ -> false in - let vars, nonvars = IList.partition f es in + let vars, nonvars = List.partition_tf ~f es in let tbl, const_tbl = match side with | Lhs -> equiv_tbl1, const_tbl1 @@ -469,7 +469,7 @@ end = struct let minus2_to_2 = List.map ~f:IntLit.of_int [-2; -1; 0; 1; 2] let get_induced_pi tenv () = - let t_sorted = IList.sort entry_compare !t in + let t_sorted = List.sort ~cmp:entry_compare !t in let add_and_chk_eq e1 e1' n = match e1, e1' with @@ -599,8 +599,8 @@ end = struct res := v'::!res | _ -> () in begin - List.iter ~f:f !tbl; - IList.rev !res + List.iter ~f !tbl; + List.rev !res end (* Return the triple whose side is [e], if it exists unique *) @@ -629,7 +629,7 @@ end = struct ~f:(function (e1, e2, Exp.Var i) -> (i, select side e1 e2) | _ -> assert false) renaming_restricted in let sub_list_side_sorted = - IList.sort (fun (_, e) (_, e') -> Exp.compare e e') sub_list_side in + List.sort ~cmp:(fun (_, e) (_, e') -> Exp.compare e e') sub_list_side in let rec find_duplicates = function | (_, e):: ((_, e'):: _ as t) -> Exp.equal e e' || find_duplicates t @@ -652,7 +652,7 @@ end = struct List.map ~f:project renaming_restricted in let sub_list_sorted = let compare (i, _) (i', _) = Ident.compare i i' in - IList.sort compare sub_list in + List.sort ~cmp:compare sub_list in let rec find_duplicates = function | (i, _):: ((i', _):: _ as t) -> Ident.equal i i' || find_duplicates t | _ -> false in @@ -1055,12 +1055,12 @@ let rec strexp_partial_join mode (strexp1: Sil.strexp) (strexp2: Sil.strexp) : S let rec f_fld_se_list inst mode acc fld_se_list1 fld_se_list2 = match fld_se_list1, fld_se_list2 with - | [], [] -> Sil.Estruct (IList.rev acc, inst) + | [], [] -> Sil.Estruct (List.rev acc, inst) | [], _ | _, [] -> begin match mode with | JoinState.Pre -> (L.d_strln "failure reason 42"; raise Sil.JoinFail) - | JoinState.Post -> Sil.Estruct (IList.rev acc, inst) + | JoinState.Post -> Sil.Estruct (List.rev acc, inst) end | (fld1, se1):: fld_se_list1', (fld2, se2):: fld_se_list2' -> let comparison = Ident.compare_fieldname fld1 fld2 in @@ -1085,13 +1085,13 @@ let rec strexp_partial_join mode (strexp1: Sil.strexp) (strexp2: Sil.strexp) : S let rec f_idx_se_list inst len idx_se_list_acc idx_se_list1 idx_se_list2 = match idx_se_list1, idx_se_list2 with - | [], [] -> Sil.Earray (len, IList.rev idx_se_list_acc, inst) + | [], [] -> Sil.Earray (len, List.rev idx_se_list_acc, inst) | [], _ | _, [] -> begin match mode with | JoinState.Pre -> (L.d_strln "failure reason 44"; raise Sil.JoinFail) | JoinState.Post -> - Sil.Earray (len, IList.rev idx_se_list_acc, inst) + Sil.Earray (len, List.rev idx_se_list_acc, inst) end | (idx1, se1):: idx_se_list1', (idx2, se2):: idx_se_list2' -> let idx = exp_partial_join idx1 idx2 in @@ -1116,12 +1116,12 @@ let rec strexp_partial_meet (strexp1: Sil.strexp) (strexp2: Sil.strexp) : Sil.st let construct side rev_list ref_list = let construct_offset_se (off, se) = (off, strexp_construct_fresh side se) in let acc = List.map ~f:construct_offset_se ref_list in - IList.rev_append rev_list acc in + List.rev_append rev_list acc in let rec f_fld_se_list inst acc fld_se_list1 fld_se_list2 = match fld_se_list1, fld_se_list2 with | [], [] -> - Sil.Estruct (IList.rev acc, inst) + Sil.Estruct (List.rev acc, inst) | [], _ -> Sil.Estruct (construct Rhs acc fld_se_list2, inst) | _, [] -> @@ -1144,7 +1144,7 @@ let rec strexp_partial_meet (strexp1: Sil.strexp) (strexp2: Sil.strexp) : Sil.st let rec f_idx_se_list inst len acc idx_se_list1 idx_se_list2 = match idx_se_list1, idx_se_list2 with | [],[] -> - Sil.Earray (len, IList.rev acc, inst) + Sil.Earray (len, List.rev acc, inst) | [], _ -> Sil.Earray (len, construct Rhs acc idx_se_list2, inst) | _, [] -> @@ -1285,7 +1285,7 @@ let find_hpred_by_address tenv (e: Exp.t) (sigma: Prop.sigma) : Sil.hpred option | [] -> None, sigma | hpred:: sigma -> if contains_e hpred then - Some hpred, (IList.rev sigma_acc) @ sigma + Some hpred, List.rev_append sigma_acc sigma else f (hpred:: sigma_acc) sigma in f [] sigma @@ -1578,8 +1578,8 @@ let pi_partial_join tenv mode let bounds = let bounds1 = get_array_len ep1 in let bounds2 = get_array_len ep2 in - let bounds_sorted = IList.sort IntLit.compare_value (bounds1@bounds2) in - IList.rev (IList.remove_duplicates IntLit.compare_value bounds_sorted) in + let bounds_sorted = List.sort ~cmp:IntLit.compare_value (bounds1@bounds2) in + List.rev (List.remove_consecutive_duplicates ~equal:IntLit.eq bounds_sorted) in let widening_atom a = (* widening heuristic for upper bound: take the length of some array, -2 and -1 *) match Prop.atom_exp_le_const a, bounds with @@ -1723,7 +1723,7 @@ let eprop_partial_meet tenv (ep1: 'a Prop.t) (ep2: 'b Prop.t) : 'c Prop.t = let sub2 = ep2.Prop.sub in let range1 = Sil.sub_range sub1 in let f e = Sil.fav_for_all (Sil.exp_fav e) Ident.is_normal in - Sil.equal_subst sub1 sub2 && List.for_all ~f:f range1 in + Sil.equal_subst sub1 sub2 && List.for_all ~f range1 in if not (sub_check ()) then (L.d_strln "sub_check() failed"; raise Sil.JoinFail) @@ -1870,7 +1870,7 @@ let eprop_partial_join tenv mode (ep1: Prop.exposed Prop.t) (ep2: Prop.exposed P let list_reduce name dd f list = let rec element_list_reduce acc (x, p1) = function - | [] -> ((x, p1), IList.rev acc) + | [] -> ((x, p1), List.rev acc) | (y, p2):: ys -> begin L.d_strln ("COMBINE[" ^ name ^ "] ...."); L.d_str "ENTRY1: "; L.d_ln (); dd x; L.d_ln (); @@ -1886,7 +1886,7 @@ let list_reduce name dd f list = element_list_reduce acc (x', p1) ys end in let rec reduce acc = function - | [] -> IList.rev acc + | [] -> List.rev acc | x:: xs -> let (x', xs') = element_list_reduce [] x xs in reduce (x':: acc) xs' in @@ -1954,7 +1954,7 @@ let pathset_join let ppalist1 = pset_to_plist pset1 in let ppalist2 = pset_to_plist pset2 in let rec join_proppath_plist ppalist2_acc ((p2, pa2) as ppa2) = function - | [] -> (ppa2, IList.rev ppalist2_acc) + | [] -> (ppa2, List.rev ppalist2_acc) | ((p2', pa2') as ppa2') :: ppalist2_rest -> begin L.d_strln ".... JOIN ...."; L.d_strln "JOIN SYM HEAP1: "; Prop.d_prop p2; L.d_ln (); diff --git a/infer/src/backend/dotty.ml b/infer/src/backend/dotty.ml index d0c898163..96ff8de0b 100644 --- a/infer/src/backend/dotty.ml +++ b/infer/src/backend/dotty.ml @@ -335,7 +335,7 @@ let set_exps_neq_zero pi = exps_neq_zero := e :: !exps_neq_zero | _ -> () in exps_neq_zero := []; - List.iter ~f:f pi + List.iter ~f pi let box_dangling e = let entry_e = List.filter ~f:(fun b -> match b with @@ -1316,10 +1316,10 @@ let rec pointsto_contents_to_xml (co: Sil.strexp) : Io_infer.Xml.node = Io_infer.Xml.create_tree "cell" [("content-value", exp_to_xml_string e)] [] | Sil.Estruct (fel, _) -> let f (fld, exp) = Io_infer.Xml.create_tree "struct-field" [("id", Ident.fieldname_to_string fld)] [(pointsto_contents_to_xml exp)] in - Io_infer.Xml.create_tree "struct" [] (List.map ~f:f fel) + Io_infer.Xml.create_tree "struct" [] (List.map ~f fel) | Sil.Earray (len, nel, _) -> let f (e, se) = Io_infer.Xml.create_tree "array-element" [("index", exp_to_xml_string e)] [pointsto_contents_to_xml se] in - Io_infer.Xml.create_tree "array" [("size", exp_to_xml_string len)] (List.map ~f:f nel) + Io_infer.Xml.create_tree "array" [("size", exp_to_xml_string len)] (List.map ~f nel) (* Convert an atom to xml in a light version. Namely, the expressions are not fully blown-up into *) (* xml tree but visualized as strings *) diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index e3e9d87b1..e8cd344d0 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -78,7 +78,7 @@ let find_in_node_or_preds start_node f_node_instr = begin visited := Procdesc.NodeSet.add node !visited; let instrs = Procdesc.Node.get_instrs node in - match List.find_map ~f:(f_node_instr node) (IList.rev instrs) with + match List.find_map ~f:(f_node_instr node) (List.rev instrs) with | Some res -> Some res | None -> List.find_map ~f:find (Procdesc.Node.get_preds node) end in @@ -172,7 +172,7 @@ let find_struct_by_value_assignment node pvar = let find_instr node = function | Sil.Call (_, Const (Cfun pname), args, loc, cf) -> begin - match IList.last args with + match List.last args with | Some (Exp.Lvar last_arg, _) when Pvar.equal pvar last_arg -> Some (node, pname, loc, cf) | _ -> @@ -575,7 +575,7 @@ let vpath_find tenv prop _exp : DExp.t option * Typ.t option = let rec find sigma_acc sigma_todo exp = let do_fse res sigma_acc' sigma_todo' lexp texp (f, se) = match se with | Sil.Eexp (e, _) when Exp.equal exp e -> - let sigma' = (IList.rev_append sigma_acc' sigma_todo') in + let sigma' = (List.rev_append sigma_acc' sigma_todo') in (match lexp with | Exp.Lvar pv -> let typo = match texp with @@ -601,7 +601,7 @@ let vpath_find tenv prop _exp : DExp.t option * Typ.t option = | _ -> () in let do_sexp sigma_acc' sigma_todo' lexp sexp texp = match sexp with | Sil.Eexp (e, _) when Exp.equal exp e -> - let sigma' = (IList.rev_append sigma_acc' sigma_todo') in + let sigma' = (List.rev_append sigma_acc' sigma_todo') in (match lexp with | Exp.Lvar pv when not (Pvar.is_frontend_tmp pv) -> let typo = match texp with @@ -981,7 +981,7 @@ let find_with_exp prop exp = if not (Pvar.is_abduced pv) && not (Pvar.is_this pv) then res := Some (pv, Fpvar) in let found_in_struct pv fld_lst = (* found_in_pvar has priority *) - if is_none !res then res := Some (pv, Fstruct (IList.rev fld_lst)) in + if is_none !res then res := Some (pv, Fstruct (List.rev fld_lst)) in let rec search_struct pv fld_lst = function | Sil.Eexp (e, _) -> if Exp.equal e exp then found_in_struct pv fld_lst diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 7869f5219..27bb5361f 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -221,8 +221,8 @@ let capture = function let args = List.rev_append Config.anon_args ( ["--analyzer"; - IList.assoc Config.equal_analyzer Config.analyzer - (List.map ~f:(fun (n,a) -> (a,n)) Config.string_to_analyzer)] @ + List.Assoc.find_exn ~equal:Config.equal_analyzer + (List.map ~f:(fun (n,a) -> (a,n)) Config.string_to_analyzer) Config.analyzer] @ (match Config.blacklist with | Some s when in_buck_mode -> ["--blacklist-regex"; s] | _ -> []) @ @@ -232,7 +232,7 @@ let capture = function ["--buck"]) @ (match Config.java_jar_compiler with None -> [] | Some p -> ["--java-jar-compiler"; p]) @ - (match IList.rev Config.buck_build_args with + (match List.rev Config.buck_build_args with | args when in_buck_mode -> List.map ~f:(fun arg -> ["--Xbuck"; "'" ^ arg ^ "'"]) args |> List.concat | _ -> []) @ @@ -430,7 +430,7 @@ let get_driver_mode () = assert_supported_mode `Java "Buck genrule"; BuckGenrule path | None -> - driver_mode_of_build_cmd (IList.rev Config.rest) + driver_mode_of_build_cmd (List.rev Config.rest) let () = let driver_mode = get_driver_mode () in diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 51fb01e03..558660da8 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -253,7 +253,7 @@ let patterns_of_json_with_key (json_key, json) = let collect accu = function | `String s -> s:: accu | _ -> failwith ("Unrecognised parameters in " ^ Yojson.Basic.to_string (`Assoc assoc)) in - IList.rev (List.fold ~f:collect ~init:[] l) in + List.rev (List.fold ~f:collect ~init:[] l) in let create_method_pattern assoc = let loop mp = function | (key, `String s) when String.equal key "class" -> diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index c03229c28..db9ee3a66 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -731,7 +731,7 @@ let compute_visited vset = let node_loc = Procdesc.Node.get_loc n in let instrs_loc = List.map ~f:Sil.instr_get_loc (Procdesc.Node.get_instrs n) in let lines = List.map ~f:(fun loc -> loc.Location.line) (node_loc :: instrs_loc) in - IList.remove_duplicates Int.compare (IList.sort Int.compare lines) in + List.remove_consecutive_duplicates ~equal:Int.equal (List.sort ~cmp:Int.compare lines) in let do_node n = res := Specs.Visitedset.add (Procdesc.Node.get_id n, node_get_all_lines n) !res in @@ -769,7 +769,7 @@ let extract_specs tenv pdesc pathset : Prop.normal Specs.spec list = vset_ref_add_path vset_ref path; compute_visited !vset_ref in (pre', post', visited) in - List.map ~f:f pplist in + List.map ~f pplist in let pre_post_map = let add map (pre, post, visited) = let current_posts, current_visited = @@ -1422,7 +1422,7 @@ let do_analysis exe_env = let calls = ref [] in let f (callee_pname, loc) = calls := (callee_pname, loc) :: !calls in Procdesc.iter_calls f caller_pdesc; - IList.rev !calls in + List.rev !calls in let init_proc pname = let pdesc = match Exe_env.get_proc_desc exe_env pname with | Some pdesc -> diff --git a/infer/src/backend/match.ml b/infer/src/backend/match.ml index d6cd2660e..782d70c68 100644 --- a/infer/src/backend/match.ml +++ b/infer/src/backend/match.ml @@ -159,7 +159,7 @@ and isel_match isel1 sub vars isel2 = (* extends substitution sub by creating a new substitution for vars *) let sub_extend_with_ren (sub: Sil.subst) vars = let f id = (id, Exp.Var (Ident.create_fresh Ident.kprimed)) in - let renaming_for_vars = Sil.sub_of_list (List.map ~f:f vars) in + let renaming_for_vars = Sil.sub_of_list (List.map ~f vars) in Sil.sub_join sub renaming_for_vars type sidecondition = Prop.normal Prop.t -> Sil.subst -> bool @@ -409,10 +409,10 @@ and hpara_common_match_with_impl tenv impl_ok ids1 sigma1 eids2 ids2 sigma2 = let sub_ids = let ren_ids = List.zip_exn ids2 ids1 in let f (id2, id1) = (id2, Exp.Var id1) in - List.map ~f:f ren_ids in + List.map ~f ren_ids in let (sub_eids, eids_fresh) = let f id = (id, Ident.create_fresh Ident.kprimed) in - let ren_eids = List.map ~f:f eids2 in + let ren_eids = List.map ~f eids2 in let eids_fresh = List.map ~f:snd ren_eids in let sub_eids = List.map ~f:(fun (id2, id1) -> (id2, Exp.Var id1)) ren_eids in (sub_eids, eids_fresh) in @@ -471,7 +471,7 @@ let sigma_remove_hpred eq sigma e = | Sil.Hpointsto (root, _, _) | Sil.Hlseg (_, _, root, _, _) | Sil.Hdllseg (_, _, root, _, _, _, _) -> eq root e in - let sigma_e, sigma_no_e = IList.partition filter sigma in + let sigma_e, sigma_no_e = List.partition_tf ~f:filter sigma in match sigma_e with | [] -> (None, sigma) | [hpred_e] -> (Some hpred_e, sigma_no_e) @@ -579,7 +579,7 @@ let rec generic_find_partial_iso tenv mode update corres sigma_corres todos sigm match todos with | [] -> let sigma1, sigma2 = sigma_corres in - Some (IList.rev corres, IList.rev sigma1, IList.rev sigma2, sigma_todo) + Some (List.rev corres, List.rev sigma1, List.rev sigma2, sigma_todo) | (e1, e2) :: todos' when corres_related corres e1 e2 -> begin match corres_extend_front e1 e2 corres with @@ -721,7 +721,7 @@ let generic_para_create tenv corres sigma1 elist1 = let not_in_elist1 ((e1, _), _) = not (List.exists ~f:(Exp.equal e1) elist1) in let corres_ids_no_elist1 = List.filter ~f:not_in_elist1 corres_ids in let should_be_shared ((e1, e2), _) = Exp.equal e1 e2 in - let shared, exists = IList.partition should_be_shared corres_ids_no_elist1 in + let shared, exists = List.partition_tf ~f:should_be_shared corres_ids_no_elist1 in let es_shared = List.map ~f:(fun ((e1, _), _) -> e1) shared in (es_shared, List.map ~f:snd shared, List.map ~f:snd exists) in let renaming = List.map ~f:(fun ((e1, _), id) -> (e1, id)) corres_ids in diff --git a/infer/src/backend/paths.ml b/infer/src/backend/paths.ml index 176fac925..e2094798c 100644 --- a/infer/src/backend/paths.ml +++ b/infer/src/backend/paths.ml @@ -319,11 +319,11 @@ end = struct if !position_seen then let rec remove_until_seen = function | ((_, p, _, _) as x):: l -> - if path_pos_at_path p then IList.rev (x :: l) + if path_pos_at_path p then List.rev (x :: l) else remove_until_seen l | [] -> [] in remove_until_seen inverse_sequence - else IList.rev inverse_sequence in + else List.rev inverse_sequence in List.iter ~f:(fun (level, p, session, exn_opt) -> f level p session exn_opt) sequence_up_to_last_seen @@ -493,13 +493,8 @@ end = struct let n = Int.compare lt1.Errlog.lt_level lt2.Errlog.lt_level in if n <> 0 then n else Location.compare lt1.Errlog.lt_loc lt2.Errlog.lt_loc in let relevant lt = lt.Errlog.lt_node_tags <> [] in - IList.remove_irrelevant_duplicates compare relevant (IList.rev !trace) - (* IList.remove_duplicates compare (IList.sort compare !trace) *) + IList.remove_irrelevant_duplicates compare relevant (List.rev !trace) -(* - let equal p1 p2 = - compare p1 p2 = 0 -*) end (* =============== END of the Path module ===============*) diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index b7e5458a4..b923183a4 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -37,7 +37,7 @@ let add_dispatch_calls pdesc cg tenv = receiver_typ in let sorted_overrides = let overrides = Prover.get_overrides_of tenv receiver_typ_no_ptr callee_pname in - IList.sort (fun (_, p1) (_, p2) -> Procname.compare p1 p2) overrides in + List.sort ~cmp:(fun (_, p1) (_, p2) -> Procname.compare p1 p2) overrides in (match sorted_overrides with | ((_, target_pname) :: _) as all_targets -> let targets_to_add = @@ -127,7 +127,7 @@ module NullifyTransferFunctions = struct let last_instr_in_node node = let get_last_instr () = let instrs = CFG.instrs node in - match IList.rev instrs with + match List.rev instrs with | instr :: _ -> instr | [] -> Sil.skip_instr in if phys_equal node !cache_node @@ -215,12 +215,12 @@ let add_nullify_instrs pdesc tenv liveness_inv_map = List.filter ~f:is_local pvars |> List.map ~f:(fun pvar -> Sil.Nullify (pvar, loc)) in if nullify_instrs <> [] - then Procdesc.Node.append_instrs node (IList.rev nullify_instrs) in + then Procdesc.Node.append_instrs node (List.rev nullify_instrs) in let node_add_removetmps_instructions node ids = if ids <> [] then let loc = Procdesc.Node.get_last_loc node in - Procdesc.Node.append_instrs node [Sil.Remove_temps (IList.rev ids, loc)] in + Procdesc.Node.append_instrs node [Sil.Remove_temps (List.rev ids, loc)] in List.iter ~f:(fun node -> @@ -294,7 +294,7 @@ let do_copy_propagation pdesc tenv = ~f:(fun node -> let instrs, changed = rev_transform_node_instrs node in if changed - then Procdesc.Node.replace_instrs node (IList.rev instrs)) + then Procdesc.Node.replace_instrs node (List.rev instrs)) (Procdesc.get_nodes pdesc) let do_liveness pdesc tenv = diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 31fa3bbb4..76c15f769 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -42,7 +42,7 @@ struct assert false (* execution never reaches here *) with End_of_file -> (In_channel.close cin; - Array.of_list (IList.rev !lines)) + Array.of_list (List.rev !lines)) let file_data (hash: t) fname = try @@ -367,7 +367,7 @@ let force_delayed_prints () = F.fprintf !curr_html_formatter "@?"; (* flush html stream *) List.iter ~f:(force_delayed_print !curr_html_formatter) - (IList.rev (L.get_delayed_prints ())); + (List.rev (L.get_delayed_prints ())); F.fprintf !curr_html_formatter "@?"; L.reset_delayed_prints (); Config.forcing_delayed_prints := false @@ -418,7 +418,7 @@ let write_proc_html source whole_seconds pdesc = if Config.write_html then begin let pname = Procdesc.get_proc_name pdesc in - let nodes = IList.sort Procdesc.Node.compare (Procdesc.get_nodes pdesc) in + let nodes = List.sort ~cmp:Procdesc.Node.compare (Procdesc.get_nodes pdesc) in let linenum = (Procdesc.Node.get_loc (List.hd_exn nodes)).Location.line in let fd, fmt = Io_infer.Html.create diff --git a/infer/src/backend/prop.ml b/infer/src/backend/prop.ml index 0cb7a399d..d597e82ff 100644 --- a/infer/src/backend/prop.ml +++ b/infer/src/backend/prop.ml @@ -194,13 +194,13 @@ let sigma_get_stack_nonstack only_local_vars sigma = let hpred_is_stack_var = function | Sil.Hpointsto (Lvar pvar, _, _) -> not only_local_vars || Pvar.is_local pvar | _ -> false in - IList.partition hpred_is_stack_var sigma + List.partition_tf ~f:hpred_is_stack_var sigma (** Pretty print a sigma in simple mode. *) let pp_sigma_simple pe env fmt sigma = let sigma_stack, sigma_nonstack = sigma_get_stack_nonstack false sigma in let pp_stack fmt _sg = - let sg = IList.sort Sil.compare_hpred _sg in + let sg = List.sort ~cmp:Sil.compare_hpred _sg in if sg <> [] then Format.fprintf fmt "%a" (Pp.semicolon_seq pe (pp_hpred_stackvar pe)) sg in let pp_nl fmt doit = if doit then (match pe.Pp.kind with @@ -428,11 +428,11 @@ let prop_fpv prop = let pi_sub (subst: Sil.subst) pi = let f = Sil.atom_sub subst in - List.map ~f:f pi + List.map ~f pi let sigma_sub subst sigma = let f = Sil.hpred_sub subst in - List.map ~f:f sigma + List.map ~f sigma (** Return [true] if the atom is an inequality *) let atom_is_inequality (atom : Sil.atom) = match atom with @@ -656,7 +656,7 @@ module Normalize = struct in let rec f eqs_zero sigma_passed (sigma1: sigma) = match sigma1 with | [] -> - (IList.rev eqs_zero, IList.rev sigma_passed) + (List.rev eqs_zero, List.rev sigma_passed) | Hpointsto _ as hpred :: sigma' -> f eqs_zero (hpred :: sigma_passed) sigma' | Hlseg (Lseg_PE, _, e1, e2, _) :: sigma' @@ -676,7 +676,7 @@ module Normalize = struct let sigma_intro_nonemptylseg e1 e2 sigma = let rec f sigma_passed (sigma1 : sigma) = match sigma1 with | [] -> - IList.rev sigma_passed + List.rev sigma_passed | Hpointsto _ as hpred :: sigma' -> f (hpred :: sigma_passed) sigma' | Hlseg (Lseg_PE, para, f1, f2, shared) :: sigma' @@ -1192,15 +1192,15 @@ module Normalize = struct | _ -> [e],[], IntLit.zero in (* sort and filter out expressions appearing in both the positive and negative part *) let normalize_posnegoff (pos, neg, off) = - let pos' = IList.sort Exp.compare pos in - let neg' = IList.sort Exp.compare neg in + let pos' = List.sort ~cmp:Exp.compare pos in + let neg' = List.sort ~cmp:Exp.compare neg in let rec combine pacc nacc = function | x:: ps, y:: ng -> (match Exp.compare x y with | n when n < 0 -> combine (x:: pacc) nacc (ps, y :: ng) | 0 -> combine pacc nacc (ps, ng) | _ -> combine pacc (y:: nacc) (x :: ps, ng)) - | ps, ng -> (IList.rev pacc) @ ps, (IList.rev nacc) @ ng in + | ps, ng -> List.rev_append pacc ps, List.rev_append nacc ng in let pos'', neg'' = combine [] [] (pos', neg') in (pos'', neg'', off) in (* turn a non-empty list of expressions into a sum expression *) @@ -1318,7 +1318,7 @@ module Normalize = struct let fld_cnts' = List.map ~f:(fun (fld, cnt) -> fld, strexp_normalize tenv sub cnt) fld_cnts in - let fld_cnts'' = IList.sort [%compare: Ident.fieldname * Sil.strexp] fld_cnts' in + let fld_cnts'' = List.sort ~cmp:[%compare: Ident.fieldname * Sil.strexp] fld_cnts' in Estruct (fld_cnts'', inst) end | Earray (len, idx_cnts, inst) -> @@ -1333,7 +1333,7 @@ module Normalize = struct let idx' = exp_normalize tenv sub idx in idx', strexp_normalize tenv sub cnt) idx_cnts in let idx_cnts'' = - IList.sort [%compare: Exp.t * Sil.strexp] idx_cnts' in + List.sort ~cmp:[%compare: Exp.t * Sil.strexp] idx_cnts' in Earray (len', idx_cnts'', inst) end @@ -1413,22 +1413,22 @@ module Normalize = struct and hpara_normalize tenv (para : Sil.hpara) = let normalized_body = List.map ~f:(hpred_normalize tenv Sil.sub_empty) (para.body) in - let sorted_body = IList.sort Sil.compare_hpred normalized_body in + let sorted_body = List.sort ~cmp:Sil.compare_hpred normalized_body in { para with body = sorted_body } and hpara_dll_normalize tenv (para : Sil.hpara_dll) = let normalized_body = List.map ~f:(hpred_normalize tenv Sil.sub_empty) (para.body_dll) in - let sorted_body = IList.sort Sil.compare_hpred normalized_body in + let sorted_body = List.sort ~cmp:Sil.compare_hpred normalized_body in { para with body_dll = sorted_body } let sigma_normalize tenv sub sigma = let sigma' = - IList.stable_sort Sil.compare_hpred (List.map ~f:(hpred_normalize tenv sub) sigma) in + List.stable_sort ~cmp:Sil.compare_hpred (List.map ~f:(hpred_normalize tenv sub) sigma) in if equal_sigma sigma sigma' then sigma else sigma' let pi_tighten_ineq tenv pi = - let ineq_list, nonineq_list = IList.partition atom_is_inequality pi in + let ineq_list, nonineq_list = List.partition_tf ~f:atom_is_inequality pi in let diseq_list = let get_disequality_info acc (a : Sil.atom) = match a with | Aneq (Const (Cint n), e) @@ -1443,11 +1443,11 @@ module Normalize = struct | Some (e, n) -> (e, n):: acc | _ -> acc in let rec le_tighten le_list_done = function - | [] -> IList.rev le_list_done + | [] -> List.rev le_list_done | (e, n):: le_list_todo -> (* e <= n *) if is_neq e n then le_tighten le_list_done ((e, n -- IntLit.one):: le_list_todo) else le_tighten ((e, n):: le_list_done) (le_list_todo) in - let le_list = IList.rev (List.fold ~f:get_le_inequality_info ~init:[] ineq_list) in + let le_list = List.rev (List.fold ~f:get_le_inequality_info ~init:[] ineq_list) in le_tighten [] le_list in let lt_list_tightened = let get_lt_inequality_info acc a = @@ -1455,13 +1455,13 @@ module Normalize = struct | Some (n, e) -> (n, e):: acc | _ -> acc in let rec lt_tighten lt_list_done = function - | [] -> IList.rev lt_list_done + | [] -> List.rev lt_list_done | (n, e):: lt_list_todo -> (* n < e *) let n_plus_one = n ++ IntLit.one in if is_neq e n_plus_one then lt_tighten lt_list_done ((n ++ IntLit.one, e):: lt_list_todo) else lt_tighten ((n, e):: lt_list_done) (lt_list_todo) in - let lt_list = IList.rev (List.fold ~f:get_lt_inequality_info ~init:[] ineq_list) in + let lt_list = List.rev (List.fold ~f:get_lt_inequality_info ~init:[] ineq_list) in lt_tighten [] lt_list in let ineq_list' = let le_ineq_list = @@ -1519,8 +1519,8 @@ module Normalize = struct not (Const.equal c1 c2) | _ -> true in let pi' = - IList.stable_sort - Sil.compare_atom + List.stable_sort + ~cmp:Sil.compare_atom ((List.filter ~f:filter_useful_atom nonineq_list) @ ineq_list) in let pi'' = pi_sorted_remove_redundant pi' in if equal_pi pi0 pi'' then pi0 else pi'' @@ -1769,7 +1769,7 @@ end = struct let stack = Stack.create () let init es = Stack.clear stack; - List.iter ~f:(fun e -> Stack.push stack e) (IList.rev es) + List.iter ~f:(fun e -> Stack.push stack e) (List.rev es) let final () = Stack.clear stack let is_empty () = Stack.is_empty stack let push e = Stack.push stack e @@ -1780,7 +1780,7 @@ let sigma_get_start_lexps_sort sigma = let exp_compare_neg e1 e2 = - (Exp.compare e1 e2) in let filter e = Sil.fav_for_all (Sil.exp_fav e) Ident.is_normal in let lexps = Sil.hpred_list_get_lexps filter sigma in - IList.sort exp_compare_neg lexps + List.sort ~cmp:exp_compare_neg lexps let sigma_dfs_sort tenv sigma = @@ -1799,30 +1799,30 @@ let sigma_dfs_sort tenv sigma = List.iter ~f:(fun (_, se) -> handle_strexp se) idx_se_list in let rec handle_e visited seen e (sigma : sigma) = match sigma with - | [] -> (visited, IList.rev seen) + | [] -> (visited, List.rev seen) | hpred :: cur -> begin match hpred with | Hpointsto (e', se, _) when Exp.equal e e' -> handle_strexp se; - (hpred:: visited, IList.rev_append cur seen) + (hpred:: visited, List.rev_append cur seen) | Hlseg (_, _, root, next, shared) when Exp.equal e root -> List.iter ~f:ExpStack.push (next:: shared); - (hpred:: visited, IList.rev_append cur seen) + (hpred:: visited, List.rev_append cur seen) | Hdllseg (_, _, iF, oB, oF, iB, shared) when Exp.equal e iF || Exp.equal e iB -> List.iter ~f:ExpStack.push (oB:: oF:: shared); - (hpred:: visited, IList.rev_append cur seen) + (hpred:: visited, List.rev_append cur seen) | _ -> handle_e visited (hpred:: seen) e cur end in let rec handle_sigma visited = function - | [] -> IList.rev visited + | [] -> List.rev visited | cur -> if ExpStack.is_empty () then let cur' = Normalize.sigma_normalize tenv Sil.sub_empty cur in - IList.rev_append cur' visited + List.rev_append cur' visited else let e = ExpStack.pop () in let (visited', cur') = handle_e visited [] e cur in @@ -1864,7 +1864,7 @@ let hpred_get_array_indices acc (hpred : Sil.hpred) = match hpred with let sigma_get_array_indices sigma = let indices = List.fold ~f:hpred_get_array_indices ~init:[] sigma in - IList.rev indices + List.rev indices let compute_reindexing fav_add get_id_offset list = let rec select list_passed list_seen = function @@ -1931,7 +1931,7 @@ let prop_rename_array_indices tenv prop = not (Exp.equal e1' e2' && IntLit.lt n1' n2') | _ -> true in let rec select_minimal_indices indices_seen = function - | [] -> IList.rev indices_seen + | [] -> List.rev indices_seen | index:: indices_rest -> let indices_seen' = List.filter ~f:(not_same_base_lt_offsets index) indices_seen in let indices_seen_new = index:: indices_seen' in @@ -1944,7 +1944,7 @@ let prop_rename_array_indices tenv prop = let compute_renaming fav = let ids = Sil.fav_to_list fav in - let ids_primed, ids_nonprimed = IList.partition Ident.is_primed ids in + let ids_primed, ids_nonprimed = List.partition_tf ~f:Ident.is_primed ids in let ids_footprint = List.filter ~f:Ident.is_footprint ids_nonprimed in let id_base_primed = Ident.create Ident.kprimed 0 in @@ -2016,13 +2016,13 @@ let rec strexp_captured_ren ren (se : Sil.strexp) : Sil.strexp = match se with Eexp (exp_captured_ren ren e, inst) | Estruct (fld_se_list, inst) -> let f (fld, se) = (fld, strexp_captured_ren ren se) in - Estruct (List.map ~f:f fld_se_list, inst) + Estruct (List.map ~f fld_se_list, inst) | Earray (len, idx_se_list, inst) -> let f (idx, se) = let idx' = exp_captured_ren ren idx in (idx', strexp_captured_ren ren se) in let len' = exp_captured_ren ren len in - Earray (len', List.map ~f:f idx_se_list, inst) + Earray (len', List.map ~f idx_se_list, inst) and hpred_captured_ren ren (hpred : Sil.hpred) : Sil.hpred = match hpred with | Hpointsto (base, se, te) -> @@ -2234,7 +2234,7 @@ let prop_iter_create prop = (** Return the prop associated to the iterator. *) let prop_iter_to_prop tenv iter = - let sigma = IList.rev_append iter.pit_old (iter.pit_curr:: iter.pit_new) in + let sigma = List.rev_append iter.pit_old (iter.pit_curr:: iter.pit_new) in let prop = Normalize.normalize tenv (set prop_emp @@ -2257,7 +2257,7 @@ let prop_iter_add_atom footprint iter atom = (** Remove the current element of the iterator, and return the prop associated to the resulting iterator *) let prop_iter_remove_curr_then_to_prop tenv iter : normal t = - let sigma = IList.rev_append iter.pit_old iter.pit_new in + let sigma = List.rev_append iter.pit_old iter.pit_new in let normalized_sigma = Normalize.sigma_normalize tenv iter.pit_sub sigma in let prop = set prop_emp @@ -2342,7 +2342,7 @@ let prop_iter_make_id_primed tenv id iter = Normalize.atom_normalize tenv Sil.sub_empty eq' in let rec split pairs_unpid pairs_pid = function - | [] -> (IList.rev pairs_unpid, IList.rev pairs_pid) + | [] -> (List.rev pairs_unpid, List.rev pairs_pid) | (eq:: eqs_cur : pi) -> begin match eq with @@ -2362,7 +2362,7 @@ let prop_iter_make_id_primed tenv id iter = let rec get_eqs acc = function | [] | [_] -> - IList.rev acc + List.rev acc | (_, e1) :: (((_, e2) :: _) as pairs) -> get_eqs (Sil.Aeq(e1, e2):: acc) pairs in diff --git a/infer/src/backend/propgraph.ml b/infer/src/backend/propgraph.ml index 4b8b400eb..38e4d5287 100644 --- a/infer/src/backend/propgraph.ml +++ b/infer/src/backend/propgraph.ml @@ -117,7 +117,7 @@ let contains_edge (footprint_part: bool) (g: t) (e: edge) = (** [iter_edges footprint_part f g] iterates function [f] on the edges in [g] in the same order as returned by [get_edges]; if [footprint_part] is true the edges are taken from the footprint part. *) let iter_edges footprint_part f g = - List.iter ~f:f (get_edges footprint_part g) + List.iter ~f (get_edges footprint_part g) (** Graph annotated with the differences w.r.t. a previous graph *) type diff = diff --git a/infer/src/backend/propset.ml b/infer/src/backend/propset.ml index 7fd674ee9..f984f4a16 100644 --- a/infer/src/backend/propset.ml +++ b/infer/src/backend/propset.ml @@ -73,14 +73,14 @@ let to_proplist pset = (** Apply function to all the elements of [propset], removing those where it returns [None]. *) let map_option tenv f pset = - let plisto = List.map ~f:f (to_proplist pset) in + let plisto = List.map ~f (to_proplist pset) in let plisto = List.filter ~f:(function | Some _ -> true | None -> false) plisto in let plist = List.map ~f:(function Some p -> p | None -> assert false) plisto in from_proplist tenv plist (** Apply function to all the elements of [propset]. *) let map tenv f pset = - from_proplist tenv (List.map ~f:f (to_proplist pset)) + from_proplist tenv (List.map ~f (to_proplist pset)) (** [fold f pset a] computes [f (... (f (f a p1) p2) ...) pn] where [p1 ... pN] are the elements of pset, in increasing order. *) diff --git a/infer/src/backend/prover.ml b/infer/src/backend/prover.ml index a77bda706..541c0c834 100644 --- a/infer/src/backend/prover.ml +++ b/infer/src/backend/prover.ml @@ -30,8 +30,8 @@ let rec list_rev_acc acc = function | x:: l -> list_rev_acc (x:: acc) l let rec remove_redundancy have_same_key acc = function - | [] -> IList.rev acc - | [x] -> IList.rev (x:: acc) + | [] -> List.rev acc + | [x] -> List.rev (x:: acc) | x:: ((y:: l') as l) -> if have_same_key x y then remove_redundancy have_same_key acc (x:: l') else remove_redundancy have_same_key (x:: acc) l @@ -123,7 +123,7 @@ end = struct generate constr acc rest let sort_then_remove_redundancy constraints = - let constraints_sorted = IList.sort compare constraints in + let constraints_sorted = List.sort ~cmp:compare constraints in let have_same_key (e1, e2, _) (f1, f2, _) = [%compare.equal: Exp.t * Exp.t] (e1, e2) (f1, f2) in remove_redundancy have_same_key [] constraints_sorted @@ -133,8 +133,8 @@ end = struct let rec combine acc_todos acc_seen constraints_new constraints_old = match constraints_new, constraints_old with - | [], [] -> IList.rev acc_todos, IList.rev acc_seen - | [], _ -> IList.rev acc_todos, list_rev_acc constraints_old acc_seen + | [], [] -> List.rev acc_todos, List.rev acc_seen + | [], _ -> List.rev acc_todos, list_rev_acc constraints_old acc_seen | _, [] -> list_rev_acc constraints_new acc_todos, list_rev_acc constraints_new acc_seen | constr:: rest, constr':: rest' -> let e1, e2, n = constr in @@ -268,7 +268,7 @@ end = struct if c2 <> 0 then c2 else - (Exp.compare e1 f1) let leqs_sort_then_remove_redundancy leqs = - let leqs_sorted = IList.sort leq_compare leqs in + let leqs_sorted = List.sort ~cmp:leq_compare leqs in let have_same_key leq1 leq2 = match leq1, leq2 with | (e1, Exp.Const (Const.Cint n1)), (e2, Exp.Const (Const.Cint n2)) -> @@ -276,7 +276,7 @@ end = struct | _, _ -> false in remove_redundancy have_same_key [] leqs_sorted let lts_sort_then_remove_redundancy lts = - let lts_sorted = IList.sort lt_compare lts in + let lts_sorted = List.sort ~cmp:lt_compare lts in let have_same_key lt1 lt2 = match lt1, lt2 with | (Exp.Const (Const.Cint n1), e1), (Exp.Const (Const.Cint n2), e2) -> @@ -643,7 +643,7 @@ let check_disequal tenv prop e1 e2 = let sigma_irrelevant' = hpred :: sigma_irrelevant in f sigma_irrelevant' e sigma_rest | Some _ -> - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (true, sigma_irrelevant')) | Sil.Hlseg (k, _, e1, e2, _) as hpred :: sigma_rest -> (match is_root tenv prop e1 e with @@ -652,20 +652,20 @@ let check_disequal tenv prop e1 e2 = in f sigma_irrelevant' e sigma_rest | Some _ -> if (Sil.equal_lseg_kind k Sil.Lseg_NE || check_pi_implies_disequal e1 e2) then - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (true, sigma_irrelevant') else if (Exp.equal e2 Exp.zero) then - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (false, sigma_irrelevant') else - let sigma_rest' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_rest' = List.rev_append sigma_irrelevant sigma_rest in f [] e2 sigma_rest') | Sil.Hdllseg (Sil.Lseg_NE, _, iF, _, _, iB, _) :: sigma_rest -> if is_root tenv prop iF e <> None || is_root tenv prop iB e <> None then - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (true, sigma_irrelevant') else - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (false, sigma_irrelevant') | Sil.Hdllseg (Sil.Lseg_PE, _, iF, _, oF, _, _) as hpred :: sigma_rest -> (match is_root tenv prop iF e with @@ -674,18 +674,18 @@ let check_disequal tenv prop e1 e2 = in f sigma_irrelevant' e sigma_rest | Some _ -> if (check_pi_implies_disequal iF oF) then - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (true, sigma_irrelevant') else if (Exp.equal oF Exp.zero) then - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (false, sigma_irrelevant') else - let sigma_rest' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_rest' = List.rev_append sigma_irrelevant sigma_rest in f [] oF sigma_rest') in let f_null_check sigma_irrelevant e sigma_rest = if not (Exp.equal e Exp.zero) then f sigma_irrelevant e sigma_rest else - let sigma_irrelevant' = (IList.rev sigma_irrelevant) @ sigma_rest + let sigma_irrelevant' = List.rev_append sigma_irrelevant sigma_rest in Some (false, sigma_irrelevant') in match f_null_check [] n_e1 spatial_part with | None -> false @@ -1474,7 +1474,8 @@ let move_primed_lhs_from_front subs sigma = match sigma with | [] -> sigma | hpred:: _ -> if hpred_has_primed_lhs (snd subs) hpred then - let (sigma_primed, sigma_unprimed) = IList.partition (hpred_has_primed_lhs (snd subs)) sigma + let (sigma_primed, sigma_unprimed) = + List.partition_tf ~f:(hpred_has_primed_lhs (snd subs)) sigma in match sigma_unprimed with | [] -> raise (IMPL_EXC ("every hpred has primed lhs, cannot proceed", subs, (EXC_FALSE_SIGMA sigma))) | _:: _ -> sigma_unprimed @ sigma_primed @@ -2148,7 +2149,7 @@ let check_implication_base pname tenv check_frame_empty calc_missing prop1 prop2 let sigma1, sigma2 = prop1.Prop.sigma, prop2.Prop.sigma in let subs = pre_check_pure_implication tenv calc_missing (prop1.Prop.sub, sub1_base) pi1 pi2 in let pi2_bcheck, pi2_nobcheck = (* find bounds checks implicit in pi2 *) - IList.partition ProverState.atom_is_array_bounds_check pi2 in + List.partition_tf ~f:ProverState.atom_is_array_bounds_check pi2 in List.iter ~f:(fun a -> ProverState.add_bounds_check (ProverState.BCfrom_pre a)) pi2_bcheck; L.d_strln "pre_check_pure_implication"; L.d_strln "pi1:"; @@ -2239,7 +2240,7 @@ exception NO_COVER let find_minimum_pure_cover tenv cases = let cases = let compare (pi1, _) (pi2, _) = Int.compare (List.length pi1) (List.length pi2) - in IList.sort compare cases in + in List.sort ~cmp:compare cases in let rec grow seen todo = match todo with | [] -> raise NO_COVER | (pi, x):: todo' -> diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index b82d81ae3..f6e736667 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -16,8 +16,8 @@ module L = Logging module F = Format let list_product l1 l2 = - let l1' = IList.rev l1 in - let l2' = IList.rev l2 in + let l1' = List.rev l1 in + let l2' = List.rev l2 in List.fold ~f:(fun acc x -> List.fold ~f:(fun acc' y -> (x, y):: acc') ~init:acc l2') ~init:[] @@ -117,7 +117,7 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp let replace_typ_of_f (f', t', a') = if Ident.equal_fieldname f f' then (f, res_t', a') else (f', t', a') in let fields' = - IList.sort StructTyp.compare_field (List.map ~f:replace_typ_of_f fields) in + List.sort ~cmp:StructTyp.compare_field (List.map ~f:replace_typ_of_f fields) in ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ; (atoms', se, t) | None -> @@ -220,13 +220,13 @@ let rec _strexp_extend_values let replace_fse ((f1, _) as ft1) = if Ident.equal_fieldname f1 f then (f1, res_se') else ft1 in let res_fsel' = - IList.sort - [%compare: Ident.fieldname * Sil.strexp] + List.sort + ~cmp:[%compare: Ident.fieldname * Sil.strexp] (List.map ~f:replace_fse fsel) in let replace_fta ((f1, _, a1) as fta1) = if Ident.equal_fieldname f f1 then (f1, res_typ', a1) else fta1 in let fields' = - IList.sort StructTyp.compare_field (List.map ~f:replace_fta fields) in + List.sort ~cmp:StructTyp.compare_field (List.map ~f:replace_fta fields) in ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ; (res_atoms', Sil.Estruct (res_fsel', inst'), typ) :: acc in List.fold ~f:replace ~init:[] atoms_se_typ_list' @@ -235,11 +235,11 @@ let rec _strexp_extend_values create_struct_values pname tenv orig_prop footprint_part kind max_stamp typ' off' inst in let res_fsel' = - IList.sort [%compare: Ident.fieldname * Sil.strexp] ((f, se'):: fsel) in + List.sort ~cmp:[%compare: Ident.fieldname * Sil.strexp] ((f, se'):: fsel) in let replace_fta (f', t', a') = if Ident.equal_fieldname f' f then (f, res_typ', a') else (f', t', a') in let fields' = - IList.sort StructTyp.compare_field (List.map ~f:replace_fta fields) in + List.sort ~cmp:StructTyp.compare_field (List.map ~f:replace_fta fields) in ignore (Tenv.mk_struct tenv ~default:struct_typ ~fields:fields' name) ; [(atoms', Sil.Estruct (res_fsel', inst'), typ)] ) @@ -317,7 +317,7 @@ and array_case_analysis_index pname tenv orig_prop create_struct_values pname tenv orig_prop footprint_part kind max_stamp typ_cont off inst in check_sound elem_typ; - let cont_new = IList.sort [%compare: Exp.t * Sil.strexp] ((index, elem_se):: array_cont) in + let cont_new = List.sort ~cmp:[%compare: Exp.t * Sil.strexp] ((index, elem_se):: array_cont) in let array_new = Sil.Earray (array_len, cont_new, inst_arr) in let typ_new = Typ.Tarray (elem_typ, typ_array_len) in [(atoms, array_new, typ_new)] @@ -330,13 +330,14 @@ and array_case_analysis_index pname tenv orig_prop create_struct_values pname tenv orig_prop footprint_part kind max_stamp typ_cont off inst in check_sound elem_typ; - let cont_new = IList.sort [%compare: Exp.t * Sil.strexp] ((index, elem_se):: array_cont) in + let cont_new = + List.sort ~cmp:[%compare: Exp.t * Sil.strexp] ((index, elem_se):: array_cont) in let array_new = Sil.Earray (array_len, cont_new, inst_arr) in let typ_new = Typ.Tarray (elem_typ, typ_array_len) in [(atoms, array_new, typ_new)] end in let rec handle_case acc isel_seen_rev = function - | [] -> List.concat (IList.rev (res_new:: acc)) + | [] -> List.concat (List.rev (res_new:: acc)) | (i, se) as ise :: isel_unseen -> let atoms_se_typ_list = _strexp_extend_values @@ -367,7 +368,7 @@ let laundry_offset_for_footprint max_stamp offs_in = let rec laundry offs_seen eqs offs = match offs with | [] -> - (IList.rev offs_seen, IList.rev eqs) + (List.rev offs_seen, List.rev eqs) | (Sil.Off_fld _ as off):: offs' -> let offs_seen' = off:: offs_seen in laundry offs_seen' eqs offs' @@ -487,7 +488,7 @@ let prop_iter_check_fields_ptsto_shallow tenv iter lexp = let fav_max_stamp fav = let max_stamp = ref 0 in let f id = max_stamp := max !max_stamp (Ident.get_stamp id) in - List.iter ~f:f (Sil.fav_to_list fav); + List.iter ~f (Sil.fav_to_list fav); max_stamp (** [prop_iter_extend_ptsto iter lexp] extends the current psto @@ -555,7 +556,7 @@ let prop_iter_extend_ptsto pname tenv orig_prop iter lexp inst = let atoms_fp_sigma_list = let footprint_sigma = Prop.prop_iter_get_footprint_sigma iter in let sigma_pto, sigma_rest = - IList.partition (function + List.partition_tf ~f:(function | Sil.Hpointsto(e', _, _) -> Exp.equal e e' | Sil.Hlseg (_, _, e1, _, _) -> Exp.equal e e1 | Sil.Hdllseg (_, _, e_iF, _, _, e_iB, _) -> @@ -570,7 +571,7 @@ let prop_iter_extend_ptsto pname tenv orig_prop iter lexp inst = L.d_warning "Cannot extend "; Sil.d_exp lexp; L.d_strln " in"; Prop.d_prop (Prop.prop_iter_to_prop tenv iter); L.d_ln(); [([], footprint_sigma)] in List.map - ~f:(fun (atoms, sigma') -> (atoms, IList.stable_sort Sil.compare_hpred sigma')) + ~f:(fun (atoms, sigma') -> (atoms, List.stable_sort ~cmp:Sil.compare_hpred sigma')) atoms_sigma_list in let iter_atoms_fp_sigma_list = list_product iter_list atoms_fp_sigma_list in @@ -1232,7 +1233,7 @@ let rec iter_rearrange else iter_rearrange pname tenv (Prop.lexp_normalize_prop tenv prop' lexp) typ prop' iter' inst in let rec f_many_iters iters_lst = function - | [] -> List.concat (IList.rev iters_lst) + | [] -> List.concat (List.rev iters_lst) | iter':: iters' -> let iters_res' = f_one_iter iter' in f_many_iters (iters_res':: iters_lst) iters' in diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index fd89b7371..750422cb1 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -271,7 +271,7 @@ module CallStats = struct (** module for tracing stats of function calls *) let pp_trace fmt tr = Pp.seq (fun fmt x -> F.fprintf fmt "%s" (tr_elem_str x)) - fmt (IList.rev tr) + fmt (List.rev tr) let iter f t = let elems = ref [] in @@ -279,7 +279,7 @@ module CallStats = struct (** module for tracing stats of function calls *) let sorted_elems = let compare (pname_loc1, _) (pname_loc2, _) = [%compare: Procname.t * Location.t] pname_loc1 pname_loc2 in - IList.sort compare !elems in + List.sort ~cmp:compare !elems in List.iter ~f:(fun (x, tr) -> f x tr) sorted_elems (* diff --git a/infer/src/backend/state.ml b/infer/src/backend/state.ml index 78b0255a3..9eda91c6b 100644 --- a/infer/src/backend/state.ml +++ b/infer/src/backend/state.ml @@ -211,7 +211,7 @@ let mk_find_duplicate_nodes proc_desc : (Procdesc.Node.t -> Procdesc.NodeSet.t) let elements = S.elements s in let (_, node_normalized_instrs), _ = let filter (node', _) = Procdesc.Node.equal node node' in - match IList.partition filter elements with + match List.partition_tf ~f:filter elements with | [this], others -> this, others | _ -> raise Not_found in let duplicates = diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 922ace592..87bca5047 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -603,7 +603,7 @@ let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = | Some class_name -> (Procname.split_classname (Typename.name class_name)) :: accu | None -> name :: accu) - ~init:[] args (Procname.java_get_parameters resolved_pname_java) |> IList.rev in + ~init:[] args (Procname.java_get_parameters resolved_pname_java) |> List.rev in Procname.java_replace_parameters resolved_pname_java resolved_params in let resolved_pname_java, other_args = match args with @@ -792,7 +792,7 @@ let normalize_params tenv pdesc prop actual_params = let e', p' = check_arith_norm_exp tenv pdesc e p in (p', (e', t) :: args) in let prop, args = List.fold ~f:norm_arg ~init:(prop, []) actual_params in - (prop, IList.rev args) + (prop, List.rev args) let do_error_checks tenv node_opt instr pname pdesc = match node_opt with | Some node -> @@ -920,7 +920,7 @@ let execute_load ?(report_deref_errors=true) pname pdesc tenv id rhs_exp typ loc begin match pred_insts_op with | None -> update acc_in ([],[]) - | Some pred_insts -> IList.rev (List.fold ~f:update ~init:acc_in pred_insts) + | Some pred_insts -> List.rev (List.fold ~f:update ~init:acc_in pred_insts) end | (Sil.Hpointsto _, _) -> Errdesc.warning_err loc "no offset access in execute_load -- treating as skip@."; @@ -956,7 +956,7 @@ let execute_load ?(report_deref_errors=true) pname pdesc tenv id rhs_exp typ loc else prop in let iter_list = Rearrange.rearrange ~report_deref_errors pdesc tenv n_rhs_exp' typ prop' loc in - IList.rev (List.fold ~f:(execute_load_ pdesc tenv id loc) ~init:[] iter_list) + List.rev (List.fold ~f:(execute_load_ pdesc tenv id loc) ~init:[] iter_list) with Rearrange.ARRAY_ACCESS -> if Int.equal Config.array_level 0 then assert false else @@ -995,7 +995,7 @@ let execute_store ?(report_deref_errors=true) pname pdesc tenv lhs_exp typ rhs_e let prop = Attribute.replace_objc_null tenv prop n_lhs_exp n_rhs_exp in let n_lhs_exp' = Prop.exp_collapse_consecutive_indices_prop typ n_lhs_exp in let iter_list = Rearrange.rearrange ~report_deref_errors pdesc tenv n_lhs_exp' typ prop loc in - IList.rev (List.fold ~f:(execute_store_ pdesc tenv n_rhs_exp) ~init:[] iter_list) + List.rev (List.fold ~f:(execute_store_ pdesc tenv n_rhs_exp) ~init:[] iter_list) with Rearrange.ARRAY_ACCESS -> if Int.equal Config.array_level 0 then assert false else [prop_] @@ -1211,8 +1211,8 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path | Sil.Nullify (pvar, _) -> begin let eprop = Prop.expose prop_ in - match IList.partition - (function + match List.partition_tf + ~f:(function | Sil.Hpointsto (Exp.Lvar pvar', _, _) -> Pvar.equal pvar pvar' | _ -> false) eprop.Prop.sigma with | [Sil.Hpointsto(e, se, typ)], sigma' -> diff --git a/infer/src/backend/tabulation.ml b/infer/src/backend/tabulation.ml index 8b0a899bc..cbab5631b 100644 --- a/infer/src/backend/tabulation.ml +++ b/infer/src/backend/tabulation.ml @@ -131,7 +131,7 @@ let spec_find_rename trace_call (proc_name : Procname.t) end; let formal_parameters = List.map ~f:(fun (x, _) -> Pvar.mk_callee x proc_name) formals in - List.map ~f:f specs, formal_parameters + List.map ~f specs, formal_parameters with Not_found -> begin L.d_strln ("ERROR: found no entry for procedure " ^ @@ -214,10 +214,10 @@ let process_splitting L.d_str "Don't know about id: "; Sil.d_exp (Exp.Var id); L.d_ln (); assert false; end - in Sil.sub_of_list (List.map ~f:f fav_sub_list) in + in Sil.sub_of_list (List.map ~f fav_sub_list) in let sub2_list = let f id = (id, Exp.Var (Ident.create_fresh Ident.kfootprint)) - in List.map ~f:f (Sil.fav_to_list fav_missing_primed) in + in List.map ~f (Sil.fav_to_list fav_missing_primed) in let sub_list' = List.map ~f:(fun (id, e) -> (id, Sil.exp_sub sub1 e)) sub_list in let sub' = Sil.sub_of_list (sub2_list @ sub_list') in @@ -497,8 +497,8 @@ let hpred_star_fld tenv (hpred1 : Sil.hpred) (hpred2 : Sil.hpred) : Sil.hpred = (** Implementation of [*] for the field-splitting model *) let sigma_star_fld tenv (sigma1 : Sil.hpred list) (sigma2 : Sil.hpred list) : Sil.hpred list = - let sigma1 = IList.stable_sort hpred_lhs_compare sigma1 in - let sigma2 = IList.stable_sort hpred_lhs_compare sigma2 in + let sigma1 = List.stable_sort ~cmp:hpred_lhs_compare sigma1 in + let sigma2 = List.stable_sort ~cmp:hpred_lhs_compare sigma2 in (* L.out "@.@. computing %a@.STAR @.%a@.@." pp_sigma sigma1 pp_sigma sigma2; *) let rec star sg1 sg2 : Sil.hpred list = match sg1, sg2 with @@ -532,8 +532,8 @@ let hpred_star_typing (hpred1 : Sil.hpred) (_, te2) : Sil.hpred = let sigma_star_typ (sigma1 : Sil.hpred list) (typings2 : (Exp.t * Exp.t) list) : Sil.hpred list = let typing_lhs_compare (e1, _) (e2, _) = Exp.compare e1 e2 in - let sigma1 = IList.stable_sort hpred_lhs_compare sigma1 in - let typings2 = IList.stable_sort typing_lhs_compare typings2 in + let sigma1 = List.stable_sort ~cmp:hpred_lhs_compare sigma1 in + let typings2 = List.stable_sort ~cmp:typing_lhs_compare typings2 in let rec star sg1 typ2 : Sil.hpred list = match sg1, typ2 with | [], _ -> [] @@ -605,7 +605,7 @@ let prop_copy_footprint_pure tenv p1 p2 = let p2' = Prop.set p2 ~pi_fp:p1.Prop.pi_fp ~sigma_fp:p1.Prop.sigma_fp in let pi2 = p2'.Prop.pi in - let pi2_attr, pi2_noattr = IList.partition Attribute.is_pred pi2 in + let pi2_attr, pi2_noattr = List.partition_tf ~f:Attribute.is_pred pi2 in let res_noattr = Prop.set p2' ~pi:(Prop.get_pure p1 @ pi2_noattr) in let replace_attr prop atom = (* call replace_atom_attribute which deals with existing attibutes *) (* if [atom] represents an attribute [att], add the attribure to [prop] *) @@ -1057,7 +1057,7 @@ let exe_spec check_uninitialize_dangling_deref tenv callee_pname actual_pre split.sub formal_params results; let inconsistent_results, consistent_results = - IList.partition (fun (p, _) -> Prover.check_inconsistency tenv p) results in + List.partition_tf ~f:(fun (p, _) -> Prover.check_inconsistency tenv p) results in let incons_pre_missing = inconsistent_actualpre_missing tenv actual_pre (Some split) in Valid_res { incons_pre_missing = incons_pre_missing; vr_pi = split.missing_pi; @@ -1140,15 +1140,15 @@ let exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc re | Invalid_res _ -> false | Valid_res _ -> true in let valid_res0, invalid_res0 = - IList.partition filter_valid_res results in + List.partition_tf ~f:filter_valid_res results in let valid_res = List.map ~f:(function Valid_res cr -> cr | Invalid_res _ -> assert false) valid_res0 in let invalid_res = List.map ~f:(function Valid_res _ -> assert false | Invalid_res ir -> ir) invalid_res0 in let valid_res_miss_pi, valid_res_no_miss_pi = - IList.partition (fun vr -> vr.vr_pi <> []) valid_res in + List.partition_tf ~f:(fun vr -> vr.vr_pi <> []) valid_res in let _, valid_res_cons_pre_missing = - IList.partition (fun vr -> vr.incons_pre_missing) valid_res in + List.partition_tf ~f:(fun vr -> vr.incons_pre_missing) valid_res in let deref_errors = List.filter ~f:(function Dereference_error _ -> true | _ -> false) invalid_res in let print_pi pi = diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 25819a3c7..913db0112 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -157,7 +157,7 @@ let wrap_line indent_string wrap_length line = (rev_lines, new_non_empty, new_line, String.length new_line) in let (rev_lines, _, line, _) = List.fold ~f:add_word_to_paragraph ~init:([], false, "", 0) words in - IList.rev (line::rev_lines) + List.rev (line::rev_lines) let pad_and_xform doc_width left_width desc = match desc with @@ -226,7 +226,7 @@ let check_no_duplicates desc_list = | _ :: tl -> check_for_duplicates_ tl in - check_for_duplicates_ (IList.sort (fun (x, _, _) (y, _, _) -> String.compare x y) desc_list) + check_for_duplicates_ (List.sort ~cmp:(fun (x, _, _) (y, _, _) -> String.compare x y) desc_list) let parse_tag_desc_lists = List.map ~f:(fun parse_tag -> (parse_tag, ref [])) all_parse_tags @@ -491,8 +491,8 @@ let mk_path_list ?(default=[]) ?(deprecated=[]) ~long ?short ?parse_mode ?(meta= let mk_symbol ~default ~symbols ~eq ?(deprecated=[]) ~long ?short ?parse_mode ?(meta="") doc = let strings = List.map ~f:fst symbols in let sym_to_str = List.map ~f:(fun (x,y) -> (y,x)) symbols in - let of_string str = IList.assoc String.equal str symbols in - let to_string sym = IList.assoc eq sym sym_to_str in + let of_string str = List.Assoc.find_exn ~equal:String.equal symbols str in + let to_string sym = List.Assoc.find_exn ~equal:eq sym_to_str sym in mk ~deprecated ~long ?short ~default ?parse_mode ~meta doc ~default_to_string:(fun s -> to_string s) ~mk_setter:(fun var str -> var := of_string str) @@ -501,7 +501,7 @@ let mk_symbol ~default ~symbols ~eq ?(deprecated=[]) ~long ?short ?parse_mode ?( let mk_symbol_opt ~symbols ?(deprecated=[]) ~long ?short ?parse_mode ?(meta="") doc = let strings = List.map ~f:fst symbols in - let of_string str = IList.assoc String.equal str symbols in + let of_string str = List.Assoc.find_exn ~equal:String.equal symbols str in mk ~deprecated ~long ?short ~default:None ?parse_mode ~meta doc ~default_to_string:(fun _ -> "") ~mk_setter:(fun var str -> var := Some (of_string str)) @@ -511,8 +511,8 @@ let mk_symbol_opt ~symbols ?(deprecated=[]) ~long ?short ?parse_mode ?(meta="") let mk_symbol_seq ?(default=[]) ~symbols ~eq ?(deprecated=[]) ~long ?short ?parse_mode ?(meta="") doc = let sym_to_str = List.map ~f:(fun (x,y) -> (y,x)) symbols in - let of_string str = IList.assoc String.equal str symbols in - let to_string sym = IList.assoc eq sym sym_to_str in + let of_string str = List.Assoc.find_exn ~equal:String.equal symbols str in + let to_string sym = List.Assoc.find_exn ~equal:eq sym_to_str sym in mk ~deprecated ~long ?short ~default ?parse_mode ~meta:(",-separated sequence" ^ meta) doc ~default_to_string:(fun syms -> String.concat ~sep:" " (List.map ~f:to_string syms)) ~mk_setter:(fun var str_seq -> @@ -607,7 +607,7 @@ let set_curr_speclist_for_parse_action ~incomplete ~usage parse_action = | _ -> let lower_norm s = String.lowercase @@ norm s in String.compare (lower_norm x) (lower_norm y) in - let sort speclist = IList.sort compare_specs speclist in + let sort speclist = List.sort ~cmp:compare_specs speclist in align (sort speclist) in let add_to_curr_speclist ?(add_help=false) ?header parse_action = diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index c472214c1..cccac1a56 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -31,7 +31,7 @@ let exes = [ let exe_name = let exe_to_name = List.map ~f:(fun (n,a) -> (a,n)) exes in - fun exe -> IList.assoc equal_exe exe exe_to_name + fun exe -> List.Assoc.find_exn ~equal:equal_exe exe_to_name exe let frontend_parse_modes = CLOpt.(Infer [Clang]) @@ -262,8 +262,8 @@ let real_exe_name = Utils.realpath Sys.executable_name let current_exe = - try IList.assoc String.equal (Filename.basename real_exe_name) exes - with Not_found -> Driver + List.Assoc.find ~equal:String.equal exes (Filename.basename real_exe_name) |> + Option.value ~default:Driver let bin_dir = Filename.dirname real_exe_name @@ -1381,9 +1381,9 @@ let post_parsing_initialization () = Unix.close_process_full chans |> ignore; err in let analyzer_name = - IList.assoc equal_analyzer - (match !analyzer with Some a -> a | None -> Infer) - (List.map ~f:(fun (n,a) -> (a,n)) string_to_analyzer) in + List.Assoc.find_exn ~equal:equal_analyzer + (List.map ~f:(fun (n,a) -> (a,n)) string_to_analyzer) + (match !analyzer with Some a -> a | None -> Infer) in let infer_version = Version.commit in F.eprintf "%s/%s/%s@." javac_version analyzer_name infer_version | `Javac -> @@ -1615,13 +1615,13 @@ and xml_specs = !xml_specs (** Configuration values derived from command-line options *) let analysis_path_regex_whitelist analyzer = - IList.assoc equal_analyzer analyzer analysis_path_regex_whitelist_options + List.Assoc.find_exn ~equal:equal_analyzer analysis_path_regex_whitelist_options analyzer and analysis_path_regex_blacklist analyzer = - IList.assoc equal_analyzer analyzer analysis_path_regex_blacklist_options + List.Assoc.find_exn ~equal:equal_analyzer analysis_path_regex_blacklist_options analyzer and analysis_blacklist_files_containing analyzer = - IList.assoc equal_analyzer analyzer analysis_blacklist_files_containing_options + List.Assoc.find_exn ~equal:equal_analyzer analysis_blacklist_files_containing_options analyzer and analysis_suppress_errors analyzer = - IList.assoc equal_analyzer analyzer analysis_suppress_errors_options + List.Assoc.find_exn ~equal:equal_analyzer analysis_suppress_errors_options analyzer let checkers_enabled = not (eradicate || crashcontext || quandary || threadsafety) diff --git a/infer/src/base/DB.ml b/infer/src/base/DB.ml index a9ebfac56..822e1cda4 100644 --- a/infer/src/base/DB.ml +++ b/infer/src/base/DB.ml @@ -52,7 +52,7 @@ let find_source_dirs () = let dir = Filename.concat captured_dir fname in if Sys.is_directory dir = `Yes then add_cg_files_from_dir dir) files_in_results_dir; - IList.rev !source_dirs + List.rev !source_dirs (** {2 Filename} *) @@ -165,7 +165,7 @@ module Results_dir = struct | [] -> base | name:: names -> Filename.concat (f names) (if String.equal name ".." then Filename.parent_dir_name else name) in - f (IList.rev path) + f (List.rev path) (** convert a path to a filename *) let path_to_filename pk path = @@ -205,7 +205,7 @@ module Results_dir = struct let new_path = Filename.concat (create names) name in Utils.create_dir new_path; new_path in - let filename, dir_path = match IList.rev path with + let filename, dir_path = match List.rev path with | filename:: dir_path -> filename, dir_path | [] -> raise (Failure "create_path") in let full_fname = Filename.concat (create dir_path) filename in diff --git a/infer/src/base/IList.ml b/infer/src/base/IList.ml index 5de711745..f16185902 100644 --- a/infer/src/base/IList.ml +++ b/infer/src/base/IList.ml @@ -7,25 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. *) -let partition = List.partition -let rev = List.rev -let rev_append = List.rev_append -let sort = List.sort -let stable_sort = List.stable_sort - -let rec last = function - | [] -> None - | [x] -> Some x - | _ :: xs -> last xs - -let rec drop_first n = function - | xs when n == 0 -> xs - | _ :: xs -> drop_first (n - 1) xs - | [] -> [] - -let drop_last n list = - rev (drop_first n (rev list)) - (** like map, but returns the original list if unchanged *) let map_changed (f : 'a -> 'a) l = let l', changed = @@ -36,7 +17,7 @@ let map_changed (f : 'a -> 'a) l = ([], false) l in if changed - then rev l' + then List.rev l' else l (** like filter, but returns the original list if unchanged *) @@ -50,24 +31,15 @@ let filter_changed (f : 'a -> bool) l = ([], false) l in if changed - then rev l' + then List.rev l' else l -(** Remove consecutive equal elements from a list (according to the given comparison functions) *) -let remove_duplicates compare l = - let rec remove compare acc = function - | [] -> rev acc - | [x] -> rev (x:: acc) - | x:: ((y:: l'') as l') -> - if compare x y = 0 then remove compare acc (x:: l'') - else remove compare (x:: acc) l' in - remove compare [] l - -(** Remove consecutive equal irrelevant elements from a list (according to the given comparison and relevance functions) *) +(** Remove consecutive equal irrelevant elements from a list + (according to the given comparison and relevance functions) *) let remove_irrelevant_duplicates compare relevant l = let rec remove compare acc = function - | [] -> rev acc - | [x] -> rev (x:: acc) + | [] -> List.rev acc + | [x] -> List.rev (x:: acc) | x:: ((y:: l'') as l') -> if compare x y = 0 then begin match relevant x, relevant y with @@ -82,9 +54,9 @@ let remove_irrelevant_duplicates compare relevant l = let rec merge_sorted_nodup compare res xs1 xs2 = match xs1, xs2 with | [], _ -> - rev_append res xs2 + List.rev_append res xs2 | _, [] -> - rev_append res xs1 + List.rev_append res xs1 | x1 :: xs1', x2 :: xs2' -> let n = compare x1 x2 in if n = 0 then @@ -95,8 +67,8 @@ let rec merge_sorted_nodup compare res xs1 xs2 = merge_sorted_nodup compare (x2 :: res) xs1 xs2' let intersect compare l1 l2 = - let l1_sorted = sort compare l1 in - let l2_sorted = sort compare l2 in + let l1_sorted = List.sort compare l1 in + let l2_sorted = List.sort compare l2 in let rec f l1 l2 = match l1, l2 with | ([], _) | (_,[]) -> false | (x1:: l1', x2:: l2') -> @@ -107,7 +79,7 @@ let intersect compare l1 l2 = f l1_sorted l2_sorted let inter compare xs ys = - let rev_sort xs = sort (fun x y -> compare y x) xs in + let rev_sort xs = List.sort (fun x y -> compare y x) xs in let rev_xs = rev_sort xs in let rev_ys = rev_sort ys in let rec inter_ is rev_xxs rev_yys = @@ -125,15 +97,6 @@ let inter compare xs ys = in inter_ [] rev_xs rev_ys -(** Return the first non-None result found when applying f to elements of l *) -let rec find_map_opt f = function - | [] -> None - | e :: l' -> - let e' = f e in - if e' <> None - then e' - else find_map_opt f l' - let to_string f l = let rec aux l = match l with @@ -141,16 +104,3 @@ let to_string f l = | s:: [] -> (f s) | s:: rest -> (f s)^", "^(aux rest) in "["^(aux l)^"]" - -(** Like List.mem_assoc but without builtin equality *) -let mem_assoc equal a l = - List.exists (fun x -> equal a (fst x)) l - -(** Like List.assoc but without builtin equality *) -let assoc equal a l = - snd (List.find (fun x -> equal a (fst x)) l) - -let range i j = - let rec aux n acc = - if n < i then acc else aux (n-1) (n :: acc) in - aux j [] diff --git a/infer/src/base/IList.mli b/infer/src/base/IList.mli index 9b55e0c33..e091ab6cb 100644 --- a/infer/src/base/IList.mli +++ b/infer/src/base/IList.mli @@ -13,25 +13,6 @@ val map_changed : ('a -> 'a) -> 'a list -> 'a list (** like filter, but returns the original list if unchanged *) val filter_changed : ('a -> bool) -> 'a list -> 'a list -val partition : ('a -> bool) -> 'a list -> 'a list * 'a list -val rev : 'a list -> 'a list -val rev_append : 'a list -> 'a list -> 'a list -val sort : ('a -> 'a -> int) -> 'a list -> 'a list - -val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list - -(** last element, if any *) -val last : 'a list -> 'a option - -(* Drops the first n elements from a list. *) -val drop_first : int -> 'a list -> 'a list - -(* Drops the last n elements from a list. *) -val drop_last : int -> 'a list -> 'a list - -(** Remove consecutive equal elements from a list (according to the given comparison functions) *) -val remove_duplicates : ('a -> 'a -> int) -> 'a list -> 'a list - (** Remove consecutive equal irrelevant elements from a list (according to the given comparison and relevance functions) *) val remove_irrelevant_duplicates : ('a -> 'a -> int) -> ('a -> bool) -> 'a list -> 'a list @@ -45,18 +26,4 @@ val intersect : ('a -> 'a -> int) -> 'a list -> 'a list -> bool (** [inter cmp xs ys] are the elements in both [xs] and [ys], sorted according to [cmp]. *) val inter : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list -(** Like List.mem_assoc but without builtin equality *) -val mem_assoc : ('a -> 'a -> bool) -> 'a -> ('a * 'b) list -> bool - -(** Like List.assoc but without builtin equality *) -val assoc : ('a -> 'a -> bool) -> 'a -> ('a * 'b) list -> 'b - -(** Return the first non-None result found when applying f to elements of l *) -val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option - val to_string : ('a -> string) -> 'a list -> string - -(** Creates an list, inclusive. E.g. `range 2 4` -> [2, 3, 4]. - - Not tail-recursive.*) -val range : int -> int -> int list diff --git a/infer/src/base/PrettyPrintable.ml b/infer/src/base/PrettyPrintable.ml index 4d6f903a2..d45dfcf77 100644 --- a/infer/src/base/PrettyPrintable.ml +++ b/infer/src/base/PrettyPrintable.ml @@ -55,7 +55,7 @@ module MakePPCompareSet let pp_element = Ord.pp let pp fmt s = - let elements_alpha = IList.sort Ord.compare_pp (elements s) in + let elements_alpha = List.sort ~cmp:Ord.compare_pp (elements s) in pp_collection ~pp_item:pp_element fmt elements_alpha end diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 4e44dfbe7..f133b73be 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -38,7 +38,7 @@ let read_file fname = with | End_of_file -> cleanup (); - Some (IList.rev !res) + Some (List.rev !res) | Sys_error _ -> cleanup (); None diff --git a/infer/src/checkers/SiofDomain.ml b/infer/src/checkers/SiofDomain.ml index f3f83a696..2d510492f 100644 --- a/infer/src/checkers/SiofDomain.ml +++ b/infer/src/checkers/SiofDomain.ml @@ -22,7 +22,7 @@ let normalize ((trace, initialized) as astate) = match trace with | BottomSiofTrace.Bottom -> astate | BottomSiofTrace.NonBottom trace -> let elems = SiofTrace.Sinks.elements (SiofTrace.sinks trace) in - let (direct, indirect) = IList.partition SiofTrace.is_intraprocedural_access elems in + let (direct, indirect) = List.partition_tf ~f:SiofTrace.is_intraprocedural_access elems in match direct with | [] | _::[] -> astate | access::_ -> diff --git a/infer/src/checkers/SiofTrace.ml b/infer/src/checkers/SiofTrace.ml index 28ec30e43..74253728e 100644 --- a/infer/src/checkers/SiofTrace.ml +++ b/infer/src/checkers/SiofTrace.ml @@ -84,7 +84,7 @@ let trace_of_error loc gname path = (* the last element of the trace gotten by [to_sink_loc_trace] contains a set of procedure-local accesses to globals. We want to remove it in exchange for as many trace elems as there are accesses. *) - match (IList.rev trace_with_set_of_globals, snd path) with + match (List.rev trace_with_set_of_globals, snd path) with | telem::rest, ({TraceElem.kind = (`Access, globals)}, _)::_ -> let nesting = telem.Errlog.lt_level in let add_trace_elem_of_access err_trace (global, loc) = @@ -94,7 +94,7 @@ let trace_of_error loc gname path = ::err_trace in GlobalsAccesses.elements globals |> List.fold ~f:add_trace_elem_of_access ~init:rest - |> IList.rev + |> List.rev | _ -> trace_with_set_of_globals in trace_elem_of_global::trace diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 7c98d80ca..309d263ab 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -150,7 +150,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct (* we don't want to warn on writes to the field if it is (a) thread-confined, or (b) volatile *) let is_safe_write access_path tenv = let is_thread_safe_write accesses tenv = - match IList.rev accesses, + match List.rev accesses, AccessPath.Raw.get_typ (AccessPath.Raw.truncate access_path) tenv with | AccessPath.FieldAccess fieldname :: _, Some (Typ.Tstruct typename | Tptr (Tstruct typename, _)) -> diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index 8d33d87ff..a20e6ae2b 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -218,7 +218,7 @@ module Make (Spec : Spec) = struct pp_sources sources_passthroughs Procname.pp cur_pname pp_passthroughs cur_passthroughs - pp_sinks (IList.rev sinks_passthroughs) + pp_sinks (List.rev sinks_passthroughs) type passthrough_kind = | Source (* passthroughs of a source *) @@ -284,11 +284,11 @@ module Make (Spec : Spec) = struct (Errlog.make_trace_element lt_level (CallSite.loc passthrough_site) desc []) :: acc in (* sort passthroughs by ascending line number to create a coherent trace *) let sorted_passthroughs = - IList.sort - (fun passthrough1 passthrough2 -> - let loc1 = CallSite.loc (Passthrough.site passthrough1) in - let loc2 = CallSite.loc (Passthrough.site passthrough2) in - Int.compare loc1.Location.line loc2.Location.line) + List.sort + ~cmp:(fun passthrough1 passthrough2 -> + let loc1 = CallSite.loc (Passthrough.site passthrough1) in + let loc2 = CallSite.loc (Passthrough.site passthrough2) in + Int.compare loc1.Location.line loc2.Location.line) (Passthroughs.elements passthroughs) in List.fold_right ~f:trace_elem_of_passthrough sorted_passthroughs ~init:acc0 in @@ -298,7 +298,7 @@ module Make (Spec : Spec) = struct if should_nest elem then incr level; pair, !level in - List.map ~f:get_nesting_ (IList.rev elems) in + List.map ~f:get_nesting_ (List.rev elems) in let trace_elems_of_path_elem call_site desc ~is_source ((elem, passthroughs), lt_level) acc = let desc = desc elem in diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index 309ba32d5..646dfcfff 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -175,7 +175,7 @@ let string_of_pname = let report_allocation_stack src_annot pname fst_call_loc trace stack_str constructor_pname call_loc = - let final_trace = IList.rev (update_trace call_loc trace) in + let final_trace = List.rev (update_trace call_loc trace) in let constr_str = string_of_pname constructor_pname in let description = Printf.sprintf @@ -193,7 +193,7 @@ let report_annotation_stack src_annot snk_annot src_pname loc trace stack_str sn if String.equal snk_annot dummy_constructor_annot then report_allocation_stack src_annot src_pname loc trace stack_str snk_pname call_loc else - let final_trace = IList.rev (update_trace call_loc trace) in + let final_trace = List.rev (update_trace call_loc trace) in let exp_pname_str = string_of_pname snk_pname in let description = Printf.sprintf diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index 2ab812093..ce65cd01d 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -427,7 +427,7 @@ let callback_find_deserialization { Callbacks.proc_desc; get_proc_desc; idenv; p (fun n -> Procdesc.Node.get_sliced_preds n has_instr) in let instrs = List.concat - (List.map ~f:(fun n -> IList.rev (Procdesc.Node.get_instrs n)) preds) in + (List.map ~f:(fun n -> List.rev (Procdesc.Node.get_instrs n)) preds) in List.find ~f instrs in let get_return_const proc_name' = diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index 91835af30..342e8510d 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -205,7 +205,7 @@ let get_vararg_type_names tenv | None -> type_names n) | _ -> raise Not_found in - IList.rev (type_names call_node) + List.rev (type_names call_node) let has_formal_proc_argument_type_names proc_desc argument_type_names = let formals = Procdesc.get_formals proc_desc in @@ -329,7 +329,7 @@ let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t) List.iter ~f:(do_instruction node) instrs in let nodes = Procdesc.get_nodes pdesc in List.iter ~f:do_node nodes; - IList.rev !res + List.rev !res let override_exists f tenv proc_name = let rec super_type_exists tenv super_class_name = diff --git a/infer/src/checkers/procCfg.ml b/infer/src/checkers/procCfg.ml index 406504c2c..214dab8ff 100644 --- a/infer/src/checkers/procCfg.ml +++ b/infer/src/checkers/procCfg.ml @@ -185,8 +185,8 @@ module Exceptional = struct normal_succs | exceptional_succs -> normal_succs @ exceptional_succs - |> IList.sort Procdesc.Node.compare - |> IList.remove_duplicates Procdesc.Node.compare + |> List.sort ~cmp:Procdesc.Node.compare + |> List.remove_consecutive_duplicates ~equal:Procdesc.Node.equal (** get all normal and exceptional predecessors of [n]. *) let preds t n = @@ -196,8 +196,8 @@ module Exceptional = struct normal_preds | exceptional_preds -> normal_preds @ exceptional_preds - |> IList.sort Procdesc.Node.compare - |> IList.remove_duplicates Procdesc.Node.compare + |> List.sort ~cmp:Procdesc.Node.compare + |> List.remove_consecutive_duplicates ~equal:Procdesc.Node.equal let proc_desc (pdesc, _) = pdesc let start_node (pdesc, _) = Procdesc.get_start_node pdesc @@ -208,8 +208,8 @@ end (** Wrapper that reverses the direction of the CFG *) module Backward (Base : S) = struct include Base - let instrs n = IList.rev (Base.instrs n) - let instr_ids n = IList.rev (Base.instr_ids n) + let instrs n = List.rev (Base.instrs n) + let instr_ids n = List.rev (Base.instr_ids n) let succs = Base.preds let preds = Base.succs diff --git a/infer/src/clang/ClangCommand.re b/infer/src/clang/ClangCommand.re index 6a6574899..a5244ee19 100644 --- a/infer/src/clang/ClangCommand.re +++ b/infer/src/clang/ClangCommand.re @@ -111,7 +111,7 @@ let clang_cc1_cmd_sanitizer cmd => { arg }; let post_args_rev = - [] |> IList.rev_append ["-include", Config.lib_dir ^\/ "clang_wrappers" ^\/ "global_defines.h"] |> + [] |> List.rev_append ["-include", Config.lib_dir ^\/ "clang_wrappers" ^\/ "global_defines.h"] |> /* Never error on warnings. Clang is often more strict than Apple's version. These arguments are appended at the end to override previous opposite settings. How it's done: suppress all the warnings, since there are no warnings, compiler can't elevate them to error @@ -121,7 +121,7 @@ let clang_cc1_cmd_sanitizer cmd => { fun | [] => /* return non-reversed list */ - IList.rev (post_args_rev @ res_rev) + List.rev (post_args_rev @ res_rev) | [flag, ...tl] when List.mem equal::String.equal flags_blacklist flag => filter_unsupported_args_and_swap_includes (flag, res_rev) tl | [arg, ...tl] => { @@ -167,8 +167,8 @@ let with_plugin_args args => { /* -cc1 has to be the first argument or clang will think it runs in driver mode */ argv_cons "-cc1" |> /* It's important to place this option before other -isystem options. */ - argv_do_if infer_cxx_models (IList.rev_append ["-isystem", Config.cpp_extra_include_dir]) |> - IList.rev_append [ + argv_do_if infer_cxx_models (List.rev_append ["-isystem", Config.cpp_extra_include_dir]) |> + List.rev_append [ "-load", plugin_path, /* (t7400979) this is a workaround to avoid that clang crashes when the -fmodules flag and the @@ -189,7 +189,7 @@ let with_plugin_args args => { /* add -O0 option to avoid compiler obfuscation of AST */ let args_after_rev = [] |> argv_cons "-O0" |> argv_do_if Config.fcp_syntax_only (argv_cons "-fsyntax-only"); - {...args, argv: IList.rev_append args_before_rev (args.argv @ IList.rev args_after_rev)} + {...args, argv: List.rev_append args_before_rev (args.argv @ List.rev args_after_rev)} }; let prepend_arg arg clang_args => {...clang_args, argv: [arg, ...clang_args.argv]}; diff --git a/infer/src/clang/ClangWrapper.re b/infer/src/clang/ClangWrapper.re index 64dc4d0e1..b1456f93e 100644 --- a/infer/src/clang/ClangWrapper.re +++ b/infer/src/clang/ClangWrapper.re @@ -81,7 +81,7 @@ let normalize prog::prog args::args :list action_item => { }; /* collect stdout and stderr output together (in reverse order) */ Utils.with_process_in clang_hashhashhash consume_input |> ignore; - normalized_commands := IList.rev !normalized_commands; + normalized_commands := List.rev !normalized_commands; !normalized_commands }; diff --git a/infer/src/clang/ComponentKit.ml b/infer/src/clang/ComponentKit.ml index 56db03801..3ea251c44 100644 --- a/infer/src/clang/ComponentKit.ml +++ b/infer/src/clang/ComponentKit.ml @@ -250,7 +250,7 @@ let component_with_multiple_factory_methods_advice context an = Some "Instead, always expose all parameters in a single \ designated initializer and document which are optional."; loc = CFrontend_checkers.location_from_decl context meth_decl - }) (IList.drop_first 1 factory_methods) + }) (List.drop factory_methods 1) | _ -> assert false in match an with | Ctl_parser_types.Decl (Clang_ast_t.ObjCImplementationDecl (_, _, _, _, impl_decl_info)) -> @@ -340,7 +340,7 @@ let component_file_line_count_info (context: CLintersContext.context) dec = Location.file = source_file } } - ) (IList.range 1 line_count) + ) (List.range 1 line_count ~start:`inclusive ~stop:`inclusive) | _ -> CTL.False, [] (** Computes a component file's cyclomatic complexity. diff --git a/infer/src/clang/cEnum_decl.ml b/infer/src/clang/cEnum_decl.ml index fc81e2a89..80f877f8b 100644 --- a/infer/src/clang/cEnum_decl.ml +++ b/infer/src/clang/cEnum_decl.ml @@ -43,7 +43,7 @@ let enum_decl decl = | _ -> () in match decl with | EnumDecl (_, _, _, type_ptr, decl_list, _, _) -> - add_enum_constants_to_map (IList.rev decl_list); + add_enum_constants_to_map (List.rev decl_list); let sil_type = Typ.Tint Typ.IInt in CAst_utils.update_sil_types_map type_ptr sil_type; sil_type diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 34b046a44..63ef53b25 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -264,7 +264,7 @@ struct | CXXDestructorDecl _ | FunctionTemplateDecl _ -> true | _ -> false in - let method_decls, no_method_decls = IList.partition is_method_decl decl_list in + let method_decls, no_method_decls = List.partition_tf ~f:is_method_decl decl_list in List.iter ~f:translate no_method_decls; ignore (CType_decl.add_types_from_decl_to_tenv tenv dec); List.iter ~f:translate method_decls diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index b69a7c632..edbaa3c6a 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -71,7 +71,7 @@ let rec append_no_duplicates_fields list1 list2 = let sort_fields fields = let compare (name1, _, _) (name2, _, _) = Ident.compare_fieldname name1 name2 in - IList.sort compare fields + List.sort ~cmp:compare fields let sort_fields_tenv tenv = diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 7ed4f72de..d50b7b0be 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -321,7 +321,7 @@ let get_return_type tenv ms = let sil_func_attributes_of_attributes attrs = let rec do_translation acc al = match al with - | [] -> IList.rev acc + | [] -> List.rev acc | Clang_ast_t.SentinelAttr attribute_info:: tl -> let (sentinel, null_pos) = match attribute_info.Clang_ast_t.ai_parameters with | a:: b::[] -> (int_of_string a, int_of_string b) @@ -370,7 +370,7 @@ let get_const_args_indices ~shift args = let i = ref shift in let rec aux result = function | [] -> - IList.rev result + List.rev result | (_, {Clang_ast_t.qt_type_ptr})::tl -> incr i; if is_pointer_to_const qt_type_ptr then diff --git a/infer/src/clang/cTL.ml b/infer/src/clang/cTL.ml index e82e87642..0567676f4 100644 --- a/infer/src/clang/cTL.ml +++ b/infer/src/clang/cTL.ml @@ -192,7 +192,7 @@ module Debug = struct result in let dotty_of_tree cluster_id tree = let get_root tree = match tree with Tree (root, _) -> root in - let get_children tree = match tree with Tree (_, children) -> IList.rev children in + let get_children tree = match tree with Tree (_, children) -> List.rev children in (* shallow: emit dotty about root node and edges to its children *) let shallow_dotty_of_tree tree = let root_node = get_root tree in @@ -246,7 +246,7 @@ module Debug = struct let buf = Buffer.create 16 in List.iteri ~f:(fun cluster_id tree -> Buffer.add_string buf ((dotty_of_tree cluster_id tree) ^ "\n")) - (IList.rev t.forest); + (List.rev t.forest); Printf.sprintf "digraph CTL_Evaluation {\n%s\n}\n" (buffer_content buf) end end diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index c424febd9..ae2238596 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -1147,7 +1147,7 @@ struct let all_res_trans = [res_trans_b; tmp_var_res_trans] in let res_trans = PriorityNode.compute_results_to_parent trans_state'' sil_loc "ConditinalStmt Branch" stmt_info all_res_trans in - let prune_nodes_t, prune_nodes_f = IList.partition is_true_prune_node prune_nodes in + let prune_nodes_t, prune_nodes_f = List.partition_tf ~f:is_true_prune_node prune_nodes in let prune_nodes' = if branch then prune_nodes_t else prune_nodes_f in List.iter ~f:(fun n -> Procdesc.node_set_succs_exn context.procdesc n res_trans.root_nodes []) @@ -1254,7 +1254,7 @@ struct let short_circuit binop s1 s2 = let res_trans_s1 = cond_trans trans_state s1 in let prune_nodes_t, prune_nodes_f = - IList.partition is_true_prune_node res_trans_s1.leaf_nodes in + List.partition_tf ~f:is_true_prune_node res_trans_s1.leaf_nodes in let res_trans_s2 = cond_trans trans_state s2 in (* prune_to_s2 is the prune node that is connected with the root node of the *) (* translation of s2.*) @@ -1318,7 +1318,7 @@ struct (Procdesc.Node.Stmt_node "IfStmt Branch") res_trans_b.instrs sil_loc context] | _ -> res_trans_b.root_nodes) in - let prune_nodes_t, prune_nodes_f = IList.partition is_true_prune_node prune_nodes in + let prune_nodes_t, prune_nodes_f = List.partition_tf ~f:is_true_prune_node prune_nodes in let prune_nodes' = if branch then prune_nodes_t else prune_nodes_f in List.iter ~f:(fun n -> Procdesc.node_set_succs_exn context.procdesc n nodes_branch []) @@ -1416,7 +1416,7 @@ struct aux rest (x :: acc) cases | [] -> cases, acc) in - aux (IList.rev stmt_list) [] [] in + aux (List.rev stmt_list) [] [] in let list_of_cases, pre_case_stmts = merge_into_cases stmt_list in let rec connected_instruction rev_instr_list successor_nodes = (* returns the entry point of the translated set of instr *) @@ -1454,7 +1454,7 @@ struct | CaseStmt(_, _ :: _ :: case_content) as case :: rest -> let last_nodes, last_prune_nodes = translate_and_connect_cases rest next_nodes next_prune_nodes in - let case_entry_point = connected_instruction (IList.rev case_content) last_nodes in + let case_entry_point = connected_instruction (List.rev case_content) last_nodes in (* connects between cases, then continuation has priority about breaks *) let prune_node_t, prune_node_f = create_prune_nodes_for_case case in Procdesc.node_set_succs_exn context.procdesc prune_node_t case_entry_point []; @@ -1468,14 +1468,14 @@ struct let last_nodes, last_prune_nodes = translate_and_connect_cases rest next_nodes [placeholder_entry_point] in let default_entry_point = - connected_instruction (IList.rev default_content) last_nodes in + connected_instruction (List.rev default_content) last_nodes in Procdesc.node_set_succs_exn context.procdesc placeholder_entry_point default_entry_point []; default_entry_point, last_prune_nodes | _ -> assert false in let top_entry_point, top_prune_nodes = translate_and_connect_cases list_of_cases succ_nodes succ_nodes in - let _ = connected_instruction (IList.rev pre_case_stmts) top_entry_point in + let _ = connected_instruction (List.rev pre_case_stmts) top_entry_point in Procdesc.node_set_succs_exn context.procdesc switch_special_cond_node top_prune_nodes []; let top_nodes = res_trans_decl.root_nodes in @@ -1489,7 +1489,7 @@ struct let stmt = extract_stmt_from_singleton stmt_list "ERROR: StmtExpr should have only one statement.\n" in let res_trans_stmt = instruction trans_state stmt in - let exps' = IList.rev res_trans_stmt.exps in + let exps' = List.rev res_trans_stmt.exps in match exps' with | last_exp :: _ -> { res_trans_stmt with exps = [last_exp]; } @@ -1553,7 +1553,7 @@ struct | Loops.DoWhile _ -> res_trans_body.root_nodes in (* Note: prune nodes are by contruction the res_trans_cond.leaf_nodes *) let prune_nodes_t, prune_nodes_f = - IList.partition is_true_prune_node res_trans_cond.leaf_nodes in + List.partition_tf ~f:is_true_prune_node res_trans_cond.leaf_nodes in let prune_t_succ_nodes = match loop_kind with | Loops.For _ | Loops.While _ -> res_trans_body.root_nodes @@ -1658,8 +1658,7 @@ struct (* of literals the array is initialized with *) let lh = if is_array var_type && List.length lh > List.length rh_exps then - let i = List.length lh - List.length rh_exps in - IList.drop_last i lh + List.take lh (List.length rh_exps) else lh in if Int.equal (List.length rh_exps) (List.length lh) then (* Creating new instructions by assigning right hand side to left hand side expressions *) @@ -2723,7 +2722,7 @@ struct exps = res_trans_tail.exps @ res_trans_s.exps; initd_exps = res_trans_tail.initd_exps @ res_trans_s.initd_exps; } in - exec_trans_instrs_no_rev trans_state (IList.rev trans_stmt_fun_list) + exec_trans_instrs_no_rev trans_state (List.rev trans_stmt_fun_list) and get_clang_stmt_trans stmt = fun trans_state -> exec_with_node_creation instruction trans_state stmt diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index d5ff106aa..7d75b0513 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -175,16 +175,16 @@ let collect_res_trans pdesc l = collect l' { root_nodes = root_nodes; leaf_nodes = leaf_nodes; - instrs = IList.rev_append rt'.instrs rt.instrs; - exps = IList.rev_append rt'.exps rt.exps; - initd_exps = IList.rev_append rt'.initd_exps rt.initd_exps; + instrs = List.rev_append rt'.instrs rt.instrs; + exps = List.rev_append rt'.exps rt.exps; + initd_exps = List.rev_append rt'.initd_exps rt.initd_exps; is_cpp_call_virtual = false; } in let rt = collect l empty_res_trans in { rt with - instrs = IList.rev rt.instrs; - exps = IList.rev rt.exps; - initd_exps = IList.rev rt.initd_exps; + instrs = List.rev rt.instrs; + exps = List.rev rt.exps; + initd_exps = List.rev rt.initd_exps; } let extract_var_exp_or_fail transt_state = diff --git a/infer/src/eradicate/AnnotatedSignature.ml b/infer/src/eradicate/AnnotatedSignature.ml index a9604c098..19b1d1622 100644 --- a/infer/src/eradicate/AnnotatedSignature.ml +++ b/infer/src/eradicate/AnnotatedSignature.ml @@ -40,7 +40,7 @@ let get proc_attributes : t = [] | _ :: _, [] -> assert false in - IList.rev (extract (IList.rev ial0) (IList.rev formals)) in + List.rev (extract (List.rev ial0) (List.rev formals)) in let annotated_signature = { ret = (ia, ret_type); params = natl } in annotated_signature diff --git a/infer/src/eradicate/eradicate.ml b/infer/src/eradicate/eradicate.ml index 6ea085e88..924f6e82b 100644 --- a/infer/src/eradicate/eradicate.ml +++ b/infer/src/eradicate/eradicate.ml @@ -251,7 +251,7 @@ struct final_typestates := (pname, final_typestate) :: !final_typestates | _, None -> () in List.iter ~f:get_final_typestate initializers_recursive; - IList.rev !final_typestates + List.rev !final_typestates let pname_and_pdescs_with f = let res = ref [] in @@ -265,7 +265,7 @@ struct res := (pname, pdesc) :: !res | None -> () in List.iter ~f:do_proc (get_procs_in_file curr_pname); - IList.rev !res + List.rev !res let get_class pn = match pn with | Procname.Java pn_java -> diff --git a/infer/src/eradicate/eradicateChecks.ml b/infer/src/eradicate/eradicateChecks.ml index ebdd447be..3ac38e1af 100644 --- a/infer/src/eradicate/eradicateChecks.ml +++ b/infer/src/eradicate/eradicateChecks.ml @@ -506,7 +506,7 @@ let check_call_parameters tenv Specs.get_summary callee_pname <> None in if should_check_parameters then (* left to right to avoid guessing the different lengths *) - check (IList.rev sig_params) (IList.rev call_params) + check (List.rev sig_params) (List.rev call_params) (** Checks if the annotations are consistent with the inherited class or with the implemented interfaces *) diff --git a/infer/src/eradicate/models.ml b/infer/src/eradicate/models.ml index 0c96f8e6c..d46ba7a2a 100644 --- a/infer/src/eradicate/models.ml +++ b/infer/src/eradicate/models.ml @@ -91,7 +91,7 @@ module Inference = struct | Some buf -> let boolvec = ref [] in String.iter ~f:(fun c -> boolvec := (Char.equal c '1') :: !boolvec) buf; - Some (IList.rev !boolvec) + Some (List.rev !boolvec) end (* Inference *) diff --git a/infer/src/eradicate/typeCheck.ml b/infer/src/eradicate/typeCheck.ml index 6a677d3d1..c0de05779 100644 --- a/infer/src/eradicate/typeCheck.ml +++ b/infer/src/eradicate/typeCheck.ml @@ -411,11 +411,11 @@ let typecheck_instr | fp:: tail when is_hidden_parameter fp -> 1 + drop_n_args tail | _ -> 0 in let n = drop_n_args proc_attributes.ProcAttributes.formals in - let visible_params = IList.drop_first n params in + let visible_params = List.drop params n in (* Drop the trailing hidden parameter if the constructor is synthetic. *) if proc_attributes.ProcAttributes.is_synthetic_method then - IList.drop_last 1 visible_params + List.take visible_params (List.length visible_params - 1) else visible_params end @@ -427,7 +427,9 @@ let typecheck_instr let drop_unchecked_signature_params proc_attributes annotated_signature = if Procname.is_constructor (proc_attributes.ProcAttributes.proc_name) && proc_attributes.ProcAttributes.is_synthetic_method then - IList.drop_last 1 annotated_signature.AnnotatedSignature.params + List.take + annotated_signature.AnnotatedSignature.params + (List.length annotated_signature.AnnotatedSignature.params - 1) else annotated_signature.AnnotatedSignature.params in diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index 9b93c2473..e56d7dc8f 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -242,7 +242,7 @@ let setup_harness_cfg harness_name env cg cfg = Cfg.create_proc_desc cfg proc_attributes in let harness_node = (* important to reverse the list or there will be scoping issues! *) - let instrs = (IList.rev env.instrs) in + let instrs = (List.rev env.instrs) in let nodekind = Procdesc.Node.Stmt_node "method_body" in Procdesc.create_node procdesc env.pc nodekind instrs in let (start_node, exit_node) = @@ -279,5 +279,5 @@ let inhabit_trace tenv trace harness_name cg cfg = trace in try setup_harness_cfg harness_name env'' cg cfg; - write_harness_to_file (IList.rev env''.instrs) harness_filename + write_harness_to_file (List.rev env''.instrs) harness_filename with Not_found -> () diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index d459d0fd2..c8eb2cc58 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -97,7 +97,7 @@ let run_compilation_database compilation_database should_capture_file = (** Computes the compilation database files. *) let get_compilation_database_files_buck () = - let cmd = List.rev_append Config.rest (IList.rev Config.buck_build_args) in + let cmd = List.rev_append Config.rest (List.rev Config.buck_build_args) in match cmd with | buck :: build :: args -> (check_args_for_targets args; diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index 783f35e8e..6050f2ba8 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -259,7 +259,7 @@ let load_from_arguments classes_out_path = let split cp_option = Option.value_map ~f:split_classpath ~default:[] cp_option in let combine path_list classpath = - List.fold ~f:append_path ~init:classpath (IList.rev path_list) in + List.fold ~f:append_path ~init:classpath (List.rev path_list) in let classpath = combine (split Config.classpath) "" |> combine (String.Set.elements roots) diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 91e850dce..d1efc27cb 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -100,7 +100,7 @@ let retrieve_fieldname fieldname = if Int.equal (List.length subs) 0 then assert false else - List.hd_exn (IList.rev subs) + List.last_exn subs with _ -> assert false @@ -133,7 +133,7 @@ let formals_from_signature program tenv cn ms kind = let init_arg_list = match kind with | Procname.Static -> [] | Procname.Non_Static -> [(JConfig.this, JTransType.get_class_type program tenv cn)] in - IList.rev (List.fold ~f:collect ~init:init_arg_list (JBasics.ms_args ms)) + List.rev (List.fold ~f:collect ~init:init_arg_list (JBasics.ms_args ms)) (** Creates the list of formal variables from a procedure based on ... *) let translate_formals program tenv cn impl = @@ -141,7 +141,7 @@ let translate_formals program tenv cn impl = let name = Mangled.from_string (JBir.var_name_g var) in let typ = JTransType.param_type program tenv cn var vt in (name, typ):: l in - IList.rev (List.fold ~f:collect ~init:[] (JBir.params impl)) + List.rev (List.fold ~f:collect ~init:[] (JBir.params impl)) (** Creates the list of local variables from the bytecode and add the variables from the JBir representation *) diff --git a/infer/src/java/jTransExn.ml b/infer/src/java/jTransExn.ml index 67353d0ae..7c721eca0 100644 --- a/infer/src/java/jTransExn.ml +++ b/infer/src/java/jTransExn.ml @@ -105,7 +105,7 @@ let translate_exceptions (context : JContext.t) exit_nodes get_body_nodes handle collect succ_nodes remove_temps handler in let nodes_first_handler = - List.fold ~f:process_handler ~init:exit_nodes (IList.rev handler_list) in + List.fold ~f:process_handler ~init:exit_nodes (List.rev handler_list) in let loc = match nodes_first_handler with | n:: _ -> Procdesc.Node.get_loc n | [] -> Location.dummy in diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index 569b1f82e..fdc85b0b6 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -90,7 +90,7 @@ let tests = else acc) astate.MockTaintAnalysis.Domain.access_tree [] in - PrettyPrintable.pp_collection ~pp_item fmt (IList.rev trace_assocs) in + PrettyPrintable.pp_collection ~pp_item fmt (List.rev trace_assocs) in let assign_to_source ret_str = let procname = Procname.from_string_c_fun "SOURCE" in make_call ~procname (Some (ident_of_str ret_str, dummy_typ)) [] in diff --git a/infer/src/unit/analyzerTester.ml b/infer/src/unit/analyzerTester.ml index 62c4d2436..d72752df4 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -268,7 +268,7 @@ module Make (CFG : ProcCfg.S with type node = Procdesc.Node.t) (T : TransferFunc let mismatches_str = F.pp_print_list (fun fmt error_msg -> F.fprintf fmt "%s" error_msg) F.str_formatter - (IList.rev error_msgs) + (List.rev error_msgs) |> F.flush_str_formatter in let assert_fail_message = F.fprintf F.str_formatter "Error while analyzing@.%a:@.%s@." diff --git a/infer/src/unit/clang/CiOSVersionNumbersTests.ml b/infer/src/unit/clang/CiOSVersionNumbersTests.ml index e11a5dfd8..ce5bc9a1f 100644 --- a/infer/src/unit/clang/CiOSVersionNumbersTests.ml +++ b/infer/src/unit/clang/CiOSVersionNumbersTests.ml @@ -15,7 +15,7 @@ let test_correct_ios_version = let output = CiOSVersionNumbers.version_of version in let cmp = fun s1 s2 -> Option.equal String.equal s1 s2 in assert_equal ~pp_diff:CiOSVersionNumbers.pp_diff_of_version_opt - ~cmp:cmp expected_version output in + ~cmp expected_version output in [ ( "test_correct_ios_version_some_version", diff --git a/infer/src/unit/procCfgTests.ml b/infer/src/unit/procCfgTests.ml index 6bef783bd..6d72d526b 100644 --- a/infer/src/unit/procCfgTests.ml +++ b/infer/src/unit/procCfgTests.ml @@ -48,7 +48,7 @@ let tests = let open OUnit2 in let cmp l1 l2 = - let sort = IList.sort Procdesc.Node.compare in + let sort = List.sort ~cmp:Procdesc.Node.compare in List.equal ~equal:Procdesc.Node.equal (sort l1) (sort l2) in let pp_diff fmt (actual, expected) = let pp_sep fmt _ = F.pp_print_char fmt ',' in diff --git a/infer/src/unit/schedulerTests.ml b/infer/src/unit/schedulerTests.ml index 33c05152c..ceb0448bc 100644 --- a/infer/src/unit/schedulerTests.ml +++ b/infer/src/unit/schedulerTests.ml @@ -78,7 +78,7 @@ let create_test test_graph expected_result _ = match S.pop q with | Some (n, _, q') -> pop_schedule_record (S.schedule_succs q' n) (n :: visited_acc) - | None -> IList.rev visited_acc in + | None -> List.rev visited_acc in let pp_diff fmt (exp, actual) = let pp_sched fmt l = F.pp_print_list ~pp_sep:F.pp_print_space (fun fmt i -> F.fprintf fmt "%d" i) fmt l in