Skip to content

Commit

Permalink
[stdlib] use Stdlib instead of Caml
Browse files Browse the repository at this point in the history
Summary:
`Caml` is deprecated going forward, the proper way to refer to the standard library is now `Stdlib`.

This is needed before upgrading to 5.2.

Reviewed By: geralt-encore

Differential Revision: D66230269

fbshipit-source-id: 57e4df99229fc7128201005fdaaac870019d25a7
  • Loading branch information
ngorogiannis authored and facebook-github-bot committed Nov 20, 2024
1 parent 1bc0366 commit f8c763e
Show file tree
Hide file tree
Showing 155 changed files with 387 additions and 383 deletions.
2 changes: 1 addition & 1 deletion infer/src/IR/ErlangTypeName.ml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ let calculate_hash atom =
*)
Md5.digest_string atom (* Compute md5 *)
|> Md5.to_binary |> Bytes.of_string (* Get the hash as bytes *)
|> Fn.flip Caml.Bytes.get_int64_be 0 (* Get the first 8 bytes as a big-endian int64 *)
|> Fn.flip Stdlib.Bytes.get_int64_be 0 (* Get the first 8 bytes as a big-endian int64 *)
|> Fn.flip Int64.shift_right_logical 8 (* Drop the last byte / keep the first 7 bytes only *)
|> Int64.to_int_exn (* Put in an integer, raising if it unexpectedly does not fit *)

Expand Down
6 changes: 3 additions & 3 deletions infer/src/IR/Exp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(** The Smallfoot Intermediate Language: Expressions *)

open! IStd
module Hashtbl = Caml.Hashtbl
module Hashtbl = Stdlib.Hashtbl
module F = Format
module L = Logging

Expand Down Expand Up @@ -53,11 +53,11 @@ and t =
| Sizeof of sizeof_data
[@@deriving compare, equal, hash, normalize]

module Set = Caml.Set.Make (struct
module Set = Stdlib.Set.Make (struct
type nonrec t = t [@@deriving compare]
end)

module Map = Caml.Map.Make (struct
module Map = Stdlib.Map.Make (struct
type nonrec t = t [@@deriving compare]
end)

Expand Down
6 changes: 3 additions & 3 deletions infer/src/IR/Exp.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ val equal : t -> t -> bool
(** Equality for expressions. *)

(** Set of expressions. *)
module Set : Caml.Set.S with type elt = t
module Set : Stdlib.Set.S with type elt = t

(** Map with expression keys. *)
module Map : Caml.Map.S with type key = t
module Map : Stdlib.Map.S with type key = t

(** Hashtable with expression keys. *)
module Hash : Caml.Hashtbl.S with type key = t
module Hash : Stdlib.Hashtbl.S with type key = t

val is_null_literal : t -> bool

Expand Down
10 changes: 5 additions & 5 deletions infer/src/IR/Ident.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(** Module for Names and Identifiers *)

open! IStd
module Hashtbl = Caml.Hashtbl
module Hashtbl = Stdlib.Hashtbl
module F = Format

module Name = struct
Expand Down Expand Up @@ -73,11 +73,11 @@ let equal i1 i2 =


(** {2 Set for identifiers} *)
module Set = Caml.Set.Make (struct
module Set = Stdlib.Set.Make (struct
type nonrec t = t [@@deriving compare]
end)

module Map = Caml.Map.Make (struct
module Map = Stdlib.Map.Make (struct
type nonrec t = t [@@deriving compare]
end)

Expand Down Expand Up @@ -128,7 +128,7 @@ module NameGenerator = struct
let stamp = NameHash.find !name_map name in
NameHash.replace !name_map name (stamp + 1) ;
stamp + 1
with Caml.Not_found ->
with Stdlib.Not_found ->
NameHash.add !name_map name 0 ;
0
in
Expand All @@ -141,7 +141,7 @@ module NameGenerator = struct
let curr_stamp = NameHash.find !name_map name in
let new_stamp = max curr_stamp stamp in
NameHash.replace !name_map name new_stamp
with Caml.Not_found -> NameHash.add !name_map name stamp
with Stdlib.Not_found -> NameHash.add !name_map name stamp
end

(** Name used for the return variable *)
Expand Down
4 changes: 2 additions & 2 deletions infer/src/IR/Ident.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ val equal_kind : kind -> kind -> bool
(** Equality for kind. *)

(** Set for identifiers. *)
module Set : Caml.Set.S with type elt = t
module Set : Stdlib.Set.S with type elt = t

(** Map with ident as key. *)
module Map : Caml.Map.S with type key = t
module Map : Stdlib.Map.S with type key = t

module HashQueue : Hash_queue.S with type key = t

Expand Down
8 changes: 4 additions & 4 deletions infer/src/IR/Procdesc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
*)

open! IStd
module Hashtbl = Caml.Hashtbl
module Hashtbl = Stdlib.Hashtbl
module L = Logging
module F = Format

module NodeKey = struct
type t = Caml.Digest.t
type t = Stdlib.Digest.t

let to_string = Caml.Digest.to_hex
let to_string = Stdlib.Digest.to_hex

let compute node ~simple_key ~succs ~preds =
let v = (simple_key node, List.rev_map ~f:simple_key succs, List.rev_map ~f:simple_key preds) in
Expand Down Expand Up @@ -483,7 +483,7 @@ end
(* =============== END of module Node =============== *)

(** Map over nodes *)
module NodeMap = Caml.Map.Make (Node)
module NodeMap = Stdlib.Map.Make (Node)

(** Hash table with nodes as keys. *)
module NodeHash = Hashtbl.Make (Node)
Expand Down
4 changes: 2 additions & 2 deletions infer/src/IR/Procdesc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ end
module IdMap : PrettyPrintable.PPMap with type key = Node.id

(** Hash table with nodes as keys. *)
module NodeHash : Caml.Hashtbl.S with type key = Node.t
module NodeHash : Stdlib.Hashtbl.S with type key = Node.t

(** Hash set with nodes as keys. *)
module NodeHashSet : HashSet.S with type elt = Node.t

(** Map over nodes. *)
module NodeMap : Caml.Map.S with type key = Node.t
module NodeMap : Stdlib.Map.S with type key = Node.t

(** Set of nodes. *)
module NodeSet : PrettyPrintable.PPSet with type elt = Node.t
Expand Down
4 changes: 2 additions & 2 deletions infer/src/IR/Procname.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*)

open! IStd
module Hashtbl = Caml.Hashtbl
module Hashtbl = Stdlib.Hashtbl
module F = Format
module L = Logging

Expand Down Expand Up @@ -1177,7 +1177,7 @@ let replace_regex regex tgt name =
match Str.search_forward regex name 0 with
| _ ->
Str.global_replace regex tgt name
| exception Caml.Not_found ->
| exception Stdlib.Not_found ->
name


Expand Down
2 changes: 1 addition & 1 deletion infer/src/IR/Procname.mli
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ include module type of struct
end

(** Hash tables with proc names as keys. *)
module Hash : Caml.Hashtbl.S with type key = t
module Hash : Stdlib.Hashtbl.S with type key = t

module LRUHash : LRUHashtbl.S with type key = t

Expand Down
6 changes: 3 additions & 3 deletions infer/src/IR/SourceFiles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ let add source_file cfg tenv integer_type_widths =
source_file ;
(* merge the proc names defined in the source file using a hashtbl so that order is
preserved but merging is still linear time *)
let existing_proc_names = Caml.Hashtbl.create (List.length old_proc_names) in
let existing_proc_names = Stdlib.Hashtbl.create (List.length old_proc_names) in
List.iter old_proc_names ~f:(fun proc_name ->
Caml.Hashtbl.add existing_proc_names proc_name () ) ;
Stdlib.Hashtbl.add existing_proc_names proc_name () ) ;
let proc_names =
List.fold new_proc_names ~init:old_proc_names ~f:(fun proc_names proc_name ->
if not (Caml.Hashtbl.mem existing_proc_names proc_name) then proc_name :: proc_names
if not (Stdlib.Hashtbl.mem existing_proc_names proc_name) then proc_name :: proc_names
else proc_names )
in
(Tenv.merge_per_file ~dst:old_tenv ~src:tenv, proc_names)
Expand Down
8 changes: 4 additions & 4 deletions infer/src/IR/SpecializeProcdesc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let convert_cfg ~callee_pdesc ~resolved_pdesc ~f_instr_list =
| node :: other_node ->
let converted_node =
try Procdesc.NodeMap.find node !node_map
with Caml.Not_found ->
with Stdlib.Not_found ->
let new_node = convert_node node
and successors = Procdesc.Node.get_succs node
and exn_nodes = Procdesc.Node.get_exn node in
Expand Down Expand Up @@ -59,7 +59,7 @@ let with_formals_types_proc callee_pdesc resolved_pdesc substitutions =
in
let subst_map = ref Ident.Map.empty in
let redirect_typename origin_id =
try Some (Ident.Map.find origin_id !subst_map) with Caml.Not_found -> None
try Some (Ident.Map.find origin_id !subst_map) with Stdlib.Not_found -> None
in
let convert_instr = function
| Sil.Load
Expand All @@ -69,7 +69,7 @@ let with_formals_types_proc callee_pdesc resolved_pdesc substitutions =
; loc } ->
let specialized_typname =
try Mangled.Map.find (Pvar.get_name origin_pvar) substitutions
with Caml.Not_found -> origin_typename
with Stdlib.Not_found -> origin_typename
in
subst_map := Ident.Map.add id specialized_typname !subst_map ;
let typ = mk_ptr_typ specialized_typname in
Expand All @@ -78,7 +78,7 @@ let with_formals_types_proc callee_pdesc resolved_pdesc substitutions =
{id; e= Exp.Var origin_id as origin_exp; typ= {Typ.desc= Tstruct _} as origin_typ; loc} ->
let updated_typ : Typ.t =
try Typ.mk ~default:origin_typ (Tstruct (Ident.Map.find origin_id !subst_map))
with Caml.Not_found -> origin_typ
with Stdlib.Not_found -> origin_typ
in
Some (Sil.Load {id; e= convert_exp origin_exp; typ= updated_typ; loc})
| Sil.Load {id; e= origin_exp; typ; loc} ->
Expand Down
4 changes: 2 additions & 2 deletions infer/src/IR/Subtype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let check_subclass_tenv tenv c1 c2 : result =
if is_root_class c2 then Yes else check c1


module SubtypesMap = Caml.Map.Make (struct
module SubtypesMap = Stdlib.Map.Make (struct
(* pair of subtypes *)
type t = Typ.Name.t * Typ.Name.t [@@deriving compare]
end)
Expand All @@ -83,7 +83,7 @@ let check_subtype =
let subtMap = ref SubtypesMap.empty in
fun tenv c1 c2 : result ->
try SubtypesMap.find (c1, c2) !subtMap
with Caml.Not_found ->
with Stdlib.Not_found ->
let is_subt = check_subclass_tenv tenv c1 c2 in
subtMap := SubtypesMap.add (c1, c2) is_subt !subtMap ;
is_subt
Expand Down
6 changes: 3 additions & 3 deletions infer/src/IR/Tenv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open Option.Monad_infix
(** Module for Type Environments. *)

(** Hash tables on type names. *)
module TypenameHash = Caml.Hashtbl.Make (Typ.Name)
module TypenameHash = Stdlib.Hashtbl.Make (Typ.Name)

(** Type for type environment. *)
type t = Struct.t TypenameHash.t
Expand Down Expand Up @@ -47,7 +47,7 @@ let mk_struct tenv ?default ?fields ?statics ?methods ?exported_objc_methods ?su
let lookup tenv name : Struct.t option =
let result =
try Some (TypenameHash.find tenv name)
with Caml.Not_found -> (
with Stdlib.Not_found -> (
(* ToDo: remove the following additional lookups once C/C++ interop is resolved *)
match (name : Typ.Name.t) with
| CStruct m ->
Expand Down Expand Up @@ -175,7 +175,7 @@ let get_parent tenv name =


let get_fields_trans =
let module Fields = Caml.Set.Make (struct
let module Fields = Stdlib.Set.Make (struct
type t = Struct.field

let compare {Struct.name= x} {Struct.name= y} =
Expand Down
2 changes: 1 addition & 1 deletion infer/src/IR/Typ.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(** The Smallfoot Intermediate Language: Types *)

open! IStd
module Hashtbl = Caml.Hashtbl
module Hashtbl = Stdlib.Hashtbl
module L = Logging
module F = Format

Expand Down
2 changes: 1 addition & 1 deletion infer/src/IR/Typ.mli
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ module Name : sig

module Map : PrettyPrintable.PPMap with type key = t

module Hash : Caml.Hashtbl.S with type key = t
module Hash : Stdlib.Hashtbl.S with type key = t
end

val equal : t -> t -> bool
Expand Down
2 changes: 1 addition & 1 deletion infer/src/IR/WeakTopologicalOrder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ module Bourdoncle_SCC (CFG : PreProcCfg) = struct
current strictly connected component.
*)
record_head node_dfn
| exception (Not_found_s _ | Caml.Not_found) ->
| exception (Not_found_s _ | Stdlib.Not_found) ->
push_on_stack node
in
let rec process_stack partition =
Expand Down
6 changes: 3 additions & 3 deletions infer/src/IR/inferconfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module FileContainsStringMatcher = struct
let file_contains regexp regexp_not_opt source_file =
let rec loop regexp file_in =
try Str.search_forward regexp (In_channel.input_line_exn file_in) 0 >= 0 with
| Caml.Not_found ->
| Stdlib.Not_found ->
loop regexp file_in
| End_of_file ->
false
Expand Down Expand Up @@ -120,7 +120,7 @@ module FileOrProcMatcher = struct
~f:(fun map pattern ->
let previous =
try String.Map.find_exn map pattern.class_name
with Not_found_s _ | Caml.Not_found -> []
with Not_found_s _ | Stdlib.Not_found -> []
in
String.Map.set ~key:pattern.class_name ~data:(pattern :: previous) map )
~init:String.Map.empty m_patterns
Expand All @@ -134,7 +134,7 @@ module FileOrProcMatcher = struct
~f:(fun p ->
match p.method_name with None -> true | Some m -> String.equal m method_name )
class_patterns
with Not_found_s _ | Caml.Not_found -> false
with Not_found_s _ | Stdlib.Not_found -> false
in
fun _ proc_name ->
match proc_name with Procname.Java pname_java -> do_java pname_java | _ -> false
Expand Down
4 changes: 2 additions & 2 deletions infer/src/absint/AbstractDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ module MapOfPPMap (M : PrettyPrintable.PPMap) (ValueDomain : S) = struct
else
M.for_all
(fun k lhs_v ->
try ValueDomain.leq ~lhs:lhs_v ~rhs:(M.find k rhs) with Caml.Not_found -> false )
try ValueDomain.leq ~lhs:lhs_v ~rhs:(M.find k rhs) with Stdlib.Not_found -> false )
lhs


Expand Down Expand Up @@ -665,7 +665,7 @@ module InvertedMap (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : S
if phys_equal lhs rhs then true
else
try for_all (fun k rhs_v -> ValueDomain.leq ~lhs:(find k lhs) ~rhs:rhs_v) rhs
with Caml.Not_found -> false
with Stdlib.Not_found -> false


let inter ~f astate1 astate2 =
Expand Down
2 changes: 1 addition & 1 deletion infer/src/absint/AbstractDomain.mli
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ end
module MinReprSet (Element : PrettyPrintable.PrintableOrderedType) : sig
type elt = Element.t

include Caml.Set.OrderedType
include Stdlib.Set.OrderedType

include WithBottom with type t := t

Expand Down
4 changes: 2 additions & 2 deletions infer/src/absint/AbstractInterpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ module AbstractInterpreterCommon (TransferFunctions : NodeTransferFunctions) = s
Ok post
with exn ->
(* delay reraising to get a chance to write the debug HTML *)
let backtrace = Caml.Printexc.get_raw_backtrace () in
let backtrace = Stdlib.Printexc.get_raw_backtrace () in
Error (exn, backtrace, instr) )
in
match result with
Expand All @@ -639,7 +639,7 @@ module AbstractInterpreterCommon (TransferFunctions : NodeTransferFunctions) = s
(Sil.pp_instr ~print_types:true Pp.text)
instr ;
logged_error := true ) ) ;
Caml.Printexc.raise_with_backtrace exn backtrace
Stdlib.Printexc.raise_with_backtrace exn backtrace
in
(* hack to ensure that we call [exec_instr] on a node even if it has no instructions *)
let instrs = if Instrs.is_empty instrs then Instrs.singleton Sil.skip_instr else instrs in
Expand Down
Loading

0 comments on commit f8c763e

Please sign in to comment.