diff --git a/infer/src/backend/clusterMakefile.ml b/infer/src/backend/clusterMakefile.ml index d863aac7c..9fc7916e3 100644 --- a/infer/src/backend/clusterMakefile.ml +++ b/infer/src/backend/clusterMakefile.ml @@ -17,7 +17,8 @@ module CLOpt = CommandLineOption let cluster_should_be_analyzed cluster = let fname = DB.source_dir_to_string cluster in - let in_ondemand_config = Option.map ~f:(StringSet.mem fname) Ondemand.dirs_to_analyze in + let in_ondemand_config = + Option.map ~f:(fun dirs -> String.Set.mem dirs fname) Ondemand.dirs_to_analyze in let check_modified () = let modified = DB.file_was_updated_after_start (DB.filename_from_string fname) in diff --git a/infer/src/backend/mergeCapture.ml b/infer/src/backend/mergeCapture.ml index e332cd824..9711e37e7 100644 --- a/infer/src/backend/mergeCapture.ml +++ b/infer/src/backend/mergeCapture.ml @@ -24,12 +24,11 @@ let buck_out () = Filename.concat Config.project_root "buck-out" let infer_deps () = Filename.concat Config.results_dir Config.buck_infer_deps_file_name -let modified_targets = ref StringSet.empty +let modified_targets = ref String.Set.empty let modified_file file = match Utils.read_file file with | Some targets -> - modified_targets := - IList.fold_left (fun s target -> StringSet.add target s) StringSet.empty targets + modified_targets := IList.fold_left String.Set.add String.Set.empty targets | None -> () @@ -167,7 +166,7 @@ let should_link ~target ~target_results_dir ~stats infer_out_src infer_out_dst = else true in let was_modified () = - StringSet.mem target !modified_targets in + String.Set.mem !modified_targets target in let r = was_modified () || not (was_copied ()) in diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 5869ad663..9f5febe6d 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -20,9 +20,9 @@ let dirs_to_analyze = SourceFile.Set.fold (fun source_file source_dir_set -> let source_dir = DB.source_dir_from_source_file source_file in - StringSet.add (DB.source_dir_to_string source_dir) source_dir_set + String.Set.add source_dir_set (DB.source_dir_to_string source_dir) ) - changed_files StringSet.empty in + changed_files String.Set.empty in Option.map ~f:process_changed_files SourceFile.changed_files_set type analyze_ondemand = SourceFile.t -> Procdesc.t -> unit diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index e9a06d357..c19c28100 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -12,7 +12,7 @@ open! Utils (** Module for on-demand analysis. *) (** Optional set of source dirs to analyze in on-demand mode. *) -val dirs_to_analyze : StringSet.t option +val dirs_to_analyze : String.Set.t option type analyze_ondemand = SourceFile.t -> Procdesc.t -> unit diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 638d82237..1996d809d 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -457,9 +457,9 @@ let create_table_err_per_line err_log = (pp_to_string Localise.pp_error_desc desc) in try let set = Hashtbl.find err_per_line loc.Location.line in - Hashtbl.replace err_per_line loc.Location.line (StringSet.add err_str set) + Hashtbl.replace err_per_line loc.Location.line (String.Set.add set err_str) with Not_found -> - Hashtbl.add err_per_line loc.Location.line (StringSet.singleton err_str) in + Hashtbl.add err_per_line loc.Location.line (String.Set.singleton err_str) in Errlog.iter add_err err_log; err_per_line @@ -520,7 +520,7 @@ let write_html_file linereader filename procs = let errors_at_linenum = try let errset = Hashtbl.find table_err_per_line line_number in - StringSet.elements errset + String.Set.elements errset with Not_found -> [] in let linenum_str = string_of_int line_number in let line_str = "LINE" ^ linenum_str in diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 6d6a4602d..f126bca3d 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -90,28 +90,6 @@ module IntSet = Set.Make(Int) (** Hash table over strings *) module StringHash = Hashtbl.Make (String) -(** Set of strings *) -module StringSet = Set.Make(String) - -(** Pretty print a set of strings *) -let pp_stringset fmt ss = - StringSet.iter (fun s -> F.fprintf fmt "%s " s) ss - -(** string list -> StringSet.t - from http://stackoverflow.com/a/2382330 *) -let string_set_of_list list = - IList.fold_left (fun acc x -> StringSet.add x acc) StringSet.empty list - -(** intersection of two string lists, as a StringSet.t - from http://stackoverflow.com/a/2382330 *) -let string_list_intersection a b = - StringSet.inter (string_set_of_list a) (string_set_of_list b) - -module StringPPSet = PrettyPrintable.MakePPSet(struct - include String - let pp_element fmt s = F.fprintf fmt "%s" s - end) - (** Maps from integers *) module IntMap = Map.Make (Int) diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index c6b134eea..b931770f4 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -78,21 +78,6 @@ module IntSet : Set.S with type elt = int (** Hash table over strings *) module StringHash : Hashtbl.S with type key = string -(** Set of strings *) -module StringSet : Set.S with type elt = string - -(** Pretty Printable Set of strings *) -module StringPPSet : PrettyPrintable.PPSet with type elt = string - -(** Pretty print a set of strings *) -val pp_stringset : Format.formatter -> StringSet.t -> unit - -(** list of strings -> set of strings *) -val string_set_of_list : string list -> StringSet.t - -(** List intersection *) -val string_list_intersection : string list -> string list -> StringSet.t - (** Maps from integers *) module IntMap : Map.S with type key = int diff --git a/infer/src/clang/cFrontend_utils.ml b/infer/src/clang/cFrontend_utils.ml index 7581357c2..9a405007c 100644 --- a/infer/src/clang/cFrontend_utils.ml +++ b/infer/src/clang/cFrontend_utils.ml @@ -413,7 +413,7 @@ struct let rec is_objc_if_descendant ?(blacklist = default_blacklist) if_decl ancestors = (* List of ancestors to check for and list of classes to short-circuit to false can't intersect *) - if not (StringSet.is_empty (string_list_intersection blacklist ancestors)) then + if not String.Set.(is_empty (inter (of_list blacklist) (of_list ancestors))) then failwith "Blacklist and ancestors must be mutually exclusive." else match if_decl with diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index 597c7b08e..29a8c5c8f 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -743,7 +743,7 @@ let var_or_zero_in_init_list tenv e typ ~return_zero:return_zero = let exp = if return_zero then Sil.zero_value_of_numerical_type typ else e in [ [(exp, typ)] ] | Typ.Tfun _ | Typ.Tvoid | Typ.Tarray _ -> assert false in - IList.flatten (var_or_zero_in_init_list' e typ StringSet.empty) + IList.flatten (var_or_zero_in_init_list' e typ String.Set.empty) (* (** Similar to extract_item_from_singleton but for option type *) diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index a59793d6f..9fb2bb9ce 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -14,7 +14,7 @@ open Javalib_pack module L = Logging -let models_specs_filenames = ref StringSet.empty +let models_specs_filenames = ref String.Set.empty let models_jar = ref "" @@ -50,7 +50,7 @@ let collect_specs_filenames jar_filename = if not (Filename.check_suffix filename Config.specs_files_suffix) then set else let proc_filename = (Filename.chop_extension (Filename.basename filename)) in - StringSet.add proc_filename set in + String.Set.add set proc_filename in models_specs_filenames := IList.fold_left collect !models_specs_filenames (Zip.entries zip_channel); models_tenv := load_models_tenv zip_channel; @@ -66,7 +66,7 @@ let add_models jar_filename = let is_model procname = - StringSet.mem (Procname.to_filename procname) !models_specs_filenames + String.Set.mem !models_specs_filenames (Procname.to_filename procname) let split_classpath cp = Str.split (Str.regexp JFile.sep) cp @@ -141,8 +141,7 @@ let add_source_file path map = let add_root_path path roots = - if StringSet.mem path roots then roots - else StringSet.add path roots + String.Set.add roots path let load_from_verbose_output () = @@ -183,9 +182,9 @@ let load_from_verbose_output () = IList.fold_left append_path "" - ((StringSet.elements roots) @ paths) in + ((String.Set.elements roots) @ paths) in (classpath, sources, classes) in - loop [] StringSet.empty StringMap.empty JBasics.ClassSet.empty + loop [] String.Set.empty StringMap.empty JBasics.ClassSet.empty let classname_of_class_filename class_filename = @@ -225,7 +224,7 @@ let search_classes path = else if Filename.check_suffix p "jar" then (add_root_path p paths, collect_classnames classes p) else accu) - (StringSet.empty, JBasics.ClassSet.empty) + (String.Set.empty, JBasics.ClassSet.empty) path @@ -255,7 +254,7 @@ let load_from_arguments classes_out_path = IList.fold_left append_path classpath (IList.rev path_list) in let classpath = combine (split Config.classpath) "" - |> combine (StringSet.elements roots) + |> combine (String.Set.elements roots) |> combine (split Config.bootclasspath) in (classpath, search_sources (), classes)