diff --git a/infer/src/IR/AttributesTable.re b/infer/src/IR/AttributesTable.re index bc4bb5ae2..f8242ecb0 100644 --- a/infer/src/IR/AttributesTable.re +++ b/infer/src/IR/AttributesTable.re @@ -39,7 +39,7 @@ let attributes_filename proc_kind::proc_kind pname_file => { /** path to the .attr file for the given procedure in the current results directory */ let res_dir_attr_filename proc_kind::proc_kind pname => { - let pname_file = Procname.to_filename pname; + let pname_file = Typ.Procname.to_filename pname; let attr_fname = attributes_filename proc_kind::proc_kind pname_file; let bucket_dir = { let base = pname_file; @@ -154,19 +154,19 @@ let store_attributes (proc_attributes: ProcAttributes.t) => { } }; -let attr_tbl = Procname.Hash.create 16; +let attr_tbl = Typ.Procname.Hash.create 16; -let defined_attr_tbl = Procname.Hash.create 16; +let defined_attr_tbl = Typ.Procname.Hash.create 16; let load_attributes proc_name => - try (Procname.Hash.find attr_tbl proc_name) { + try (Typ.Procname.Hash.find attr_tbl proc_name) { | Not_found => let proc_attributes = load_attr defined_only::false proc_name; switch proc_attributes { | Some attrs => - Procname.Hash.add attr_tbl proc_name proc_attributes; + Typ.Procname.Hash.add attr_tbl proc_name proc_attributes; if attrs.is_defined { - Procname.Hash.add defined_attr_tbl proc_name proc_attributes + Typ.Procname.Hash.add defined_attr_tbl proc_name proc_attributes } | None => () }; @@ -174,15 +174,15 @@ let load_attributes proc_name => }; let load_defined_attributes cache_none::cache_none proc_name => - try (Procname.Hash.find defined_attr_tbl proc_name) { + try (Typ.Procname.Hash.find defined_attr_tbl proc_name) { | Not_found => let proc_attributes = load_attr defined_only::true proc_name; if (proc_attributes != None) { /* procedure just got defined, replace attribute in attr_tbl with defined version */ - Procname.Hash.replace attr_tbl proc_name proc_attributes; - Procname.Hash.add defined_attr_tbl proc_name proc_attributes + Typ.Procname.Hash.replace attr_tbl proc_name proc_attributes; + Typ.Procname.Hash.add defined_attr_tbl proc_name proc_attributes } else if cache_none { - Procname.Hash.add defined_attr_tbl proc_name proc_attributes + Typ.Procname.Hash.add defined_attr_tbl proc_name proc_attributes }; proc_attributes }; @@ -193,7 +193,7 @@ let load_defined_attributes cache_none::cache_none proc_name => corresponds to the class definition. */ let get_correct_type_from_objc_class_name type_name => /* ToDo: this function should return a type that includes a reference to the tenv computed by: - let class_method = Procname.get_default_objc_class_method (Typename.name type_name); + let class_method = Typ.Procname.get_default_objc_class_method (Typename.name type_name); switch (find_tenv_from_class_of_proc class_method) { | Some tenv => */ @@ -246,7 +246,7 @@ let aggregate s => { }; let stats () => { - let stats = Procname.Hash.stats attr_tbl; + let stats = Typ.Procname.Hash.stats attr_tbl; let {Hashtbl.num_bindings: num_bindings, num_buckets, max_bucket_length} = stats; let serialized_size_kb = Config.developer_mode ? diff --git a/infer/src/IR/AttributesTable.rei b/infer/src/IR/AttributesTable.rei index 1f5dd0a49..e82058308 100644 --- a/infer/src/IR/AttributesTable.rei +++ b/infer/src/IR/AttributesTable.rei @@ -16,11 +16,11 @@ let store_attributes: ProcAttributes.t => unit; /** Load the attributes for the procedure from the attributes database. */ -let load_attributes: Procname.t => option ProcAttributes.t; +let load_attributes: Typ.Procname.t => option ProcAttributes.t; /** Load attrubutes for the procedure but only if is_defined is true */ -let load_defined_attributes: cache_none::bool => Procname.t => option ProcAttributes.t; +let load_defined_attributes: cache_none::bool => Typ.Procname.t => option ProcAttributes.t; /** Given the name of an ObjC class, extract the type from the tenv where the class was defined. We @@ -31,7 +31,8 @@ let get_correct_type_from_objc_class_name: Typename.t => option Typ.t; /* Find the file where the procedure was captured, if a cfg for that file exists. Return also a boolean indicating whether the procedure is defined in an include file. */ -let find_file_capturing_procedure: Procname.t => option (SourceFile.t, [ | `Include | `Source]); +let find_file_capturing_procedure: + Typ.Procname.t => option (SourceFile.t, [ | `Include | `Source]); type t; diff --git a/infer/src/IR/BuiltinDecl.ml b/infer/src/IR/BuiltinDecl.ml index 2a3e68dbf..0178d2787 100644 --- a/infer/src/IR/BuiltinDecl.ml +++ b/infer/src/IR/BuiltinDecl.ml @@ -9,26 +9,26 @@ open! IStd -type t = Procname.t +type t = Typ.Procname.t -let builtin_decls = ref Procname.Set.empty +let builtin_decls = ref Typ.Procname.Set.empty let register pname = - builtin_decls := Procname.Set.add pname !builtin_decls + builtin_decls := Typ.Procname.Set.add pname !builtin_decls let create_procname name = - let pname = Procname.from_string_c_fun name in + let pname = Typ.Procname.from_string_c_fun name in register pname; pname let create_objc_class_method class_name method_name = - let method_kind = Procname.ObjCClassMethod in + let method_kind = Typ.Procname.ObjCClassMethod in let tname = Typename.Objc.from_string class_name in - let pname = Procname.ObjC_Cpp (Procname.objc_cpp tname method_name method_kind) in + let pname = Typ.Procname.ObjC_Cpp (Typ.Procname.objc_cpp tname method_name method_kind) in register pname; pname -let is_declared pname = Procname.Set.mem pname !builtin_decls +let is_declared pname = Typ.Procname.Set.mem pname !builtin_decls let __assert_fail = create_procname "__assert_fail" let __builtin_va_arg = create_procname "__builtin_va_arg" diff --git a/infer/src/IR/BuiltinDecl.mli b/infer/src/IR/BuiltinDecl.mli index 5e160b3a6..9a05396be 100644 --- a/infer/src/IR/BuiltinDecl.mli +++ b/infer/src/IR/BuiltinDecl.mli @@ -10,6 +10,6 @@ open! IStd (** Procnames for the builtin functions supported *) -include BUILTINS.S with type t = Procname.t +include BUILTINS.S with type t = Typ.Procname.t -val is_declared : Procname.t -> bool +val is_declared : Typ.Procname.t -> bool diff --git a/infer/src/IR/CallFlags.re b/infer/src/IR/CallFlags.re index 0ab25af10..d37b13b20 100644 --- a/infer/src/IR/CallFlags.re +++ b/infer/src/IR/CallFlags.re @@ -22,7 +22,7 @@ type t = { cf_interface: bool, cf_noreturn: bool, cf_is_objc_block: bool, - cf_targets: list Procname.t + cf_targets: list Typ.Procname.t } [@@deriving compare]; diff --git a/infer/src/IR/CallFlags.rei b/infer/src/IR/CallFlags.rei index 68e0d7a34..1fa455e5c 100644 --- a/infer/src/IR/CallFlags.rei +++ b/infer/src/IR/CallFlags.rei @@ -22,7 +22,7 @@ type t = { cf_interface: bool, cf_noreturn: bool, cf_is_objc_block: bool, - cf_targets: list Procname.t + cf_targets: list Typ.Procname.t } [@@deriving compare]; diff --git a/infer/src/IR/CallSite.ml b/infer/src/IR/CallSite.ml index 208d6eca0..9598b85a4 100644 --- a/infer/src/IR/CallSite.ml +++ b/infer/src/IR/CallSite.ml @@ -13,7 +13,7 @@ module F = Format type t = { - pname : Procname.t; + pname : Typ.Procname.t; loc : Location.t; } [@@deriving compare] @@ -30,10 +30,10 @@ let make pname loc = { pname; loc; } let dummy = - make Procname.empty_block Location.dummy + make Typ.Procname.empty_block Location.dummy let pp fmt t = - F.fprintf fmt "%a at %a" Procname.pp t.pname Location.pp t.loc + F.fprintf fmt "%a at %a" Typ.Procname.pp t.pname Location.pp t.loc module Set = PrettyPrintable.MakePPSet(struct type nonrec t = t diff --git a/infer/src/IR/CallSite.mli b/infer/src/IR/CallSite.mli index 2841fa6b3..0bdb69eab 100644 --- a/infer/src/IR/CallSite.mli +++ b/infer/src/IR/CallSite.mli @@ -15,11 +15,11 @@ type t [@@deriving compare] val equal : t -> t -> bool -val pname : t -> Procname.t +val pname : t -> Typ.Procname.t val loc : t -> Location.t -val make : Procname.t -> Location.t -> t +val make : Typ.Procname.t -> Location.t -> t val dummy : t diff --git a/infer/src/IR/Cfg.re b/infer/src/IR/Cfg.re index 7bea12d62..29f592653 100644 --- a/infer/src/IR/Cfg.re +++ b/infer/src/IR/Cfg.re @@ -15,20 +15,20 @@ let module F = Format; /** data type for the control flow graph */ -type cfg = {proc_desc_table: Procname.Hash.t Procdesc.t /** Map proc name to procdesc */}; +type cfg = {proc_desc_table: Typ.Procname.Hash.t Procdesc.t /** Map proc name to procdesc */}; /** create a new empty cfg */ -let create_cfg () => {proc_desc_table: Procname.Hash.create 16}; +let create_cfg () => {proc_desc_table: Typ.Procname.Hash.create 16}; -let add_proc_desc cfg pname pdesc => Procname.Hash.add cfg.proc_desc_table pname pdesc; +let add_proc_desc cfg pname pdesc => Typ.Procname.Hash.add cfg.proc_desc_table pname pdesc; -let remove_proc_desc cfg pname => Procname.Hash.remove cfg.proc_desc_table pname; +let remove_proc_desc cfg pname => Typ.Procname.Hash.remove cfg.proc_desc_table pname; -let iter_proc_desc cfg f => Procname.Hash.iter f cfg.proc_desc_table; +let iter_proc_desc cfg f => Typ.Procname.Hash.iter f cfg.proc_desc_table; let find_proc_desc_from_name cfg pname => - try (Some (Procname.Hash.find cfg.proc_desc_table pname)) { + try (Some (Typ.Procname.Hash.find cfg.proc_desc_table pname)) { | Not_found => None }; @@ -48,7 +48,7 @@ let iter_all_nodes sorted::sorted=false f cfg => { if (not sorted) { iter_proc_desc cfg do_proc_desc } else { - Procname.Hash.fold + Typ.Procname.Hash.fold ( fun _ pdesc desc_nodes => List.fold @@ -105,7 +105,7 @@ let check_cfg_connectedness cfg => { } }; let do_pdesc pd => { - let pname = Procname.to_string (Procdesc.get_proc_name pd); + let pname = Typ.Procname.to_string (Procdesc.get_proc_name pd); let nodes = Procdesc.get_nodes pd; let broken = List.exists f::broken_node nodes; if broken { @@ -212,7 +212,7 @@ let proc_inline_synthetic_methods cfg pdesc :unit => { | Sil.Call ret_id (Exp.Const (Const.Cfun pn)) etl loc _ => switch (find_proc_desc_from_name cfg pn) { | Some pd => - let is_access = Procname.java_is_access_method pn; + let is_access = Typ.Procname.java_is_access_method pn; let attributes = Procdesc.get_attributes pd; let is_synthetic = attributes.is_synthetic_method; let is_bridge = attributes.is_bridge_method; @@ -246,7 +246,7 @@ let proc_inline_synthetic_methods cfg pdesc :unit => { /** Inline the java synthetic methods in the cfg */ let inline_java_synthetic_methods cfg => { let f pname pdesc => - if (Procname.is_java pname) { + if (Typ.Procname.is_java pname) { proc_inline_synthetic_methods cfg pdesc }; iter_proc_desc cfg f @@ -310,7 +310,7 @@ let mark_unchanged_pdescs cfg_new cfg_old => { let new_procs = cfg_new.proc_desc_table; let mark_pdesc_if_unchanged pname (new_pdesc: Procdesc.t) => try { - let old_pdesc = Procname.Hash.find old_procs pname; + let old_pdesc = Typ.Procname.Hash.find old_procs pname; let changed = /* in continue_capture mode keep the old changed bit */ Config.continue_capture && (Procdesc.get_attributes old_pdesc).changed || @@ -319,7 +319,7 @@ let mark_unchanged_pdescs cfg_new cfg_old => { } { | Not_found => () }; - Procname.Hash.iter mark_pdesc_if_unchanged new_procs + Typ.Procname.Hash.iter mark_pdesc_if_unchanged new_procs }; @@ -388,7 +388,7 @@ let specialize_types_proc callee_pdesc resolved_pdesc substitutions => { } | Sil.Call return_ids - (Exp.Const (Const.Cfun (Procname.Java callee_pname_java))) + (Exp.Const (Const.Cfun (Typ.Procname.Java callee_pname_java))) [(Exp.Var id, _), ...origin_args] loc call_flags @@ -396,7 +396,7 @@ let specialize_types_proc callee_pdesc resolved_pdesc substitutions => { let redirected_typename = Option.value_exn (redirect_typename id); let redirected_typ = mk_ptr_typ redirected_typename; let redirected_pname = - Procname.replace_class (Procname.Java callee_pname_java) redirected_typename; + Typ.Procname.replace_class (Typ.Procname.Java callee_pname_java) redirected_typename; let args = { let other_args = List.map f::(fun (exp, typ) => (convert_exp exp, typ)) origin_args; [(Exp.Var id, redirected_typ), ...other_args] diff --git a/infer/src/IR/Cfg.rei b/infer/src/IR/Cfg.rei index 3fd8ab523..5fdfa5f9c 100644 --- a/infer/src/IR/Cfg.rei +++ b/infer/src/IR/Cfg.rei @@ -35,11 +35,11 @@ let create_proc_desc: cfg => ProcAttributes.t => Procdesc.t; /** Iterate over all the procdesc's */ -let iter_proc_desc: cfg => (Procname.t => Procdesc.t => unit) => unit; +let iter_proc_desc: cfg => (Typ.Procname.t => Procdesc.t => unit) => unit; /** Find the procdesc given the proc name. Return None if not found. */ -let find_proc_desc_from_name: cfg => Procname.t => option Procdesc.t; +let find_proc_desc_from_name: cfg => Typ.Procname.t => option Procdesc.t; /** Get all the procedures (defined and declared) */ @@ -59,13 +59,13 @@ let check_cfg_connectedness: cfg => unit; /** Remove the procdesc from the control flow graph. */ -let remove_proc_desc: cfg => Procname.t => unit; +let remove_proc_desc: cfg => Typ.Procname.t => unit; /** Creates a copy of a procedure description and a list of type substitutions of the form (name, typ) where name is a parameter. The resulting procdesc is isomorphic but all the type of the parameters are replaced in the instructions according to the list. The virtual calls are also replaced to match the parameter types */ -let specialize_types: Procdesc.t => Procname.t => list (Exp.t, Typ.t) => Procdesc.t; +let specialize_types: Procdesc.t => Typ.Procname.t => list (Exp.t, Typ.t) => Procdesc.t; let pp_proc_signatures: Format.formatter => cfg => unit; diff --git a/infer/src/IR/Cg.re b/infer/src/IR/Cg.re index 85f078bb5..798cb2dcf 100644 --- a/infer/src/IR/Cg.re +++ b/infer/src/IR/Cg.re @@ -17,7 +17,7 @@ let module L = Logging; let module F = Format; -type node = Procname.t; +type node = Typ.Procname.t; type in_out_calls = { in_calls: int, /** total number of in calls transitively */ @@ -27,14 +27,14 @@ type in_out_calls = { type node_info = { /** defined procedure as opposed to just declared */ mutable defined: bool, - mutable parents: Procname.Set.t, - mutable children: Procname.Set.t, + mutable parents: Typ.Procname.Set.t, + mutable children: Typ.Procname.Set.t, /** ancestors are computed lazily */ - mutable ancestors: option Procname.Set.t, + mutable ancestors: option Typ.Procname.Set.t, /** heirs are computed lazily */ - mutable heirs: option Procname.Set.t, + mutable heirs: option Typ.Procname.Set.t, /** recursive dependents are computed lazily */ - mutable recursive_dependents: option Procname.Set.t, + mutable recursive_dependents: option Typ.Procname.Set.t, /** calls are computed lazily */ mutable in_out_calls: option in_out_calls }; @@ -43,7 +43,7 @@ type node_info = { /** Type for call graph */ type t = { source: SourceFile.t, /** path for the source file */ - node_map: Procname.Hash.t node_info /** map from node to node_info */ + node_map: Typ.Procname.Hash.t node_info /** map from node to node_info */ }; let create source_opt => { @@ -52,12 +52,12 @@ let create source_opt => { | None => SourceFile.empty | Some source => source }; - {source, node_map: Procname.Hash.create 3} + {source, node_map: Typ.Procname.Hash.create 3} }; let add_node g n defined::defined => try { - let info = Procname.Hash.find g.node_map n; + let info = Typ.Procname.Hash.find g.node_map n; /* defined and disabled only go from false to true to avoid accidental overwrite to false by calling add_edge */ if defined { @@ -67,19 +67,19 @@ let add_node g n defined::defined => | Not_found => let info = { defined, - parents: Procname.Set.empty, - children: Procname.Set.empty, + parents: Typ.Procname.Set.empty, + children: Typ.Procname.Set.empty, ancestors: None, heirs: None, recursive_dependents: None, in_out_calls: None }; - Procname.Hash.add g.node_map n info + Typ.Procname.Hash.add g.node_map n info }; let remove_node_defined g n => try { - let info = Procname.Hash.find g.node_map n; + let info = Typ.Procname.Hash.find g.node_map n; info.defined = false } { | Not_found => () @@ -90,20 +90,20 @@ let add_defined_node g n => add_node g n defined::true; /** Compute the ancestors of the node, if not already computed */ let compute_ancestors g node => { - let todo = ref (Procname.Set.singleton node); - let seen = ref Procname.Set.empty; - let result = ref Procname.Set.empty; - while (not (Procname.Set.is_empty !todo)) { - let current = Procname.Set.choose !todo; - todo := Procname.Set.remove current !todo; - if (not (Procname.Set.mem current !seen)) { - seen := Procname.Set.add current !seen; - let info = Procname.Hash.find g current; + let todo = ref (Typ.Procname.Set.singleton node); + let seen = ref Typ.Procname.Set.empty; + let result = ref Typ.Procname.Set.empty; + while (not (Typ.Procname.Set.is_empty !todo)) { + let current = Typ.Procname.Set.choose !todo; + todo := Typ.Procname.Set.remove current !todo; + if (not (Typ.Procname.Set.mem current !seen)) { + seen := Typ.Procname.Set.add current !seen; + let info = Typ.Procname.Hash.find g current; switch info.ancestors { - | Some ancestors => result := Procname.Set.union !result ancestors + | Some ancestors => result := Typ.Procname.Set.union !result ancestors | None => - result := Procname.Set.union !result info.parents; - todo := Procname.Set.union !todo info.parents + result := Typ.Procname.Set.union !result info.parents; + todo := Typ.Procname.Set.union !todo info.parents } } }; @@ -113,20 +113,20 @@ let compute_ancestors g node => { /** Compute the heirs of the node, if not already computed */ let compute_heirs g node => { - let todo = ref (Procname.Set.singleton node); - let seen = ref Procname.Set.empty; - let result = ref Procname.Set.empty; - while (not (Procname.Set.is_empty !todo)) { - let current = Procname.Set.choose !todo; - todo := Procname.Set.remove current !todo; - if (not (Procname.Set.mem current !seen)) { - seen := Procname.Set.add current !seen; - let info = Procname.Hash.find g current; + let todo = ref (Typ.Procname.Set.singleton node); + let seen = ref Typ.Procname.Set.empty; + let result = ref Typ.Procname.Set.empty; + while (not (Typ.Procname.Set.is_empty !todo)) { + let current = Typ.Procname.Set.choose !todo; + todo := Typ.Procname.Set.remove current !todo; + if (not (Typ.Procname.Set.mem current !seen)) { + seen := Typ.Procname.Set.add current !seen; + let info = Typ.Procname.Hash.find g current; switch info.heirs { - | Some heirs => result := Procname.Set.union !result heirs + | Some heirs => result := Typ.Procname.Set.union !result heirs | None => - result := Procname.Set.union !result info.children; - todo := Procname.Set.union !todo info.children + result := Typ.Procname.Set.union !result info.children; + todo := Typ.Procname.Set.union !todo info.children } } }; @@ -136,14 +136,14 @@ let compute_heirs g node => { /** Compute the ancestors of the node, if not pre-computed already */ let get_ancestors (g: t) node => { - let info = Procname.Hash.find g.node_map node; + let info = Typ.Procname.Hash.find g.node_map node; switch info.ancestors { | None => let ancestors = compute_ancestors g.node_map node; info.ancestors = Some ancestors; - let size = Procname.Set.cardinal ancestors; + let size = Typ.Procname.Set.cardinal ancestors; if (size > 1000) { - L.err "%a has %d ancestors@." Procname.pp node size + L.err "%a has %d ancestors@." Typ.Procname.pp node size }; ancestors | Some ancestors => ancestors @@ -153,14 +153,14 @@ let get_ancestors (g: t) node => { /** Compute the heirs of the node, if not pre-computed already */ let get_heirs (g: t) node => { - let info = Procname.Hash.find g.node_map node; + let info = Typ.Procname.Hash.find g.node_map node; switch info.heirs { | None => let heirs = compute_heirs g.node_map node; info.heirs = Some heirs; - let size = Procname.Set.cardinal heirs; + let size = Typ.Procname.Set.cardinal heirs; if (size > 1000) { - L.err "%a has %d heirs@." Procname.pp node size + L.err "%a has %d heirs@." Typ.Procname.pp node size }; heirs | Some heirs => heirs @@ -169,7 +169,7 @@ let get_heirs (g: t) node => { let node_defined (g: t) n => try { - let info = Procname.Hash.find g.node_map n; + let info = Typ.Procname.Hash.find g.node_map n; info.defined } { | Not_found => false @@ -178,37 +178,37 @@ let node_defined (g: t) n => let add_edge g nfrom nto => { add_node g nfrom defined::false; add_node g nto defined::false; - let info_from = Procname.Hash.find g.node_map nfrom; - let info_to = Procname.Hash.find g.node_map nto; - info_from.children = Procname.Set.add nto info_from.children; - info_to.parents = Procname.Set.add nfrom info_to.parents + let info_from = Typ.Procname.Hash.find g.node_map nfrom; + let info_to = Typ.Procname.Hash.find g.node_map nto; + info_from.children = Typ.Procname.Set.add nto info_from.children; + info_to.parents = Typ.Procname.Set.add nfrom info_to.parents }; /** iterate over the elements of a node_map in node order */ 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; + Typ.Procname.Hash.iter (fun node info => table := [(node, info), ...!table]) g.node_map; + let cmp (n1: Typ.Procname.t, _) (n2: Typ.Procname.t, _) => Typ.Procname.compare n1 n2; List.iter f::(fun (n, info) => f n info) (List.sort cmp::cmp !table) }; let get_nodes (g: t) => { - let nodes = ref Procname.Set.empty; - let f node _ => nodes := Procname.Set.add node !nodes; + let nodes = ref Typ.Procname.Set.empty; + let f node _ => nodes := Typ.Procname.Set.add node !nodes; node_map_iter f g; !nodes }; let compute_calls g node => { - in_calls: Procname.Set.cardinal (get_ancestors g node), - out_calls: Procname.Set.cardinal (get_heirs g node) + in_calls: Typ.Procname.Set.cardinal (get_ancestors g node), + out_calls: Typ.Procname.Set.cardinal (get_heirs g node) }; /** Compute the calls of the node, if not pre-computed already */ let get_calls (g: t) node => { - let info = Procname.Hash.find g.node_map node; + let info = Typ.Procname.Hash.find g.node_map node; switch info.in_out_calls { | None => let calls = compute_calls g node; @@ -219,19 +219,19 @@ let get_calls (g: t) node => { }; let get_all_nodes (g: t) => { - let nodes = Procname.Set.elements (get_nodes g); + let nodes = Typ.Procname.Set.elements (get_nodes g); List.map f::(fun node => (node, get_calls g node)) nodes }; let get_nodes_and_calls (g: t) => List.filter f::(fun (n, _) => node_defined g n) (get_all_nodes g); -let node_get_num_ancestors g n => (n, Procname.Set.cardinal (get_ancestors g n)); +let node_get_num_ancestors g n => (n, Typ.Procname.Set.cardinal (get_ancestors g n)); let get_edges (g: t) :list ((node, int), (node, int)) => { let edges = ref []; let f node info => - Procname.Set.iter + Typ.Procname.Set.iter ( fun nto => edges := [(node_get_num_ancestors g node, node_get_num_ancestors g nto), ...!edges] @@ -243,42 +243,43 @@ let get_edges (g: t) :list ((node, int), (node, int)) => { /** Return all the children of [n], whether defined or not */ -let get_all_children (g: t) n => (Procname.Hash.find g.node_map n).children; +let get_all_children (g: t) n => (Typ.Procname.Hash.find g.node_map n).children; /** Return the children of [n] which are defined */ -let get_defined_children (g: t) n => Procname.Set.filter (node_defined g) (get_all_children g n); +let get_defined_children (g: t) n => + Typ.Procname.Set.filter (node_defined g) (get_all_children g n); /** Return the parents of [n] */ -let get_parents (g: t) n => (Procname.Hash.find g.node_map n).parents; +let get_parents (g: t) n => (Typ.Procname.Hash.find g.node_map n).parents; /** Check if [source] recursively calls [dest] */ -let calls_recursively (g: t) source dest => Procname.Set.mem source (get_ancestors g dest); +let calls_recursively (g: t) source dest => Typ.Procname.Set.mem source (get_ancestors g dest); /** Return the children of [n] which are not heirs of [n] */ let get_nonrecursive_dependents (g: t) n => { - let is_not_recursive pn => not (Procname.Set.mem pn (get_ancestors g n)); - let res0 = Procname.Set.filter is_not_recursive (get_all_children g n); - let res = Procname.Set.filter (node_defined g) res0; + let is_not_recursive pn => not (Typ.Procname.Set.mem pn (get_ancestors g n)); + let res0 = Typ.Procname.Set.filter is_not_recursive (get_all_children g n); + let res = Typ.Procname.Set.filter (node_defined g) res0; res }; /** Return the ancestors of [n] which are also heirs of [n] */ let compute_recursive_dependents (g: t) n => { - let reached_from_n pn => Procname.Set.mem n (get_ancestors g pn); - let res0 = Procname.Set.filter reached_from_n (get_ancestors g n); - let res = Procname.Set.filter (node_defined g) res0; + let reached_from_n pn => Typ.Procname.Set.mem n (get_ancestors g pn); + let res0 = Typ.Procname.Set.filter reached_from_n (get_ancestors g n); + let res = Typ.Procname.Set.filter (node_defined g) res0; res }; /** Compute the ancestors of [n] which are also heirs of [n], if not pre-computed already */ let get_recursive_dependents (g: t) n => { - let info = Procname.Hash.find g.node_map n; + let info = Typ.Procname.Hash.find g.node_map n; switch info.recursive_dependents { | None => let recursive_dependents = compute_recursive_dependents g n; @@ -291,21 +292,21 @@ let get_recursive_dependents (g: t) n => { /** Return the nodes dependent on [n] */ let get_dependents (g: t) n => - Procname.Set.union (get_nonrecursive_dependents g n) (get_recursive_dependents g n); + Typ.Procname.Set.union (get_nonrecursive_dependents g n) (get_recursive_dependents g n); /** Return all the nodes with their defined children */ let get_nodes_and_defined_children (g: t) => { - let nodes = ref Procname.Set.empty; + let nodes = ref Typ.Procname.Set.empty; node_map_iter ( fun n info => if info.defined { - nodes := Procname.Set.add n !nodes + nodes := Typ.Procname.Set.add n !nodes } ) g; - let nodes_list = Procname.Set.elements !nodes; + let nodes_list = Typ.Procname.Set.elements !nodes; List.map f::(fun n => (n, get_defined_children g n)) nodes_list }; @@ -321,7 +322,7 @@ let get_nodes_and_edges (g: t) :nodes_and_edges => { let do_children node nto => edges := [(node, nto), ...!edges]; let f node info => { nodes := [(node, info.defined), ...!nodes]; - Procname.Set.iter (do_children node) info.children + Typ.Procname.Set.iter (do_children node) info.children }; node_map_iter f g; (!nodes, !edges) @@ -395,12 +396,12 @@ let pp_graph_dotty get_specs (g: t) fmt => { } else { "diamond" }; - let pp_node fmt (n, _) => F.fprintf fmt "\"%s\"" (Procname.to_filename n); + let pp_node fmt (n, _) => F.fprintf fmt "\"%s\"" (Typ.Procname.to_filename n); let pp_node_label fmt (n, calls) => F.fprintf fmt "\"%a | calls=%d %d | specs=%d)\"" - Procname.pp + Typ.Procname.pp n calls.in_calls calls.out_calls diff --git a/infer/src/IR/Cg.rei b/infer/src/IR/Cg.rei index c9e753edb..f2514d953 100644 --- a/infer/src/IR/Cg.rei +++ b/infer/src/IR/Cg.rei @@ -19,7 +19,7 @@ type in_out_calls = { type t; /** the type of a call graph */ -/** A call graph consists of a set of nodes (Procname.t), and edges between them. +/** A call graph consists of a set of nodes (Typ.Procname.t), and edges between them. A node can be defined or undefined (to represent whether we have code for it). In an edge from [n1] to [n2], indicating that [n1] calls [n2], [n1] is the parent and [n2] is the child. @@ -28,15 +28,15 @@ type t; /** the type of a call graph */ /** [add_edge cg f t] adds an edge from [f] to [t] in the call graph [cg]. The nodes are also added as undefined, unless already present. */ -let add_edge: t => Procname.t => Procname.t => unit; +let add_edge: t => Typ.Procname.t => Typ.Procname.t => unit; /** Add a node to the call graph as defined */ -let add_defined_node: t => Procname.t => unit; +let add_defined_node: t => Typ.Procname.t => unit; /** Check if [source] recursively calls [dest] */ -let calls_recursively: t => Procname.t => Procname.t => bool; +let calls_recursively: t => Typ.Procname.t => Typ.Procname.t => bool; /** Create an empty call graph */ @@ -49,55 +49,55 @@ let extend: t => t => unit; /** Return all the children of [n], whether defined or not */ -let get_all_children: t => Procname.t => Procname.Set.t; +let get_all_children: t => Typ.Procname.t => Typ.Procname.Set.t; /** Compute the ancestors of the node, if not pre-computed already */ -let get_ancestors: t => Procname.t => Procname.Set.t; +let get_ancestors: t => Typ.Procname.t => Typ.Procname.Set.t; /** Compute the heirs of the node, if not pre-computed already */ -let get_heirs: t => Procname.t => Procname.Set.t; +let get_heirs: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the in/out calls of the node */ -let get_calls: t => Procname.t => in_out_calls; +let get_calls: t => Typ.Procname.t => in_out_calls; /** Return the list of nodes which are defined */ -let get_defined_nodes: t => list Procname.t; +let get_defined_nodes: t => list Typ.Procname.t; /** Return the children of [n] which are defined */ -let get_defined_children: t => Procname.t => Procname.Set.t; +let get_defined_children: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the nodes dependent on [n] */ -let get_dependents: t => Procname.t => Procname.Set.t; +let get_dependents: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the list of nodes with calls */ -let get_nodes_and_calls: t => list (Procname.t, in_out_calls); +let get_nodes_and_calls: t => list (Typ.Procname.t, in_out_calls); /** Return all the nodes with their defined children */ -let get_nodes_and_defined_children: t => list (Procname.t, Procname.Set.t); +let get_nodes_and_defined_children: t => list (Typ.Procname.t, Typ.Procname.Set.t); /** Return the list of nodes, with defined flag, and the list of edges */ -let get_nodes_and_edges: t => (list (Procname.t, bool), list (Procname.t, Procname.t)); +let get_nodes_and_edges: t => (list (Typ.Procname.t, bool), list (Typ.Procname.t, Typ.Procname.t)); /** Return the children of [n] which are not heirs of [n] and are defined */ -let get_nonrecursive_dependents: t => Procname.t => Procname.Set.t; +let get_nonrecursive_dependents: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the parents of [n] */ -let get_parents: t => Procname.t => Procname.Set.t; +let get_parents: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the ancestors of [n] which are also heirs of [n] */ -let get_recursive_dependents: t => Procname.t => Procname.Set.t; +let get_recursive_dependents: t => Typ.Procname.t => Typ.Procname.Set.t; /** Return the path of the source file */ @@ -109,15 +109,15 @@ let load_from_file: DB.filename => option t; /** Returns true if the node is defined */ -let node_defined: t => Procname.t => bool; +let node_defined: t => Typ.Procname.t => bool; /** Remove the defined flag from a node, if it exists. */ -let remove_node_defined: t => Procname.t => unit; +let remove_node_defined: t => Typ.Procname.t => unit; /** Print the call graph as a dotty file. */ -let save_call_graph_dotty: SourceFile.t => (Procname.t => list 'a) => t => unit; +let save_call_graph_dotty: SourceFile.t => (Typ.Procname.t => list 'a) => t => unit; /** Save a call graph into a file */ diff --git a/infer/src/IR/Const.re b/infer/src/IR/Const.re index f9a33a7f6..b4568c2ea 100644 --- a/infer/src/IR/Const.re +++ b/infer/src/IR/Const.re @@ -17,7 +17,7 @@ let module F = Format; type t = | Cint IntLit.t /** integer constants */ - | Cfun Procname.t /** function names */ + | Cfun Typ.Procname.t /** function names */ | Cstr string /** string constants */ | Cfloat float /** float constants */ | Cclass Ident.name /** class constant */ @@ -43,8 +43,8 @@ let pp pe f => | Cint i => IntLit.pp f i | Cfun fn => switch pe.Pp.kind { - | HTML => F.fprintf f "_fun_%s" (Escape.escape_xml (Procname.to_string fn)) - | _ => F.fprintf f "_fun_%s" (Procname.to_string fn) + | HTML => F.fprintf f "_fun_%s" (Escape.escape_xml (Typ.Procname.to_string fn)) + | _ => F.fprintf f "_fun_%s" (Typ.Procname.to_string fn) } | Cstr s => F.fprintf f "\"%s\"" (String.escaped s) | Cfloat v => F.fprintf f "%f" v diff --git a/infer/src/IR/Const.rei b/infer/src/IR/Const.rei index 2c3ebbc5c..cd37fd90b 100644 --- a/infer/src/IR/Const.rei +++ b/infer/src/IR/Const.rei @@ -19,7 +19,7 @@ let module F = Format; /** Constants */ type t = | Cint IntLit.t /** integer constants */ - | Cfun Procname.t /** function names */ + | Cfun Typ.Procname.t /** function names */ | Cstr string /** string constants */ | Cfloat float /** float constants */ | Cclass Ident.name /** class constant */ diff --git a/infer/src/IR/DecompiledExp.re b/infer/src/IR/DecompiledExp.re index 52f56ab24..25e3c2c1c 100644 --- a/infer/src/IR/DecompiledExp.re +++ b/infer/src/IR/DecompiledExp.re @@ -47,7 +47,7 @@ let rec to_string = fun | Darray de1 de2 => to_string de1 ^ "[" ^ to_string de2 ^ "]" | Dbinop op de1 de2 => "(" ^ to_string de1 ^ Binop.str Pp.text op ^ to_string de2 ^ ")" - | Dconst (Cfun pn) => Procname.to_simplified_string pn + | Dconst (Cfun pn) => Typ.Procname.to_simplified_string pn | Dconst c => Const.to_string c | Dderef de => "*" ^ to_string de | Dfcall fun_dexp args _ {cf_virtual: isvirtual} => { @@ -65,8 +65,8 @@ let rec to_string = | Dconst (Cfun pname) => { let s = switch pname { - | Procname.Java pname_java => Procname.java_get_method pname_java - | _ => Procname.to_string pname + | Typ.Procname.Java pname_java => Typ.Procname.java_get_method pname_java + | _ => Typ.Procname.to_string pname }; F.fprintf fmt "%s" s } diff --git a/infer/src/IR/Exp.re b/infer/src/IR/Exp.re index 0f3421b19..0f4d7ef8d 100644 --- a/infer/src/IR/Exp.re +++ b/infer/src/IR/Exp.re @@ -22,7 +22,7 @@ type _ident = Ident.t; let compare__ident x y => Ident.compare y x; -type closure = {name: Procname.t, captured_vars: list (t, Pvar.t, Typ.t)} [@@deriving compare] +type closure = {name: Typ.Procname.t, captured_vars: list (t, Pvar.t, Typ.t)} [@@deriving compare] /** dynamically determined length of an array value, if any */ and dynamic_length = option t [@@deriving compare] /** Program expressions. */ diff --git a/infer/src/IR/Exp.rei b/infer/src/IR/Exp.rei index cf524b725..58786831e 100644 --- a/infer/src/IR/Exp.rei +++ b/infer/src/IR/Exp.rei @@ -15,7 +15,7 @@ let module L = Logging; let module F = Format; -type closure = {name: Procname.t, captured_vars: list (t, Pvar.t, Typ.t)} [@@deriving compare] +type closure = {name: Typ.Procname.t, captured_vars: list (t, Pvar.t, Typ.t)} [@@deriving compare] /** dynamically determined length of an array value, if any */ and dynamic_length = option t [@@deriving compare] /** Program expressions. */ diff --git a/infer/src/IR/Io_infer.ml b/infer/src/IR/Io_infer.ml index a4c91cbc7..203c60271 100644 --- a/infer/src/IR/Io_infer.ml +++ b/infer/src/IR/Io_infer.ml @@ -185,7 +185,7 @@ struct F.fprintf fmt " %s" pr_str (** File name for the node, given the procedure name and node id *) - let node_filename pname id = (Procname.to_filename pname) ^ "_node" ^ string_of_int id + let node_filename pname id = (Typ.Procname.to_filename pname) ^ "_node" ^ string_of_int id (** Print an html link to the given node. *) let pp_node_link path_to_root pname ~description ~preds ~succs ~exn ~isvisited ~isproof fmt id = @@ -219,7 +219,7 @@ struct (** Print an html link to the given proc *) let pp_proc_link path_to_root proc_name fmt text = - pp_link ~path: (path_to_root @ [Procname.to_filename proc_name]) fmt text + pp_link ~path: (path_to_root @ [Typ.Procname.to_filename proc_name]) fmt text (** Print an html link to the given line number of the current source file *) let pp_line_link ?(with_name = false) ?(text = None) source path_to_root fmt linenum = diff --git a/infer/src/IR/Io_infer.mli b/infer/src/IR/Io_infer.mli index dbf1183cd..ad79acf65 100644 --- a/infer/src/IR/Io_infer.mli +++ b/infer/src/IR/Io_infer.mli @@ -24,7 +24,7 @@ module Html : sig val modified_during_analysis : SourceFile.t -> DB.Results_dir.path -> bool (** File name for the node, given the procedure name and node id *) - val node_filename : Procname.t -> int -> string + val node_filename : Typ.Procname.t -> int -> string (** Open an Html file to append data *) val open_out : SourceFile.t -> DB.Results_dir.path -> Unix.File_descr.t * Format.formatter @@ -45,13 +45,13 @@ module Html : sig [path_to_root] is the path to the dir for the procedure in the spec db. [id] is the node identifier. *) val pp_node_link : - DB.Results_dir.path -> Procname.t -> + DB.Results_dir.path -> Typ.Procname.t -> description:string -> preds:int list -> succs:int list -> exn:int list -> isvisited:bool -> isproof:bool -> Format.formatter -> int -> unit (** Print an html link to the given proc *) val pp_proc_link : - DB.Results_dir.path -> Procname.t -> Format.formatter -> string -> unit + DB.Results_dir.path -> Typ.Procname.t -> Format.formatter -> string -> unit (** Print an html link given node id and session *) val pp_session_link : diff --git a/infer/src/IR/LintIssues.ml b/infer/src/IR/LintIssues.ml index 73c948b4a..d04fc44af 100644 --- a/infer/src/IR/LintIssues.ml +++ b/infer/src/IR/LintIssues.ml @@ -11,18 +11,18 @@ open! IStd -let errLogMap = ref Procname.Map.empty +let errLogMap = ref Typ.Procname.Map.empty let exists_issues () = - not (Procname.Map.is_empty !errLogMap) + not (Typ.Procname.Map.is_empty !errLogMap) let get_err_log procname = - try Procname.Map.find procname !errLogMap + try Typ.Procname.Map.find procname !errLogMap with Not_found -> let errlog = Errlog.empty () in - errLogMap := Procname.Map.add procname errlog !errLogMap; errlog + errLogMap := Typ.Procname.Map.add procname errlog !errLogMap; errlog -let lint_issues_serializer : (Errlog.t Procname.Map.t) Serialization.serializer = +let lint_issues_serializer : (Errlog.t Typ.Procname.Map.t) Serialization.serializer = Serialization.create_serializer Serialization.Key.lint_issues (** Save issues to a file *) @@ -41,7 +41,7 @@ let load_issues_to_errlog_map dir = let file = DB.filename_from_string (Filename.concat issues_dir issues_file) in match load_issues file with | Some map -> - errLogMap := Procname.Map.merge ( + errLogMap := Typ.Procname.Map.merge ( fun _ issues1 issues2 -> match issues1, issues2 with | Some issues1, Some issues2 -> diff --git a/infer/src/IR/LintIssues.mli b/infer/src/IR/LintIssues.mli index 114c84327..197f4c6d5 100644 --- a/infer/src/IR/LintIssues.mli +++ b/infer/src/IR/LintIssues.mli @@ -11,15 +11,15 @@ open! IStd (** Module to store a set of issues per procedure *) -val errLogMap : Errlog.t Procname.Map.t ref +val errLogMap : Errlog.t Typ.Procname.Map.t ref val exists_issues : unit -> bool (** Save issues to a file *) -val get_err_log : Procname.t -> Errlog.t +val get_err_log : Typ.Procname.t -> Errlog.t (** Load issues from the given file *) -val store_issues : DB.filename -> Errlog.t Procname.Map.t -> unit +val store_issues : DB.filename -> Errlog.t Typ.Procname.Map.t -> unit (** Load all the lint issues in the given dir and update the issues map *) val load_issues_to_errlog_map : string -> unit diff --git a/infer/src/IR/Localise.ml b/infer/src/IR/Localise.ml index aa9bbcd9c..9bfe7dd77 100644 --- a/infer/src/IR/Localise.ml +++ b/infer/src/IR/Localise.ml @@ -230,7 +230,7 @@ let at_line tags loc = at_line_tag tags Tags.line loc let call_to tags proc_name = - let proc_name_str = Procname.to_simplified_string proc_name in + let proc_name_str = Typ.Procname.to_simplified_string proc_name in Tags.add tags Tags.call_procedure proc_name_str; "call to " ^ proc_name_str @@ -258,10 +258,10 @@ let format_field f = let format_method pname = match pname with - | Procname.Java pname_java -> - Procname.java_get_method pname_java + | Typ.Procname.Java pname_java -> + Typ.Procname.java_get_method pname_java | _ -> - Procname.to_string pname + Typ.Procname.to_string pname let mem_dyn_allocated = "memory dynamically allocated" let lock_acquired = "lock acquired" @@ -316,18 +316,18 @@ let deref_str_weak_variable_in_block proc_name_opt nullable_obj_str = let deref_str_nil_argument_in_variadic_method pn total_args arg_number = let tags = Tags.create () in let function_method, nil_null = - if Procname.is_c_method pn then ("method", "nil") else ("function", "null") in + if Typ.Procname.is_c_method pn then ("method", "nil") else ("function", "null") in let problem_str = Printf.sprintf "could be %s which results in a call to %s with %d arguments instead of %d \ (%s indicates that the last argument of this variadic %s has been reached)" - nil_null (Procname.to_simplified_string pn) arg_number (total_args - 1) nil_null function_method in + nil_null (Typ.Procname.to_simplified_string pn) arg_number (total_args - 1) nil_null function_method in _deref_str_null None problem_str tags (** dereference strings for an undefined value coming from the given procedure *) let deref_str_undef (proc_name, loc) = let tags = Tags.create () in - let proc_name_str = Procname.to_simplified_string proc_name in + let proc_name_str = Typ.Procname.to_simplified_string proc_name in Tags.add tags Tags.call_procedure proc_name_str; { tags = tags; value_pre = Some (pointer_or_object ()); @@ -407,7 +407,7 @@ let deref_str_uninitialized alloc_att_opt = (** Java unchecked exceptions errors *) let java_unchecked_exn_desc proc_name exn_name pre_str : error_desc = { no_desc with descriptions = [ - Procname.to_string proc_name; + Typ.Procname.to_string proc_name; "can throw " ^ (Typename.name exn_name); "whenever " ^ pre_str]; } @@ -429,10 +429,10 @@ let desc_context_leak pname context_typ fieldname leak_path : error_desc = path_prefix ^ context_str in let preamble = let pname_str = match pname with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> Printf.sprintf "%s.%s" - (Procname.java_get_class_name pname_java) - (Procname.java_get_method pname_java) + (Typ.Procname.java_get_class_name pname_java) + (Typ.Procname.java_get_method pname_java) | _ -> "" in "Context " ^ context_str ^ " may leak during method " ^ pname_str ^ ":\n" in @@ -450,7 +450,7 @@ let desc_unsafe_guarded_by_access pname accessed_fld guarded_by_str loc = guarded_by_str line_info guarded_by_str - (Procname.to_string pname) + (Typ.Procname.to_string pname) annot_str in { no_desc with descriptions = [msg]; } @@ -565,13 +565,13 @@ let desc_allocation_mismatch alloc dealloc = let tag_fun, tag_call, tag_line = if is_alloc then Tags.alloc_function, Tags.alloc_call, Tags.alloc_line else Tags.dealloc_function, Tags.dealloc_call, Tags.dealloc_line in - Tags.add tags tag_fun (Procname.to_simplified_string primitive_pname); - Tags.add tags tag_call (Procname.to_simplified_string called_pname); + Tags.add tags tag_fun (Typ.Procname.to_simplified_string primitive_pname); + Tags.add tags tag_call (Typ.Procname.to_simplified_string called_pname); Tags.add tags tag_line (string_of_int loc.Location.line); let by_call = - if Procname.equal primitive_pname called_pname then "" - else " by call to " ^ Procname.to_simplified_string called_pname in - "using " ^ Procname.to_simplified_string primitive_pname ^ by_call ^ " " ^ at_line (Tags.create ()) (* ignore the tag *) loc in + if Typ.Procname.equal primitive_pname called_pname then "" + else " by call to " ^ Typ.Procname.to_simplified_string called_pname in + "using " ^ Typ.Procname.to_simplified_string primitive_pname ^ by_call ^ " " ^ at_line (Tags.create ()) (* ignore the tag *) loc in let description = Format.sprintf "%s %s is deallocated %s" mem_dyn_allocated @@ -823,12 +823,12 @@ let desc_unary_minus_applied_to_unsigned_expression expr_str_opt typ_str loc = let desc_skip_function proc_name = let tags = Tags.create () in - let proc_name_str = Procname.to_string proc_name in + let proc_name_str = Typ.Procname.to_string proc_name in Tags.add tags Tags.value proc_name_str; { no_desc with descriptions = [proc_name_str]; tags = !tags } let desc_inherently_dangerous_function proc_name = - let proc_name_str = Procname.to_string proc_name in + let proc_name_str = Typ.Procname.to_string proc_name in let tags = Tags.create () in Tags.add tags Tags.value proc_name_str; { no_desc with descriptions = [proc_name_str]; tags = !tags } diff --git a/infer/src/IR/Localise.mli b/infer/src/IR/Localise.mli index 627cad693..7b626f1bf 100644 --- a/infer/src/IR/Localise.mli +++ b/infer/src/IR/Localise.mli @@ -141,16 +141,16 @@ val error_desc_get_dotty : error_desc -> string option type deref_str (** dereference strings for null dereference *) -val deref_str_null : Procname.t option -> deref_str +val deref_str_null : Typ.Procname.t option -> deref_str (** dereference strings for null dereference due to Nullable annotation *) -val deref_str_nullable : Procname.t option -> string -> deref_str +val deref_str_nullable : Typ.Procname.t option -> string -> deref_str (** dereference strings for null dereference due to weak captured variable in block *) -val deref_str_weak_variable_in_block : Procname.t option -> string -> deref_str +val deref_str_weak_variable_in_block : Typ.Procname.t option -> string -> deref_str (** dereference strings for an undefined value coming from the given procedure *) -val deref_str_undef : Procname.t * Location.t -> deref_str +val deref_str_undef : Typ.Procname.t * Location.t -> deref_str (** dereference strings for a freed pointer dereference *) val deref_str_freed : PredSymb.res_action -> deref_str @@ -165,7 +165,7 @@ val deref_str_array_bound : IntLit.t option -> IntLit.t option -> deref_str val deref_str_uninitialized : Sil.atom option -> deref_str (** dereference strings for nonterminal nil arguments in c/objc variadic methods *) -val deref_str_nil_argument_in_variadic_method : Procname.t -> int -> int -> deref_str +val deref_str_nil_argument_in_variadic_method : Typ.Procname.t -> int -> int -> deref_str (** dereference strings for a pointer size mismatch *) val deref_str_pointer_size_mismatch : Typ.t -> Typ.t -> deref_str @@ -188,10 +188,10 @@ val is_field_not_null_checked_desc : error_desc -> bool val is_parameter_field_not_null_checked_desc : error_desc -> bool val desc_allocation_mismatch : - Procname.t * Procname.t * Location.t -> Procname.t * Procname.t * Location.t -> error_desc + Typ.Procname.t * Typ.Procname.t * Location.t -> Typ.Procname.t * Typ.Procname.t * Location.t -> error_desc val desc_class_cast_exception : - Procname.t option -> string -> string -> string option -> Location.t -> error_desc + Typ.Procname.t option -> string -> string -> string option -> Location.t -> error_desc val desc_comparing_floats_for_equality : Location.t -> error_desc @@ -199,13 +199,13 @@ val desc_condition_is_assignment : Location.t -> error_desc val desc_condition_always_true_false : IntLit.t -> string option -> Location.t -> error_desc -val desc_deallocate_stack_variable : string -> Procname.t -> Location.t -> error_desc +val desc_deallocate_stack_variable : string -> Typ.Procname.t -> Location.t -> error_desc -val desc_deallocate_static_memory : string -> Procname.t -> Location.t -> error_desc +val desc_deallocate_static_memory : string -> Typ.Procname.t -> Location.t -> error_desc val desc_divide_by_zero : string -> Location.t -> error_desc -val desc_empty_vector_access : Procname.t option -> string -> Location.t -> error_desc +val desc_empty_vector_access : Typ.Procname.t option -> string -> Location.t -> error_desc val is_empty_vector_access_desc : error_desc -> bool @@ -219,14 +219,14 @@ val desc_buffer_overrun : string -> string -> error_desc val desc_null_test_after_dereference : string -> int -> Location.t -> error_desc -val java_unchecked_exn_desc : Procname.t -> Typename.t -> string -> error_desc +val java_unchecked_exn_desc : Typ.Procname.t -> Typename.t -> string -> error_desc val desc_context_leak : - Procname.t -> Typ.t -> Ident.fieldname -> + Typ.Procname.t -> Typ.t -> Ident.fieldname -> (Ident.fieldname option * Typ.t) list -> error_desc val desc_fragment_retains_view : - Typ.t -> Ident.fieldname -> Typ.t -> Procname.t -> error_desc + Typ.t -> Ident.fieldname -> Typ.t -> Typ.Procname.t -> error_desc (* Create human-readable error description for assertion failures *) val desc_custom_error : Location.t -> error_desc @@ -236,7 +236,7 @@ type pnm_kind = | Pnm_bounds | Pnm_dangling -val desc_precondition_not_met : pnm_kind option -> Procname.t -> Location.t -> error_desc +val desc_precondition_not_met : pnm_kind option -> Typ.Procname.t -> Location.t -> error_desc val desc_return_expression_required : string -> Location.t -> error_desc @@ -250,21 +250,21 @@ val desc_registered_observer_being_deallocated : Pvar.t -> Location.t -> error_d val desc_return_statement_missing : Location.t -> error_desc -val desc_return_value_ignored : Procname.t -> Location.t -> error_desc +val desc_return_value_ignored : Typ.Procname.t -> Location.t -> error_desc val desc_stack_variable_address_escape : string -> string option -> Location.t -> error_desc -val desc_skip_function : Procname.t -> error_desc +val desc_skip_function : Typ.Procname.t -> error_desc -val desc_inherently_dangerous_function : Procname.t -> error_desc +val desc_inherently_dangerous_function : Typ.Procname.t -> error_desc val desc_unary_minus_applied_to_unsigned_expression : string option -> string -> Location.t -> error_desc val desc_unsafe_guarded_by_access : - Procname.t -> Ident.fieldname -> string -> Location.t -> error_desc + Typ.Procname.t -> Ident.fieldname -> string -> Location.t -> error_desc val desc_tainted_value_reaching_sensitive_function : - PredSymb.taint_kind -> string -> Procname.t -> Procname.t -> Location.t -> error_desc + PredSymb.taint_kind -> string -> Typ.Procname.t -> Typ.Procname.t -> Location.t -> error_desc val desc_uninitialized_dangling_pointer_deref : deref_str -> string -> Location.t -> error_desc diff --git a/infer/src/IR/PredSymb.re b/infer/src/IR/PredSymb.re index cdc0a0978..09372c366 100644 --- a/infer/src/IR/PredSymb.re +++ b/infer/src/IR/PredSymb.re @@ -84,7 +84,7 @@ type dangling_kind = /** position in a path: proc name, node id */ -type path_pos = (Procname.t, int) [@@deriving compare]; +type path_pos = (Typ.Procname.t, int) [@@deriving compare]; let equal_path_pos = [%compare.equal : path_pos]; @@ -96,14 +96,14 @@ type taint_kind = | Tk_unknown [@@deriving compare]; -type taint_info = {taint_source: Procname.t, taint_kind: taint_kind} [@@deriving compare]; +type taint_info = {taint_source: Typ.Procname.t, taint_kind: taint_kind} [@@deriving compare]; /** acquire/release action on a resource */ type res_action = { ra_kind: res_act_kind, /** kind of action */ ra_res: resource, /** kind of resource */ - ra_pname: Procname.t, /** name of the procedure used to acquire/release the resource */ + ra_pname: Typ.Procname.t, /** name of the procedure used to acquire/release the resource */ ra_loc: Location.t, /** location of the acquire/release */ ra_vpath: DecompiledExp.vpath /** vpath of the resource value */ }; @@ -139,7 +139,7 @@ type t = | Aautorelease | Adangling dangling_kind /** dangling pointer */ /** undefined value obtained by calling the given procedure, plus its return value annots */ - | Aundef Procname.t _annot_item _location _path_pos + | Aundef Typ.Procname.t _annot_item _location _path_pos | Ataint taint_info | Auntaint taint_info | Alocked @@ -149,7 +149,7 @@ type t = /** attributed exp is null due to a call to a method with given path as null receiver */ | Aobjc_null /** value was returned from a call to the given procedure, plus the annots of the return value */ - | Aretval Procname.t Annot.Item.t + | Aretval Typ.Procname.t Annot.Item.t /** denotes an object registered as an observers to a notification center */ | Aobserver /** denotes an object unsubscribed from observers of a notification center */ @@ -162,19 +162,19 @@ let equal = [%compare.equal : t]; /** name of the allocation function for the given memory kind */ let mem_alloc_pname = fun - | Mmalloc => Procname.from_string_c_fun "malloc" - | Mnew => Procname.from_string_c_fun "new" - | Mnew_array => Procname.from_string_c_fun "new[]" - | Mobjc => Procname.from_string_c_fun "alloc"; + | Mmalloc => Typ.Procname.from_string_c_fun "malloc" + | Mnew => Typ.Procname.from_string_c_fun "new" + | Mnew_array => Typ.Procname.from_string_c_fun "new[]" + | Mobjc => Typ.Procname.from_string_c_fun "alloc"; /** name of the deallocation function for the given memory kind */ let mem_dealloc_pname = fun - | Mmalloc => Procname.from_string_c_fun "free" - | Mnew => Procname.from_string_c_fun "delete" - | Mnew_array => Procname.from_string_c_fun "delete[]" - | Mobjc => Procname.from_string_c_fun "dealloc"; + | Mmalloc => Typ.Procname.from_string_c_fun "free" + | Mnew => Typ.Procname.from_string_c_fun "delete" + | Mnew_array => Typ.Procname.from_string_c_fun "delete[]" + | Mobjc => Typ.Procname.from_string_c_fun "dealloc"; /** Categories of attributes */ @@ -244,7 +244,7 @@ let to_string pe => }; name ^ Binop.str pe Lt ^ - Procname.to_string ra.ra_pname ^ + Typ.Procname.to_string ra.ra_pname ^ ":" ^ string_of_int ra.ra_loc.Location.line ^ Binop.str pe Gt ^ str_vpath } | Aautorelease => "AUTORELEASE" @@ -260,14 +260,14 @@ let to_string pe => | Aundef pn _ loc _ => "UND" ^ Binop.str pe Lt ^ - Procname.to_string pn ^ Binop.str pe Gt ^ ":" ^ string_of_int loc.Location.line - | Ataint {taint_source} => "TAINTED[" ^ Procname.to_string taint_source ^ "]" + Typ.Procname.to_string pn ^ Binop.str pe Gt ^ ":" ^ string_of_int loc.Location.line + | Ataint {taint_source} => "TAINTED[" ^ Typ.Procname.to_string taint_source ^ "]" | Auntaint _ => "UNTAINTED" | Alocked => "LOCKED" | Aunlocked => "UNLOCKED" | Adiv0 (_, _) => "DIV0" | Aobjc_null => "OBJC_NULL" - | Aretval pn _ => "RET" ^ Binop.str pe Lt ^ Procname.to_string pn ^ Binop.str pe Gt + | Aretval pn _ => "RET" ^ Binop.str pe Lt ^ Typ.Procname.to_string pn ^ Binop.str pe Gt | Aobserver => "OBSERVER" | Aunsubscribed_observer => "UNSUBSCRIBED_OBSERVER"; diff --git a/infer/src/IR/PredSymb.rei b/infer/src/IR/PredSymb.rei index ca74a9af5..d0c1e9732 100644 --- a/infer/src/IR/PredSymb.rei +++ b/infer/src/IR/PredSymb.rei @@ -73,7 +73,7 @@ type dangling_kind = /** position in a path: proc name, node id */ -type path_pos = (Procname.t, int) [@@deriving compare]; +type path_pos = (Typ.Procname.t, int) [@@deriving compare]; let equal_path_pos: path_pos => path_pos => bool; @@ -84,14 +84,14 @@ type taint_kind = | Tk_integrity_annotation | Tk_unknown; -type taint_info = {taint_source: Procname.t, taint_kind: taint_kind}; +type taint_info = {taint_source: Typ.Procname.t, taint_kind: taint_kind}; /** acquire/release action on a resource */ type res_action = { ra_kind: res_act_kind, /** kind of action */ ra_res: resource, /** kind of resource */ - ra_pname: Procname.t, /** name of the procedure used to acquire/release the resource */ + ra_pname: Typ.Procname.t, /** name of the procedure used to acquire/release the resource */ ra_loc: Location.t, /** location of the acquire/release */ ra_vpath: DecompiledExp.vpath /** vpath of the resource value */ }; @@ -110,7 +110,7 @@ type t = | Aautorelease | Adangling dangling_kind /** dangling pointer */ /** undefined value obtained by calling the given procedure, plus its return value annots */ - | Aundef Procname.t Annot.Item.t Location.t path_pos + | Aundef Typ.Procname.t Annot.Item.t Location.t path_pos | Ataint taint_info | Auntaint taint_info | Alocked @@ -120,7 +120,7 @@ type t = /** attributed exp is null due to a call to a method with given path as null receiver */ | Aobjc_null /** value was returned from a call to the given procedure, plus the annots of the return value */ - | Aretval Procname.t Annot.Item.t + | Aretval Typ.Procname.t Annot.Item.t /** denotes an object registered as an observers to a notification center */ | Aobserver /** denotes an object unsubscribed from observers of a notification center */ @@ -131,11 +131,11 @@ let equal: t => t => bool; /** name of the allocation function for the given memory kind */ -let mem_alloc_pname: mem_kind => Procname.t; +let mem_alloc_pname: mem_kind => Typ.Procname.t; /** name of the deallocation function for the given memory kind */ -let mem_dealloc_pname: mem_kind => Procname.t; +let mem_dealloc_pname: mem_kind => Typ.Procname.t; /** Categories of attributes */ diff --git a/infer/src/IR/ProcAttributes.re b/infer/src/IR/ProcAttributes.re index 35addfef1..a8a5f7d2b 100644 --- a/infer/src/IR/ProcAttributes.re +++ b/infer/src/IR/ProcAttributes.re @@ -67,7 +67,7 @@ type t = { method_annotation: Annot.Method.t, /** annotations for java methods */ objc_accessor: option objc_accessor_type, /** type of ObjC accessor, if any */ proc_flags: proc_flags, /** flags of the procedure */ - proc_name: Procname.t, /** name of the procedure */ + proc_name: Typ.Procname.t, /** name of the procedure */ ret_type: Typ.t, /** return type */ source_file_captured: SourceFile.t /** source file where the procedure was captured */ } diff --git a/infer/src/IR/ProcAttributes.rei b/infer/src/IR/ProcAttributes.rei index 3babb7945..992034a6b 100644 --- a/infer/src/IR/ProcAttributes.rei +++ b/infer/src/IR/ProcAttributes.rei @@ -62,7 +62,7 @@ type t = { method_annotation: Annot.Method.t, /** annotations for java methods */ objc_accessor: option objc_accessor_type, /** type of ObjC accessor, if any */ proc_flags: proc_flags, /** flags of the procedure */ - proc_name: Procname.t, /** name of the procedure */ + proc_name: Typ.Procname.t, /** name of the procedure */ ret_type: Typ.t, /** return type */ source_file_captured: SourceFile.t /** source file where the procedure was captured */ } @@ -70,4 +70,4 @@ type t = { /** Create a proc_attributes with default values. */ -let default: Procname.t => Config.language => t; +let default: Typ.Procname.t => Config.language => t; diff --git a/infer/src/IR/Procdesc.re b/infer/src/IR/Procdesc.re index 10cb35215..47e3ccabe 100644 --- a/infer/src/IR/Procdesc.re +++ b/infer/src/IR/Procdesc.re @@ -20,8 +20,8 @@ let module Node = { type id = int [@@deriving compare]; let equal_id = [%compare.equal : id]; type nodekind = - | Start_node Procname.t - | Exit_node Procname.t + | Start_node Typ.Procname.t + | Exit_node Typ.Procname.t | Stmt_node string | Join_node | Prune_node bool Sil.if_kind string /** (true/false branch, if_kind, comment) */ @@ -46,7 +46,7 @@ let module Node = { /** predecessor nodes in the cfg */ mutable preds: list t, /** name of the procedure the node belongs to */ - pname_opt: option Procname.t, + pname_opt: option Typ.Procname.t, /** successor nodes in the cfg */ mutable succs: list t }; @@ -580,7 +580,7 @@ let pp_objc_accessor fmt accessor => let pp_signature fmt pdesc => { let attributes = get_attributes pdesc; let pname = get_proc_name pdesc; - let pname_string = Procname.to_string pname; + let pname_string = Typ.Procname.to_string pname; let defined_string = is_defined pdesc ? "defined" : "undefined"; Format.fprintf fmt diff --git a/infer/src/IR/Procdesc.rei b/infer/src/IR/Procdesc.rei index 00df8f56e..f118370cd 100644 --- a/infer/src/IR/Procdesc.rei +++ b/infer/src/IR/Procdesc.rei @@ -22,8 +22,8 @@ let module Node: { /** kind of cfg node */ type nodekind = - | Start_node Procname.t - | Exit_node Procname.t + | Start_node Typ.Procname.t + | Exit_node Typ.Procname.t | Stmt_node string | Join_node | Prune_node bool Sil.if_kind string /** (true/false branch, if_kind, comment) */ @@ -50,13 +50,13 @@ let module Node: { let d_instrs: sub_instrs::bool => option Sil.instr => t => unit; /** Create a dummy node */ - let dummy: option Procname.t => t; + let dummy: option Typ.Procname.t => t; /** Check if two nodes are equal */ let equal: t => t => bool; /** Get the list of callee procnames from the node */ - let get_callees: t => list Procname.t; + let get_callees: t => list Typ.Procname.t; /** Return a description of the node */ let get_description: Pp.env => t => string; @@ -90,7 +90,7 @@ let module Node: { let get_preds: t => list t; /** Get the name of the procedure the node belongs to */ - let get_proc_name: t => Procname.t; + let get_proc_name: t => Typ.Procname.t; /** Get the predecessor nodes of a node where the given predicate evaluates to true */ let get_sliced_preds: t => (t => bool) => list t; @@ -159,7 +159,7 @@ let did_preanalysis: t => bool; /** fold over the calls from the procedure: (callee, location) pairs */ -let fold_calls: ('a => (Procname.t, Location.t) => 'a) => 'a => t => 'a; +let fold_calls: ('a => (Typ.Procname.t, Location.t) => 'a) => 'a => t => 'a; /** fold over all nodes and their instructions */ @@ -207,7 +207,7 @@ let get_locals: t => list (Mangled.t, Typ.t); let get_nodes: t => list Node.t; -let get_proc_name: t => Procname.t; +let get_proc_name: t => Typ.Procname.t; /** Return the return type of the procedure and type string */ @@ -239,7 +239,7 @@ let is_java_synchronized: t => bool; /** iterate over the calls from the procedure: (callee, location) pairs */ -let iter_calls: ((Procname.t, Location.t) => unit) => t => unit; +let iter_calls: ((Typ.Procname.t, Location.t) => unit) => t => unit; /** iterate over all nodes and their instructions */ @@ -255,7 +255,7 @@ let iter_slope: (Node.t => unit) => t => unit; /** iterate over all calls until we reach a branching structure */ -let iter_slope_calls: (Procname.t => unit) => t => unit; +let iter_slope_calls: (Typ.Procname.t => unit) => t => unit; /** iterate between two nodes or until we reach a branching structure */ diff --git a/infer/src/IR/Procname.re b/infer/src/IR/Procname.re deleted file mode 100644 index 6f46fc73e..000000000 --- a/infer/src/IR/Procname.re +++ /dev/null @@ -1,587 +0,0 @@ -/* - * Copyright (c) 2009 - 2013 Monoidics ltd. - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -open! IStd; - -let module Hashtbl = Caml.Hashtbl; - - -/** Module for Procedure Names */ -let module L = Logging; - -let module F = Format; - -/* e.g. ("", "int") for primitive types or ("java.io", "PrintWriter") for objects */ -type java_type = (option string, string); - -/* compare in inverse order */ -let compare_java_type (p1, c1) (p2, c2) => [%compare : (string, option string)] (c1, p1) (c2, p2); - -type method_kind = - | Non_Static /* in Java, procedures called with invokevirtual, invokespecial, and invokeinterface */ - | Static /* in Java, procedures called with invokestatic */ -[@@deriving compare]; - -let equal_method_kind = [%compare.equal : method_kind]; - - -/** Type of java procedure names. */ -type java = { - method_name: string, - parameters: list java_type, - class_name: Typename.t, - return_type: option java_type, /* option because constructors have no return type */ - kind: method_kind -} -[@@deriving compare]; - - -/** Type of c procedure names. */ -type c = (string, option string) [@@deriving compare]; - -type objc_cpp_method_kind = - | CPPMethod (option string) /** with mangling */ - | CPPConstructor (option string, bool) /** with mangling + is it constexpr? */ - | ObjCClassMethod - | ObjCInstanceMethod - | ObjCInternalMethod -[@@deriving compare]; - - -/** Type of Objective C and C++ procedure names: method signatures. */ -type objc_cpp = {method_name: string, class_name: Typename.t, kind: objc_cpp_method_kind} -[@@deriving compare]; - - -/** Type of Objective C block names. */ -type block = string [@@deriving compare]; - - -/** Type of procedure names. */ -type t = - | Java java - | C c - | Linters_dummy_method - | Block block - | ObjC_Cpp objc_cpp -[@@deriving compare]; - -let equal = [%compare.equal : t]; - - -/** Level of verbosity of some to_string functions. */ -type detail_level = - | Verbose - | Non_verbose - | Simple -[@@deriving compare]; - -let equal_detail_level = [%compare.equal : detail_level]; - -let objc_method_kind_of_bool is_instance => - if is_instance {ObjCInstanceMethod} else {ObjCClassMethod}; - -let empty_block = Block ""; - -let is_verbose v => - switch v { - | Verbose => true - | _ => false - }; - - -/** A type is a pair (package, type_name) that is translated in a string package.type_name */ -let java_type_to_string_verbosity p verbosity => - switch p { - | (None, typ) => typ - | (Some p, cls) => - if (is_verbose verbosity) { - p ^ "." ^ cls - } else { - cls - } - }; - -let java_type_to_string p => java_type_to_string_verbosity p Verbose; - - -/** Given a list of types, it creates a unique string of types separated by commas */ -let rec java_param_list_to_string inputList verbosity => - switch inputList { - | [] => "" - | [head] => java_type_to_string_verbosity head verbosity - | [head, ...rest] => - java_type_to_string_verbosity head verbosity ^ "," ^ java_param_list_to_string rest verbosity - }; - - -/** It is the same as java_type_to_string, but Java return types are optional because of constructors without type */ -let java_return_type_to_string j verbosity => - switch j.return_type { - | None => "" - | Some typ => java_type_to_string_verbosity typ verbosity - }; - - -/** Given a package.class_name string, it looks for the latest dot and split the string - in two (package, class_name) */ -let split_classname package_classname => - switch (String.rsplit2 package_classname on::'.') { - | Some (x, y) => (Some x, y) - | None => (None, package_classname) - }; - -let split_typename typename => split_classname (Typename.name typename); - -let from_string_c_fun (s: string) => C (s, None); - -let c (plain: string) (mangled: string) => (plain, Some mangled); - -let java class_name return_type method_name parameters kind => { - class_name, - return_type, - method_name, - parameters, - kind -}; - - -/** Create an objc procedure name from a class_name and method_name. */ -let objc_cpp class_name method_name kind => {class_name, method_name, kind}; - -let get_default_objc_class_method objc_class => { - let objc_cpp = objc_cpp objc_class "__find_class_" ObjCInternalMethod; - ObjC_Cpp objc_cpp -}; - - -/** Create an objc procedure name from a class_name and method_name. */ -let mangled_objc_block name => Block name; - -let is_java = - fun - | Java _ => true - | _ => false; - -let is_c_method = - fun - | ObjC_Cpp _ => true - | _ => false; - -let is_constexpr = - fun - | ObjC_Cpp {kind: CPPConstructor (_, true)} => true - | _ => false; - - -/** Replace the class name component of a procedure name. - In case of Java, replace package and class name. */ -let replace_class t (new_class: Typename.t) => - switch t { - | Java j => Java {...j, class_name: new_class} - | ObjC_Cpp osig => ObjC_Cpp {...osig, class_name: new_class} - | C _ - | Block _ - | Linters_dummy_method => t - }; - - -/** Get the class name of a Objective-C/C++ procedure name. */ -let objc_cpp_get_class_name objc_cpp => Typename.name objc_cpp.class_name; - -let objc_cpp_get_class_type_name objc_cpp => objc_cpp.class_name; - - -/** Return the package.classname of a java procname. */ -let java_get_class_name (j: java) => Typename.name j.class_name; - - -/** Return the package.classname as a typename of a java procname. */ -let java_get_class_type_name (j: java) => j.class_name; - - -/** Return the class name of a java procedure name. */ -let java_get_simple_class_name (j: java) => snd (split_classname (java_get_class_name j)); - - -/** Return the package of a java procname. */ -let java_get_package (j: java) => fst (split_classname (java_get_class_name j)); - - -/** Return the method of a java procname. */ -let java_get_method (j: java) => j.method_name; - - -/** Replace the method of a java procname. */ -let java_replace_method (j: java) mname => {...j, method_name: mname}; - - -/** Replace the return type of a java procname. */ -let java_replace_return_type j ret_type => {...j, return_type: Some ret_type}; - - -/** Replace the parameters of a java procname. */ -let java_replace_parameters j parameters => {...j, parameters}; - - -/** Return the method/function of a procname. */ -let get_method = - fun - | ObjC_Cpp name => name.method_name - | C (name, _) => name - | Block name => name - | Java j => j.method_name - | Linters_dummy_method => "Linters_dummy_method"; - - -/** Return the language of the procedure. */ -let get_language = - fun - | ObjC_Cpp _ => Config.Clang - | C _ => Config.Clang - | Block _ => Config.Clang - | Linters_dummy_method => Config.Clang - | Java _ => Config.Java; - - -/** Return the return type of a java procname. */ -let java_get_return_type (j: java) => java_return_type_to_string j Verbose; - - -/** Return the parameters of a java procname. */ -let java_get_parameters j => j.parameters; - - -/** Return the parameters of a java procname as strings. */ -let java_get_parameters_as_strings j => - List.map f::(fun param => java_type_to_string param) j.parameters; - - -/** Return true if the java procedure is static */ -let java_is_static = - fun - | Java j => equal_method_kind j.kind Static - | _ => false; - - -/** Prints a string of a java procname with the given level of verbosity */ -let java_to_string withclass::withclass=false (j: java) verbosity => - switch verbosity { - | Verbose - | Non_verbose => - /* if verbose, then package.class.method(params): rtype, - else rtype package.class.method(params) - verbose is used for example to create unique filenames, non_verbose to create reports */ - let return_type = java_return_type_to_string j verbosity; - let params = java_param_list_to_string j.parameters verbosity; - let class_name = java_type_to_string_verbosity (split_typename j.class_name) verbosity; - let separator = - switch (j.return_type, verbosity) { - | (None, _) => "" - | (Some _, Verbose) => ":" - | _ => " " - }; - let output = class_name ^ "." ^ j.method_name ^ "(" ^ params ^ ")"; - if (equal_detail_level verbosity Verbose) { - output ^ separator ^ return_type - } else { - return_type ^ separator ^ output - } - | Simple => - /* methodname(...) or without ... if there are no parameters */ - let cls_prefix = - if withclass { - java_type_to_string_verbosity (split_typename j.class_name) verbosity ^ "." - } else { - "" - }; - let params = - switch j.parameters { - | [] => "" - | _ => "..." - }; - let method_name = - if (String.equal j.method_name "") { - java_get_simple_class_name j - } else { - cls_prefix ^ j.method_name - }; - method_name ^ "(" ^ params ^ ")" - }; - - -/** Check if the class name is for an anonymous inner class. */ -let is_anonymous_inner_class_name class_name => { - let class_name_no_package = snd (split_typename class_name); - switch (String.rsplit2 class_name_no_package on::'$') { - | Some (_, s) => - let is_int = - try { - ignore (int_of_string (String.strip s)); - true - } { - | Failure _ => false - }; - is_int - | None => false - } -}; - - -/** Check if the procedure belongs to an anonymous inner class. */ -let java_is_anonymous_inner_class = - fun - | Java j => is_anonymous_inner_class_name j.class_name - | _ => false; - - -/** Check if the last parameter is a hidden inner class, and remove it if present. - This is used in private constructors, where a proxy constructor is generated - with an extra parameter and calls the normal constructor. */ -let java_remove_hidden_inner_class_parameter = - fun - | Java js => - switch (List.rev js.parameters) { - | [(_, s), ...par'] => - if (is_anonymous_inner_class_name (Typename.Java.from_string s)) { - Some (Java {...js, parameters: List.rev par'}) - } else { - None - } - | [] => None - } - | _ => None; - - -/** Check if the procedure name is an anonymous inner class constructor. */ -let java_is_anonymous_inner_class_constructor = - fun - | Java js => is_anonymous_inner_class_name js.class_name - | _ => false; - - -/** Check if the procedure name is an acess method (e.g. access$100 used to - access private members from a nested class. */ -let java_is_access_method = - fun - | Java js => - switch (String.rsplit2 js.method_name on::'$') { - | Some ("access", s) => - let is_int = - try { - ignore (int_of_string s); - true - } { - | Failure _ => false - }; - is_int - | _ => false - } - | _ => false; - - -/** Check if the procedure name is of an auto-generated method containing '$'. */ -let java_is_autogen_method = - fun - | Java js => String.contains js.method_name '$' - | _ => false; - - -/** Check if the proc name has the type of a java vararg. - Note: currently only checks that the last argument has type Object[]. */ -let java_is_vararg = - fun - | Java js => - switch (List.rev js.parameters) { - | [(_, "java.lang.Object[]"), ..._] => true - | _ => false - } - | _ => false; - -let is_objc_constructor method_name => - String.equal method_name "new" || String.is_prefix prefix::"init" method_name; - -let is_objc_kind = - fun - | ObjCClassMethod - | ObjCInstanceMethod - | ObjCInternalMethod => true - | _ => false; - - -/** [is_constructor pname] returns true if [pname] is a constructor */ -let is_constructor = - fun - | Java js => String.equal js.method_name "" - | ObjC_Cpp {kind: CPPConstructor _} => true - | ObjC_Cpp {kind, method_name} when is_objc_kind kind => is_objc_constructor method_name - | _ => false; - -let is_objc_dealloc method_name => String.equal method_name "dealloc"; - - -/** [is_dealloc pname] returns true if [pname] is the dealloc method in Objective-C - TODO: add case for C++ */ -let is_destructor = - fun - | ObjC_Cpp name => is_objc_dealloc name.method_name - | _ => false; - -let java_is_close = - fun - | Java js => String.equal js.method_name "close" - | _ => false; - - -/** [is_class_initializer pname] returns true if [pname] is a class initializer */ -let is_class_initializer = - fun - | Java js => String.equal js.method_name "" - | _ => false; - - -/** [is_infer_undefined pn] returns true if [pn] is a special Infer undefined proc */ -let is_infer_undefined pn => - switch pn { - | Java j => - let regexp = Str.regexp "com.facebook.infer.builtins.InferUndefined"; - Str.string_match regexp (java_get_class_name j) 0 - | _ => - /* TODO: add cases for obj-c, c, c++ */ - false - }; - -let get_global_name_of_initializer = - fun - | C (name, _) when String.is_prefix prefix::Config.clang_initializer_prefix name => { - let prefix_len = String.length Config.clang_initializer_prefix; - Some (String.sub name pos::prefix_len len::(String.length name - prefix_len)) - } - | _ => None; - - -/** to_string for C_function type */ -let to_readable_string (c1, c2) verbose => { - let plain = c1; - if verbose { - switch c2 { - | None => plain - | Some s => plain ^ "{" ^ s ^ "}" - } - } else { - plain - } -}; - -let c_method_to_string osig detail_level => - switch detail_level { - | Simple => osig.method_name - | Non_verbose => Typename.name osig.class_name ^ "_" ^ osig.method_name - | Verbose => - let m_str = - switch osig.kind { - | CPPMethod m => - "(" ^ - ( - switch m { - | None => "" - | Some s => s - } - ) ^ ")" - | CPPConstructor (m, is_constexpr) => - "{" ^ - ( - switch m { - | None => "" - | Some s => s - } - ) ^ - (if is_constexpr {"|constexpr"} else {""}) ^ "}" - | ObjCClassMethod => "class" - | ObjCInstanceMethod => "instance" - | ObjCInternalMethod => "internal" - }; - Typename.name osig.class_name ^ "_" ^ osig.method_name ^ m_str - }; - - -/** Very verbose representation of an existing Procname.t */ -let to_unique_id pn => - switch pn { - | Java j => java_to_string j Verbose - | C (c1, c2) => to_readable_string (c1, c2) true - | ObjC_Cpp osig => c_method_to_string osig Verbose - | Block name => name - | Linters_dummy_method => "Linters_dummy_method" - }; - - -/** Convert a proc name to a string for the user to see */ -let to_string p => - switch p { - | Java j => java_to_string j Non_verbose - | C (c1, c2) => to_readable_string (c1, c2) false - | ObjC_Cpp osig => c_method_to_string osig Non_verbose - | Block name => name - | Linters_dummy_method => to_unique_id p - }; - - -/** Convenient representation of a procname for external tools (e.g. eclipse plugin) */ -let to_simplified_string withclass::withclass=false p => - switch p { - | Java j => java_to_string withclass::withclass j Simple - | C (c1, c2) => to_readable_string (c1, c2) false ^ "()" - | ObjC_Cpp osig => c_method_to_string osig Simple - | Block _ => "block" - | Linters_dummy_method => to_unique_id p - }; - - -/** Convert a proc name to a filename */ -let to_filename proc_name => - Escape.escape_filename @@ SourceFile.append_crc_cutoff @@ to_unique_id proc_name; - - -/** Pretty print a proc name */ -let pp f pn => F.fprintf f "%s" (to_string pn); - - -/** hash function for procname */ -let hash_pname = Hashtbl.hash; - -let module Hash = Hashtbl.Make { - type nonrec t = t; - let equal = equal; - let hash = hash_pname; -}; - -let module Map = Caml.Map.Make { - type nonrec t = t; - let compare = compare; -}; - -let module Set = Caml.Set.Make { - type nonrec t = t; - let compare = compare; -}; - - -/** Pretty print a set of proc names */ -let pp_set fmt set => Set.iter (fun pname => F.fprintf fmt "%a " pp pname) set; - -let get_qualifiers pname => - switch pname { - | C c => fst c |> QualifiedCppName.qualifiers_of_qual_name - | ObjC_Cpp objc_cpp => - List.append - (QualifiedCppName.qualifiers_of_qual_name (Typename.name objc_cpp.class_name)) - [objc_cpp.method_name] - | _ => [] - }; diff --git a/infer/src/IR/Procname.rei b/infer/src/IR/Procname.rei deleted file mode 100644 index b88bcb167..000000000 --- a/infer/src/IR/Procname.rei +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2009 - 2013 Monoidics ltd. - * Copyright (c) 2013 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -open! IStd; - - -/** Module for Procedure Names. */ - -/** Type of java procedure names. */ -type java; - - -/** Type of c procedure names. */ -type c; - - -/** Type of Objective C and C++ procedure names. */ -type objc_cpp; - - -/** Type of Objective C block names. */ -type block; - - -/** Type of procedure names. */ -type t = - | Java java - | C c - | Linters_dummy_method - | Block block - | ObjC_Cpp objc_cpp -[@@deriving compare]; - - -/** Equality for proc names. */ -let equal: t => t => bool; - -type java_type = (option string, string); - -type method_kind = - | Non_Static /* in Java, procedures called with invokevirtual, invokespecial, and invokeinterface */ - | Static /* in Java, procedures called with invokestatic */; - -type objc_cpp_method_kind = - | CPPMethod (option string) /** with mangling */ - | CPPConstructor (option string, bool) /** with mangling + is it constexpr? */ - | ObjCClassMethod - | ObjCInstanceMethod - | ObjCInternalMethod; - - -/** Hash tables with proc names as keys. */ -let module Hash: Caml.Hashtbl.S with type key = t; - - -/** Maps from proc names. */ -let module Map: Caml.Map.S with type key = t; - - -/** Sets of proc names. */ -let module Set: Caml.Set.S with type elt = t; - - -/** Create a C procedure name from plain and mangled name. */ -let c: string => string => c; - - -/** Empty block name. */ -let empty_block: t; - - -/** Convert a string to a proc name. */ -let from_string_c_fun: string => t; - - -/** Return the language of the procedure. */ -let get_language: t => Config.language; - - -/** Return the method/function of a procname. */ -let get_method: t => string; - - -/** Hash function for procname. */ -let hash_pname: t => int; - - -/** Check if a class string is an anoynmous inner class name. */ -let is_anonymous_inner_class_name: Typename.t => bool; - - -/** Check if this is an Objective-C/C++ method name. */ -let is_c_method: t => bool; - - -/** Check if this is a constructor method in Objective-C. */ -let is_objc_constructor: string => bool; - - -/** Check if this is a constructor. */ -let is_constructor: t => bool; - - -/** Check if this is a constexpr function. */ -let is_constexpr: t => bool; - - -/** Check if this is a Java procedure name. */ -let is_java: t => bool; - - -/** Check if this is a dealloc method in Objective-C. */ -let is_objc_dealloc: string => bool; - - -/** Check if this is a dealloc method. */ -let is_destructor: t => bool; - - -/** Create a Java procedure name from its - class_name method_name args_type_name return_type_name method_kind. */ -let java: Typename.t => option java_type => string => list java_type => method_kind => java; - - -/** Replace the parameters of a java procname. */ -let java_replace_parameters: java => list java_type => java; - - -/** Replace the method of a java procname. */ -let java_replace_return_type: java => java_type => java; - - -/** Create an objc block name. */ -let mangled_objc_block: string => t; - - -/** Create an objc procedure name from a class_name and method_name. */ -let objc_cpp: Typename.t => string => objc_cpp_method_kind => objc_cpp; - -let get_default_objc_class_method: Typename.t => t; - - -/** Get the class name of a Objective-C/C++ procedure name. */ -let objc_cpp_get_class_name: objc_cpp => string; - -let objc_cpp_get_class_type_name: objc_cpp => Typename.t; - - -/** Create ObjC method type from a bool is_instance. */ -let objc_method_kind_of_bool: bool => objc_cpp_method_kind; - - -/** Return the class name of a java procedure name. */ -let java_get_class_name: java => string; - - -/** Return the class name as a typename of a java procedure name. */ -let java_get_class_type_name: java => Typename.t; - - -/** Return the simple class name of a java procedure name. */ -let java_get_simple_class_name: java => string; - - -/** Return the package name of a java procedure name. */ -let java_get_package: java => option string; - - -/** Return the method name of a java procedure name. */ -let java_get_method: java => string; - - -/** Return the return type of a java procedure name. */ -let java_get_return_type: java => string; - - -/** Return the parameters of a java procedure name. */ -let java_get_parameters: java => list java_type; - - -/** Return the parameters of a java procname as strings. */ -let java_get_parameters_as_strings: java => list string; - - -/** Check if the procedure name is an acess method (e.g. access$100 used to - access private members from a nested class. */ -let java_is_access_method: t => bool; - - -/** Check if the procedure name is of an auto-generated method containing '$'. */ -let java_is_autogen_method: t => bool; - - -/** Check if the procedure belongs to an anonymous inner class. */ -let java_is_anonymous_inner_class: t => bool; - - -/** Check if the procedure name is an anonymous inner class constructor. */ -let java_is_anonymous_inner_class_constructor: t => bool; - - -/** Check if the method name is "close". */ -let java_is_close: t => bool; - - -/** Check if the java procedure is static. */ -let java_is_static: t => bool; - - -/** Check if the proc name has the type of a java vararg. - Note: currently only checks that the last argument has type Object[]. */ -let java_is_vararg: t => bool; - - -/** Check if the last parameter is a hidden inner class, and remove it if present. - This is used in private constructors, where a proxy constructor is generated - with an extra parameter and calls the normal constructor. */ -let java_remove_hidden_inner_class_parameter: t => option t; - - -/** Replace the method name of an existing java procname. */ -let java_replace_method: java => string => java; - - -/** Convert a java type to a string. */ -let java_type_to_string: java_type => string; - - -/** Check if this is a class initializer. */ -let is_class_initializer: t => bool; - - -/** Check if this is a special Infer undefined procedure. */ -let is_infer_undefined: t => bool; - - -/** Return the name of the global for which this procedure is the initializer if this is an - initializer, None otherwise. */ -let get_global_name_of_initializer: t => option string; - - -/** Pretty print a proc name. */ -let pp: Format.formatter => t => unit; - - -/** Pretty print a set of proc names. */ -let pp_set: Format.formatter => Set.t => unit; - - -/** Replace the class name component of a procedure name. - In case of Java, replace package and class name. */ -let replace_class: t => Typename.t => t; - - -/** Given a package.class_name string, look for the latest dot and split the string - in two (package, class_name). */ -let split_classname: string => (option string, string); - - -/** Convert a proc name to a string for the user to see. */ -let to_string: t => string; - - -/** Convert a proc name into a easy string for the user to see in an IDE. */ -let to_simplified_string: withclass::bool? => t => string; - - -/** Convert a proc name into a unique identifier. */ -let to_unique_id: t => string; - - -/** Convert a proc name to a filename. */ -let to_filename: t => string; - -let get_qualifiers: t => list string; diff --git a/infer/src/IR/Pvar.re b/infer/src/IR/Pvar.re index 269e90ada..177ad46dd 100644 --- a/infer/src/IR/Pvar.re +++ b/infer/src/IR/Pvar.re @@ -18,10 +18,10 @@ let module F = Format; /** Kind of global variables */ type pvar_kind = - | Local_var Procname.t /** local variable belonging to a function */ - | Callee_var Procname.t /** local variable belonging to a callee */ - | Abduced_retvar Procname.t Location.t /** synthetic variable to represent return value */ - | Abduced_ref_param Procname.t t Location.t + | Local_var Typ.Procname.t /** local variable belonging to a function */ + | Callee_var Typ.Procname.t /** local variable belonging to a callee */ + | Abduced_retvar Typ.Procname.t Location.t /** synthetic variable to represent return value */ + | Abduced_ref_param Typ.Procname.t t Location.t /** synthetic variable to represent param passed by reference */ | Global_var (SourceFile.t, bool, bool, bool) /** global variable: translation unit + is it compile constant? + is it POD? + is it a static @@ -43,25 +43,25 @@ let rec _pp f pv => { if !Config.pp_simple { F.fprintf f "%a" Mangled.pp name } else { - F.fprintf f "%a$%a" Procname.pp n Mangled.pp name + F.fprintf f "%a$%a" Typ.Procname.pp n Mangled.pp name } | Callee_var n => if !Config.pp_simple { F.fprintf f "%a|callee" Mangled.pp name } else { - F.fprintf f "%a$%a|callee" Procname.pp n Mangled.pp name + F.fprintf f "%a$%a|callee" Typ.Procname.pp n Mangled.pp name } | Abduced_retvar n l => if !Config.pp_simple { F.fprintf f "%a|abducedRetvar" Mangled.pp name } else { - F.fprintf f "%a$%a%a|abducedRetvar" Procname.pp n Location.pp l Mangled.pp name + F.fprintf f "%a$%a%a|abducedRetvar" Typ.Procname.pp n Location.pp l Mangled.pp name } | Abduced_ref_param n pv l => if !Config.pp_simple { F.fprintf f "%a|%a|abducedRefParam" _pp pv Mangled.pp name } else { - F.fprintf f "%a$%a%a|abducedRefParam" Procname.pp n Location.pp l Mangled.pp name + F.fprintf f "%a$%a%a|abducedRefParam" Typ.Procname.pp n Location.pp l Mangled.pp name } | Global_var (fname, is_const, is_pod, _) => F.fprintf @@ -256,7 +256,7 @@ let is_frontend_tmp pvar => { let name = to_string pvar; is_sil_tmp name || ( switch pvar.pv_kind { - | Local_var pname => Procname.is_java pname && is_bytecode_tmp name + | Local_var pname => Typ.Procname.is_java pname && is_bytecode_tmp name | _ => false } ) @@ -282,7 +282,7 @@ let name_hash (name: Mangled.t) => Hashtbl.hash name; /** [mk name proc_name] creates a program var with the given function name */ -let mk (name: Mangled.t) (proc_name: Procname.t) :t => { +let mk (name: Mangled.t) (proc_name: Typ.Procname.t) :t => { pv_hash: name_hash name, pv_name: name, pv_kind: Local_var proc_name @@ -293,7 +293,7 @@ let get_ret_pvar pname => mk Ident.name_return pname; /** [mk_callee name proc_name] creates a program var for a callee function with the given function name */ -let mk_callee (name: Mangled.t) (proc_name: Procname.t) :t => { +let mk_callee (name: Mangled.t) (proc_name: Typ.Procname.t) :t => { pv_hash: name_hash name, pv_name: name, pv_kind: Callee_var proc_name @@ -323,13 +323,13 @@ let mk_tmp name pname => { /** create an abduced return variable for a call to [proc_name] at [loc] */ -let mk_abduced_ret (proc_name: Procname.t) (loc: Location.t) :t => { - let name = Mangled.from_string ("$RET_" ^ Procname.to_unique_id proc_name); +let mk_abduced_ret (proc_name: Typ.Procname.t) (loc: Location.t) :t => { + let name = Mangled.from_string ("$RET_" ^ Typ.Procname.to_unique_id proc_name); {pv_hash: name_hash name, pv_name: name, pv_kind: Abduced_retvar proc_name loc} }; -let mk_abduced_ref_param (proc_name: Procname.t) (pv: t) (loc: Location.t) :t => { - let name = Mangled.from_string ("$REF_PARAM_" ^ Procname.to_unique_id proc_name); +let mk_abduced_ref_param (proc_name: Typ.Procname.t) (pv: t) (loc: Location.t) :t => { + let name = Mangled.from_string ("$REF_PARAM_" ^ Typ.Procname.to_unique_id proc_name); {pv_hash: name_hash name, pv_name: name, pv_kind: Abduced_ref_param proc_name pv loc} }; @@ -355,7 +355,9 @@ let get_initializer_pname {pv_name, pv_kind} => switch pv_kind { | Global_var _ => Some ( - Procname.from_string_c_fun (Config.clang_initializer_prefix ^ Mangled.to_string_full pv_name) + Typ.Procname.from_string_c_fun ( + Config.clang_initializer_prefix ^ Mangled.to_string_full pv_name + ) ) | _ => None }; diff --git a/infer/src/IR/Pvar.rei b/infer/src/IR/Pvar.rei index af21488d8..263d77900 100644 --- a/infer/src/IR/Pvar.rei +++ b/infer/src/IR/Pvar.rei @@ -44,7 +44,7 @@ let get_name: t => Mangled.t; /** [get_ret_pvar proc_name] retuns the return pvar associated with the procedure name */ -let get_ret_pvar: Procname.t => t; +let get_ret_pvar: Typ.Procname.t => t; /** Get a simplified version of the name component of a program variable. */ @@ -88,20 +88,20 @@ let is_frontend_tmp: t => bool; /** [mk name proc_name suffix] creates a program var with the given function name and suffix */ -let mk: Mangled.t => Procname.t => t; +let mk: Mangled.t => Typ.Procname.t => t; /** create an abduced variable for a parameter passed by reference */ -let mk_abduced_ref_param: Procname.t => t => Location.t => t; +let mk_abduced_ref_param: Typ.Procname.t => t => Location.t => t; /** create an abduced return variable for a call to [proc_name] at [loc] */ -let mk_abduced_ret: Procname.t => Location.t => t; +let mk_abduced_ret: Typ.Procname.t => Location.t => t; /** [mk_callee name proc_name] creates a program var for a callee function with the given function name */ -let mk_callee: Mangled.t => Procname.t => t; +let mk_callee: Mangled.t => Typ.Procname.t => t; /** create a global variable with the given name */ @@ -110,7 +110,7 @@ let mk_global: /** create a fresh temporary variable local to procedure [pname]. for use in the frontends only! */ -let mk_tmp: string => Procname.t => t; +let mk_tmp: string => Typ.Procname.t => t; /** Pretty print a program variable. */ @@ -126,7 +126,7 @@ let pp_value: Pp.env => F.formatter => t => unit; /** Turn an ordinary program variable into a callee program variable */ -let to_callee: Procname.t => t => t; +let to_callee: Typ.Procname.t => t => t; /** Turn a pvar into a seed pvar (which stores the initial value of a stack var) */ @@ -152,6 +152,6 @@ let is_pod: t => bool; /** Get the procname of the initializer function for the given global variable */ -let get_initializer_pname: t => option Procname.t; +let get_initializer_pname: t => option Typ.Procname.t; let module Set: PrettyPrintable.PPSet with type elt = t; diff --git a/infer/src/IR/Sil.re b/infer/src/IR/Sil.re index 33b8214e5..cb7b0e951 100644 --- a/infer/src/IR/Sil.re +++ b/infer/src/IR/Sil.re @@ -515,7 +515,7 @@ let pp_instr pe0 f instr => { let is_block_pvar pvar => Typ.has_block_prefix (Mangled.to_string (Pvar.get_name pvar)); /* A block pvar used to explain retain cycles */ -let block_pvar = Pvar.mk (Mangled.from_string "block") (Procname.from_string_c_fun ""); +let block_pvar = Pvar.mk (Mangled.from_string "block") (Typ.Procname.from_string_c_fun ""); /** Dump an instruction. */ diff --git a/infer/src/IR/Tenv.re b/infer/src/IR/Tenv.re index 86ff0c67d..3ba74efaa 100644 --- a/infer/src/IR/Tenv.re +++ b/infer/src/IR/Tenv.re @@ -96,20 +96,22 @@ let add tenv name struct_typ => TypenameHash.replace tenv name struct_typ; let get_overriden_method tenv pname_java => { let struct_typ_get_method_by_name (struct_typ: Typ.Struct.t) method_name => List.find_exn - f::(fun meth => String.equal method_name (Procname.get_method meth)) struct_typ.methods; + f::(fun meth => String.equal method_name (Typ.Procname.get_method meth)) struct_typ.methods; let rec get_overriden_method_in_supers pname_java supers => switch supers { | [superclass, ...supers_tail] => switch (lookup tenv superclass) { | Some struct_typ => - try (Some (struct_typ_get_method_by_name struct_typ (Procname.java_get_method pname_java))) { + try ( + Some (struct_typ_get_method_by_name struct_typ (Typ.Procname.java_get_method pname_java)) + ) { | Not_found => get_overriden_method_in_supers pname_java (supers_tail @ struct_typ.supers) } | None => get_overriden_method_in_supers pname_java supers_tail } | [] => None }; - switch (lookup tenv (Procname.java_get_class_type_name pname_java)) { + switch (lookup tenv (Typ.Procname.java_get_class_type_name pname_java)) { | Some {supers} => get_overriden_method_in_supers pname_java supers | _ => None } diff --git a/infer/src/IR/Tenv.rei b/infer/src/IR/Tenv.rei index 1d76b0bd4..f1864c378 100644 --- a/infer/src/IR/Tenv.rei +++ b/infer/src/IR/Tenv.rei @@ -43,7 +43,7 @@ let mk_struct: default::Typ.Struct.t? => fields::Typ.Struct.fields? => statics::Typ.Struct.fields? => - methods::list Procname.t? => + methods::list Typ.Procname.t? => supers::list Typename.t? => annots::Annot.Item.t? => specialization::Typ.template_spec_info? => @@ -64,4 +64,4 @@ let store_to_file: DB.filename => t => unit; /** Get method that is being overriden by java_pname (if any) **/ -let get_overriden_method: t => Procname.java => option Procname.t; +let get_overriden_method: t => Typ.Procname.java => option Typ.Procname.t; diff --git a/infer/src/IR/Typ.re b/infer/src/IR/Typ.re index d2a4de6e2..3cf897267 100644 --- a/infer/src/IR/Typ.re +++ b/infer/src/IR/Typ.re @@ -288,14 +288,6 @@ let rec java_from_string = } | typ_str => Tstruct (Typename.Java.from_string typ_str); - -/** Return the return type of [pname_java]. */ -let java_proc_return_typ pname_java => - switch (java_from_string (Procname.java_get_return_type pname_java)) { - | Tstruct _ as typ => Tptr typ Pk_pointer - | typ => typ - }; - type typ = t [@@deriving compare]; /* template instantiation arguments */ @@ -304,6 +296,509 @@ type template_spec_info = | Template (string, list (option t)) [@@deriving compare]; +let module Procname = { + /* e.g. ("", "int") for primitive types or ("java.io", "PrintWriter") for objects */ + type java_type = (option string, string); + /* compare in inverse order */ + let compare_java_type (p1, c1) (p2, c2) => + [%compare : (string, option string)] (c1, p1) (c2, p2); + type method_kind = + | Non_Static /* in Java, procedures called with invokevirtual, invokespecial, and invokeinterface */ + | Static /* in Java, procedures called with invokestatic */ + [@@deriving compare]; + let equal_method_kind = [%compare.equal : method_kind]; + + /** Type of java procedure names. */ + type java = { + method_name: string, + parameters: list java_type, + class_name: Typename.t, + return_type: option java_type, /* option because constructors have no return type */ + kind: method_kind + } + [@@deriving compare]; + + /** Type of c procedure names. */ + type c = (string, option string) [@@deriving compare]; + type objc_cpp_method_kind = + | CPPMethod (option string) /** with mangling */ + | CPPConstructor (option string, bool) /** with mangling + is it constexpr? */ + | ObjCClassMethod + | ObjCInstanceMethod + | ObjCInternalMethod + [@@deriving compare]; + + /** Type of Objective C and C++ procedure names: method signatures. */ + type objc_cpp = {method_name: string, class_name: Typename.t, kind: objc_cpp_method_kind} + [@@deriving compare]; + + /** Type of Objective C block names. */ + type block = string [@@deriving compare]; + + /** Type of procedure names. */ + type t = + | Java java + | C c + | Linters_dummy_method + | Block block + | ObjC_Cpp objc_cpp + [@@deriving compare]; + let equal = [%compare.equal : t]; + + /** Level of verbosity of some to_string functions. */ + type detail_level = + | Verbose + | Non_verbose + | Simple + [@@deriving compare]; + let equal_detail_level = [%compare.equal : detail_level]; + let objc_method_kind_of_bool is_instance => + if is_instance {ObjCInstanceMethod} else {ObjCClassMethod}; + let empty_block = Block ""; + let is_verbose v => + switch v { + | Verbose => true + | _ => false + }; + + /** A type is a pair (package, type_name) that is translated in a string package.type_name */ + let java_type_to_string_verbosity p verbosity => + switch p { + | (None, typ) => typ + | (Some p, cls) => + if (is_verbose verbosity) { + p ^ "." ^ cls + } else { + cls + } + }; + let java_type_to_string p => java_type_to_string_verbosity p Verbose; + + /** Given a list of types, it creates a unique string of types separated by commas */ + let rec java_param_list_to_string inputList verbosity => + switch inputList { + | [] => "" + | [head] => java_type_to_string_verbosity head verbosity + | [head, ...rest] => + java_type_to_string_verbosity head verbosity ^ "," ^ java_param_list_to_string rest verbosity + }; + + /** It is the same as java_type_to_string, but Java return types are optional because of constructors without type */ + let java_return_type_to_string j verbosity => + switch j.return_type { + | None => "" + | Some typ => java_type_to_string_verbosity typ verbosity + }; + + /** Given a package.class_name string, it looks for the latest dot and split the string + in two (package, class_name) */ + let split_classname package_classname => + switch (String.rsplit2 package_classname on::'.') { + | Some (x, y) => (Some x, y) + | None => (None, package_classname) + }; + let split_typename typename => split_classname (Typename.name typename); + let from_string_c_fun (s: string) => C (s, None); + let c (plain: string) (mangled: string) => (plain, Some mangled); + let java class_name return_type method_name parameters kind => { + class_name, + return_type, + method_name, + parameters, + kind + }; + + /** Create an objc procedure name from a class_name and method_name. */ + let objc_cpp class_name method_name kind => {class_name, method_name, kind}; + let get_default_objc_class_method objc_class => { + let objc_cpp = objc_cpp objc_class "__find_class_" ObjCInternalMethod; + ObjC_Cpp objc_cpp + }; + + /** Create an objc procedure name from a class_name and method_name. */ + let mangled_objc_block name => Block name; + let is_java = + fun + | Java _ => true + | _ => false; + let is_c_method = + fun + | ObjC_Cpp _ => true + | _ => false; + let is_constexpr = + fun + | ObjC_Cpp {kind: CPPConstructor (_, true)} => true + | _ => false; + + /** Replace the class name component of a procedure name. + In case of Java, replace package and class name. */ + let replace_class t (new_class: Typename.t) => + switch t { + | Java j => Java {...j, class_name: new_class} + | ObjC_Cpp osig => ObjC_Cpp {...osig, class_name: new_class} + | C _ + | Block _ + | Linters_dummy_method => t + }; + + /** Get the class name of a Objective-C/C++ procedure name. */ + let objc_cpp_get_class_name objc_cpp => Typename.name objc_cpp.class_name; + let objc_cpp_get_class_type_name objc_cpp => objc_cpp.class_name; + + /** Return the package.classname of a java procname. */ + let java_get_class_name (j: java) => Typename.name j.class_name; + + /** Return the package.classname as a typename of a java procname. */ + let java_get_class_type_name (j: java) => j.class_name; + + /** Return the class name of a java procedure name. */ + let java_get_simple_class_name (j: java) => snd (split_classname (java_get_class_name j)); + + /** Return the package of a java procname. */ + let java_get_package (j: java) => fst (split_classname (java_get_class_name j)); + + /** Return the method of a java procname. */ + let java_get_method (j: java) => j.method_name; + + /** Replace the method of a java procname. */ + let java_replace_method (j: java) mname => {...j, method_name: mname}; + + /** Replace the return type of a java procname. */ + let java_replace_return_type j ret_type => {...j, return_type: Some ret_type}; + + /** Replace the parameters of a java procname. */ + let java_replace_parameters j parameters => {...j, parameters}; + + /** Return the method/function of a procname. */ + let get_method = + fun + | ObjC_Cpp name => name.method_name + | C (name, _) => name + | Block name => name + | Java j => j.method_name + | Linters_dummy_method => "Linters_dummy_method"; + + /** Return the language of the procedure. */ + let get_language = + fun + | ObjC_Cpp _ => Config.Clang + | C _ => Config.Clang + | Block _ => Config.Clang + | Linters_dummy_method => Config.Clang + | Java _ => Config.Java; + + /** Return the return type of a java procname. */ + let java_get_return_type (j: java) => java_return_type_to_string j Verbose; + + /** Return the parameters of a java procname. */ + let java_get_parameters j => j.parameters; + + /** Return the parameters of a java procname as strings. */ + let java_get_parameters_as_strings j => + List.map f::(fun param => java_type_to_string param) j.parameters; + + /** Return true if the java procedure is static */ + let java_is_static = + fun + | Java j => equal_method_kind j.kind Static + | _ => false; + + /** Prints a string of a java procname with the given level of verbosity */ + let java_to_string withclass::withclass=false (j: java) verbosity => + switch verbosity { + | Verbose + | Non_verbose => + /* if verbose, then package.class.method(params): rtype, + else rtype package.class.method(params) + verbose is used for example to create unique filenames, non_verbose to create reports */ + let return_type = java_return_type_to_string j verbosity; + let params = java_param_list_to_string j.parameters verbosity; + let class_name = java_type_to_string_verbosity (split_typename j.class_name) verbosity; + let separator = + switch (j.return_type, verbosity) { + | (None, _) => "" + | (Some _, Verbose) => ":" + | _ => " " + }; + let output = class_name ^ "." ^ j.method_name ^ "(" ^ params ^ ")"; + if (equal_detail_level verbosity Verbose) { + output ^ separator ^ return_type + } else { + return_type ^ separator ^ output + } + | Simple => + /* methodname(...) or without ... if there are no parameters */ + let cls_prefix = + if withclass { + java_type_to_string_verbosity (split_typename j.class_name) verbosity ^ "." + } else { + "" + }; + let params = + switch j.parameters { + | [] => "" + | _ => "..." + }; + let method_name = + if (String.equal j.method_name "") { + java_get_simple_class_name j + } else { + cls_prefix ^ j.method_name + }; + method_name ^ "(" ^ params ^ ")" + }; + + /** Check if the class name is for an anonymous inner class. */ + let is_anonymous_inner_class_name class_name => { + let class_name_no_package = snd (split_typename class_name); + switch (String.rsplit2 class_name_no_package on::'$') { + | Some (_, s) => + let is_int = + try { + ignore (int_of_string (String.strip s)); + true + } { + | Failure _ => false + }; + is_int + | None => false + } + }; + + /** Check if the procedure belongs to an anonymous inner class. */ + let java_is_anonymous_inner_class = + fun + | Java j => is_anonymous_inner_class_name j.class_name + | _ => false; + + /** Check if the last parameter is a hidden inner class, and remove it if present. + This is used in private constructors, where a proxy constructor is generated + with an extra parameter and calls the normal constructor. */ + let java_remove_hidden_inner_class_parameter = + fun + | Java js => + switch (List.rev js.parameters) { + | [(_, s), ...par'] => + if (is_anonymous_inner_class_name (Typename.Java.from_string s)) { + Some (Java {...js, parameters: List.rev par'}) + } else { + None + } + | [] => None + } + | _ => None; + + /** Check if the procedure name is an anonymous inner class constructor. */ + let java_is_anonymous_inner_class_constructor = + fun + | Java js => is_anonymous_inner_class_name js.class_name + | _ => false; + + /** Check if the procedure name is an acess method (e.g. access$100 used to + access private members from a nested class. */ + let java_is_access_method = + fun + | Java js => + switch (String.rsplit2 js.method_name on::'$') { + | Some ("access", s) => + let is_int = + try { + ignore (int_of_string s); + true + } { + | Failure _ => false + }; + is_int + | _ => false + } + | _ => false; + + /** Check if the procedure name is of an auto-generated method containing '$'. */ + let java_is_autogen_method = + fun + | Java js => String.contains js.method_name '$' + | _ => false; + + /** Check if the proc name has the type of a java vararg. + Note: currently only checks that the last argument has type Object[]. */ + let java_is_vararg = + fun + | Java js => + switch (List.rev js.parameters) { + | [(_, "java.lang.Object[]"), ..._] => true + | _ => false + } + | _ => false; + let is_objc_constructor method_name => + String.equal method_name "new" || String.is_prefix prefix::"init" method_name; + let is_objc_kind = + fun + | ObjCClassMethod + | ObjCInstanceMethod + | ObjCInternalMethod => true + | _ => false; + + /** [is_constructor pname] returns true if [pname] is a constructor */ + let is_constructor = + fun + | Java js => String.equal js.method_name "" + | ObjC_Cpp {kind: CPPConstructor _} => true + | ObjC_Cpp {kind, method_name} when is_objc_kind kind => is_objc_constructor method_name + | _ => false; + let is_objc_dealloc method_name => String.equal method_name "dealloc"; + + /** [is_dealloc pname] returns true if [pname] is the dealloc method in Objective-C + TODO: add case for C++ */ + let is_destructor = + fun + | ObjC_Cpp name => is_objc_dealloc name.method_name + | _ => false; + let java_is_close = + fun + | Java js => String.equal js.method_name "close" + | _ => false; + + /** [is_class_initializer pname] returns true if [pname] is a class initializer */ + let is_class_initializer = + fun + | Java js => String.equal js.method_name "" + | _ => false; + + /** [is_infer_undefined pn] returns true if [pn] is a special Infer undefined proc */ + let is_infer_undefined pn => + switch pn { + | Java j => + let regexp = Str.regexp "com.facebook.infer.builtins.InferUndefined"; + Str.string_match regexp (java_get_class_name j) 0 + | _ => + /* TODO: add cases for obj-c, c, c++ */ + false + }; + let get_global_name_of_initializer = + fun + | C (name, _) when String.is_prefix prefix::Config.clang_initializer_prefix name => { + let prefix_len = String.length Config.clang_initializer_prefix; + Some (String.sub name pos::prefix_len len::(String.length name - prefix_len)) + } + | _ => None; + + /** to_string for C_function type */ + let to_readable_string (c1, c2) verbose => { + let plain = c1; + if verbose { + switch c2 { + | None => plain + | Some s => plain ^ "{" ^ s ^ "}" + } + } else { + plain + } + }; + let c_method_to_string osig detail_level => + switch detail_level { + | Simple => osig.method_name + | Non_verbose => Typename.name osig.class_name ^ "_" ^ osig.method_name + | Verbose => + let m_str = + switch osig.kind { + | CPPMethod m => + "(" ^ + ( + switch m { + | None => "" + | Some s => s + } + ) ^ ")" + | CPPConstructor (m, is_constexpr) => + "{" ^ + ( + switch m { + | None => "" + | Some s => s + } + ) ^ + (if is_constexpr {"|constexpr"} else {""}) ^ "}" + | ObjCClassMethod => "class" + | ObjCInstanceMethod => "instance" + | ObjCInternalMethod => "internal" + }; + Typename.name osig.class_name ^ "_" ^ osig.method_name ^ m_str + }; + + /** Very verbose representation of an existing Procname.t */ + let to_unique_id pn => + switch pn { + | Java j => java_to_string j Verbose + | C (c1, c2) => to_readable_string (c1, c2) true + | ObjC_Cpp osig => c_method_to_string osig Verbose + | Block name => name + | Linters_dummy_method => "Linters_dummy_method" + }; + + /** Convert a proc name to a string for the user to see */ + let to_string p => + switch p { + | Java j => java_to_string j Non_verbose + | C (c1, c2) => to_readable_string (c1, c2) false + | ObjC_Cpp osig => c_method_to_string osig Non_verbose + | Block name => name + | Linters_dummy_method => to_unique_id p + }; + + /** Convenient representation of a procname for external tools (e.g. eclipse plugin) */ + let to_simplified_string withclass::withclass=false p => + switch p { + | Java j => java_to_string withclass::withclass j Simple + | C (c1, c2) => to_readable_string (c1, c2) false ^ "()" + | ObjC_Cpp osig => c_method_to_string osig Simple + | Block _ => "block" + | Linters_dummy_method => to_unique_id p + }; + + /** Convert a proc name to a filename */ + let to_filename proc_name => + Escape.escape_filename @@ SourceFile.append_crc_cutoff @@ to_unique_id proc_name; + + /** Pretty print a proc name */ + let pp f pn => F.fprintf f "%s" (to_string pn); + + /** hash function for procname */ + let hash_pname = Hashtbl.hash; + let module Hash = Hashtbl.Make { + type nonrec t = t; + let equal = equal; + let hash = hash_pname; + }; + let module Map = Caml.Map.Make { + type nonrec t = t; + let compare = compare; + }; + let module Set = Caml.Set.Make { + type nonrec t = t; + let compare = compare; + }; + + /** Pretty print a set of proc names */ + let pp_set fmt set => Set.iter (fun pname => F.fprintf fmt "%a " pp pname) set; + let get_qualifiers pname => + switch pname { + | C c => fst c |> QualifiedCppName.qualifiers_of_qual_name + | ObjC_Cpp objc_cpp => + List.append + (QualifiedCppName.qualifiers_of_qual_name (Typename.name objc_cpp.class_name)) + [objc_cpp.method_name] + | _ => [] + }; +}; + + +/** Return the return type of [pname_java]. */ +let java_proc_return_typ pname_java => + switch (java_from_string (Procname.java_get_return_type pname_java)) { + | Tstruct _ as typ => Tptr typ Pk_pointer + | typ => typ + }; + let module Struct = { type field = (Ident.fieldname, T.t, Annot.Item.t) [@@deriving compare]; type fields = list field; diff --git a/infer/src/IR/Typ.rei b/infer/src/IR/Typ.rei index 77542cad0..029a596df 100644 --- a/infer/src/IR/Typ.rei +++ b/infer/src/IR/Typ.rei @@ -148,10 +148,6 @@ let is_block_type: t => bool; let unsome: string => option t => t; - -/** Return the return type of [pname_java]. */ -let java_proc_return_typ: Procname.java => t; - type typ = t; /* template instantiation arguments */ @@ -160,6 +156,219 @@ type template_spec_info = | Template (string, list (option t)) [@@deriving compare]; +let module Procname: { + + /** Module for Procedure Names. */ + + /** Type of java procedure names. */ + type java; + + /** Type of c procedure names. */ + type c; + + /** Type of Objective C and C++ procedure names. */ + type objc_cpp; + + /** Type of Objective C block names. */ + type block; + + /** Type of procedure names. */ + type t = + | Java java + | C c + | Linters_dummy_method + | Block block + | ObjC_Cpp objc_cpp + [@@deriving compare]; + + /** Equality for proc names. */ + let equal: t => t => bool; + type java_type = (option string, string); + type method_kind = + | Non_Static /* in Java, procedures called with invokevirtual, invokespecial, and invokeinterface */ + | Static /* in Java, procedures called with invokestatic */; + type objc_cpp_method_kind = + | CPPMethod (option string) /** with mangling */ + | CPPConstructor (option string, bool) /** with mangling + is it constexpr? */ + | ObjCClassMethod + | ObjCInstanceMethod + | ObjCInternalMethod; + + /** Hash tables with proc names as keys. */ + let module Hash: Caml.Hashtbl.S with type key = t; + + /** Maps from proc names. */ + let module Map: Caml.Map.S with type key = t; + + /** Sets of proc names. */ + let module Set: Caml.Set.S with type elt = t; + + /** Create a C procedure name from plain and mangled name. */ + let c: string => string => c; + + /** Empty block name. */ + let empty_block: t; + + /** Convert a string to a proc name. */ + let from_string_c_fun: string => t; + + /** Return the language of the procedure. */ + let get_language: t => Config.language; + + /** Return the method/function of a procname. */ + let get_method: t => string; + + /** Hash function for procname. */ + let hash_pname: t => int; + + /** Check if a class string is an anoynmous inner class name. */ + let is_anonymous_inner_class_name: Typename.t => bool; + + /** Check if this is an Objective-C/C++ method name. */ + let is_c_method: t => bool; + + /** Check if this is a constructor method in Objective-C. */ + let is_objc_constructor: string => bool; + + /** Check if this is a constructor. */ + let is_constructor: t => bool; + + /** Check if this is a constexpr function. */ + let is_constexpr: t => bool; + + /** Check if this is a Java procedure name. */ + let is_java: t => bool; + + /** Check if this is a dealloc method in Objective-C. */ + let is_objc_dealloc: string => bool; + + /** Check if this is a dealloc method. */ + let is_destructor: t => bool; + + /** Create a Java procedure name from its + class_name method_name args_type_name return_type_name method_kind. */ + let java: Typename.t => option java_type => string => list java_type => method_kind => java; + + /** Replace the parameters of a java procname. */ + let java_replace_parameters: java => list java_type => java; + + /** Replace the method of a java procname. */ + let java_replace_return_type: java => java_type => java; + + /** Create an objc block name. */ + let mangled_objc_block: string => t; + + /** Create an objc procedure name from a class_name and method_name. */ + let objc_cpp: Typename.t => string => objc_cpp_method_kind => objc_cpp; + let get_default_objc_class_method: Typename.t => t; + + /** Get the class name of a Objective-C/C++ procedure name. */ + let objc_cpp_get_class_name: objc_cpp => string; + let objc_cpp_get_class_type_name: objc_cpp => Typename.t; + + /** Create ObjC method type from a bool is_instance. */ + let objc_method_kind_of_bool: bool => objc_cpp_method_kind; + + /** Return the class name of a java procedure name. */ + let java_get_class_name: java => string; + + /** Return the class name as a typename of a java procedure name. */ + let java_get_class_type_name: java => Typename.t; + + /** Return the simple class name of a java procedure name. */ + let java_get_simple_class_name: java => string; + + /** Return the package name of a java procedure name. */ + let java_get_package: java => option string; + + /** Return the method name of a java procedure name. */ + let java_get_method: java => string; + + /** Return the return type of a java procedure name. */ + let java_get_return_type: java => string; + + /** Return the parameters of a java procedure name. */ + let java_get_parameters: java => list java_type; + + /** Return the parameters of a java procname as strings. */ + let java_get_parameters_as_strings: java => list string; + + /** Check if the procedure name is an acess method (e.g. access$100 used to + access private members from a nested class. */ + let java_is_access_method: t => bool; + + /** Check if the procedure name is of an auto-generated method containing '$'. */ + let java_is_autogen_method: t => bool; + + /** Check if the procedure belongs to an anonymous inner class. */ + let java_is_anonymous_inner_class: t => bool; + + /** Check if the procedure name is an anonymous inner class constructor. */ + let java_is_anonymous_inner_class_constructor: t => bool; + + /** Check if the method name is "close". */ + let java_is_close: t => bool; + + /** Check if the java procedure is static. */ + let java_is_static: t => bool; + + /** Check if the proc name has the type of a java vararg. + Note: currently only checks that the last argument has type Object[]. */ + let java_is_vararg: t => bool; + + /** Check if the last parameter is a hidden inner class, and remove it if present. + This is used in private constructors, where a proxy constructor is generated + with an extra parameter and calls the normal constructor. */ + let java_remove_hidden_inner_class_parameter: t => option t; + + /** Replace the method name of an existing java procname. */ + let java_replace_method: java => string => java; + + /** Convert a java type to a string. */ + let java_type_to_string: java_type => string; + + /** Check if this is a class initializer. */ + let is_class_initializer: t => bool; + + /** Check if this is a special Infer undefined procedure. */ + let is_infer_undefined: t => bool; + + /** Return the name of the global for which this procedure is the initializer if this is an + initializer, None otherwise. */ + let get_global_name_of_initializer: t => option string; + + /** Pretty print a proc name. */ + let pp: Format.formatter => t => unit; + + /** Pretty print a set of proc names. */ + let pp_set: Format.formatter => Set.t => unit; + + /** Replace the class name component of a procedure name. + In case of Java, replace package and class name. */ + let replace_class: t => Typename.t => t; + + /** Given a package.class_name string, look for the latest dot and split the string + in two (package, class_name). */ + let split_classname: string => (option string, string); + + /** Convert a proc name to a string for the user to see. */ + let to_string: t => string; + + /** Convert a proc name into a easy string for the user to see in an IDE. */ + let to_simplified_string: withclass::bool? => t => string; + + /** Convert a proc name into a unique identifier. */ + let to_unique_id: t => string; + + /** Convert a proc name to a filename. */ + let to_filename: t => string; + let get_qualifiers: t => list string; +}; + + +/** Return the return type of [pname_java]. */ +let java_proc_return_typ: Procname.java => t; + let module Struct: { type field = (Ident.fieldname, typ, Annot.Item.t) [@@deriving compare]; type fields = list field; diff --git a/infer/src/backend/Attribute.mli b/infer/src/backend/Attribute.mli index d12dad297..ce8b67ec5 100644 --- a/infer/src/backend/Attribute.mli +++ b/infer/src/backend/Attribute.mli @@ -91,7 +91,7 @@ val nullify_exp_with_objc_null : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Prop.n (** mark Exp.Var's or Exp.Lvar's as undefined *) val mark_vars_as_undefined : - Tenv.t -> Prop.normal Prop.t -> Exp.t list -> Procname.t -> Annot.Item.t -> + Tenv.t -> Prop.normal Prop.t -> Exp.t list -> Typ.Procname.t -> Annot.Item.t -> Location.t -> PredSymb.path_pos -> Prop.normal Prop.t (** type for arithmetic problems *) diff --git a/infer/src/backend/BuiltinDefn.ml b/infer/src/backend/BuiltinDefn.ml index a07559ba8..146b69817 100644 --- a/infer/src/backend/BuiltinDefn.ml +++ b/infer/src/backend/BuiltinDefn.ml @@ -669,7 +669,7 @@ let execute_abort { Builtin.proc_name; } : Builtin.ret_typ = raise (Exceptions.Precondition_not_found - (Localise.verbatim_desc (Procname.to_string proc_name), __POS__)) + (Localise.verbatim_desc (Typ.Procname.to_string proc_name), __POS__)) let execute_exit { Builtin.prop_; path; } : Builtin.ret_typ = @@ -834,7 +834,7 @@ let execute_pthread_create ({ Builtin.tenv; prop_; path; args; } as builtin_args let fun_string = Mangled.to_string fun_name in L.d_strln ("pthread_create: calling function " ^ fun_string); begin - match Specs.get_summary (Procname.from_string_c_fun fun_string) with + match Specs.get_summary (Typ.Procname.from_string_c_fun fun_string) with | None -> assert false | Some callee_summary -> SymExec.proc_call callee_summary diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index 5374a312e..2d5a76900 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -170,8 +170,8 @@ let summary_values summary => { }; let pp_failure failure => F.asprintf "%a" SymOp.pp_failure_kind failure; { - vname: Procname.to_string proc_name, - vname_id: Procname.to_filename proc_name, + vname: Typ.Procname.to_string proc_name, + vname_id: Typ.Procname.to_filename proc_name, vspecs: List.length specs, vtime: Printf.sprintf "%.0f" stats.Specs.stats_time, vto: Option.value_map f::pp_failure default::"NONE" stats.Specs.stats_failure, @@ -401,7 +401,7 @@ let module IssuesCsv = { }; let kind = Exceptions.err_kind_string ekind; let type_str = Localise.to_string error_name; - let procedure_id = Procname.to_filename procname; + let procedure_id = Typ.Procname.to_filename procname; let filename = SourceFile.to_string source_file; let always_report = switch (Localise.error_desc_extract_tag_value error_desc "always_report") { @@ -416,7 +416,7 @@ let module IssuesCsv = { pp "\"%s\"," err_desc_string; pp "%s," severity; pp "%d," loc.Location.line; - pp "\"%s\"," (Escape.escape_csv (Procname.to_string procname)); + pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_string procname)); pp "\"%s\"," (Escape.escape_csv procedure_id); pp "%s," filename; pp "\"%s\"," (Escape.escape_csv trace); @@ -467,7 +467,7 @@ let module IssuesJson = { ) { let kind = Exceptions.err_kind_string ekind; let bug_type = Localise.to_string error_name; - let procedure_id = Procname.to_filename procname; + let procedure_id = Typ.Procname.to_filename procname; let file = SourceFile.to_string source_file; let json_ml_loc = switch ml_loc_opt { @@ -485,7 +485,7 @@ let module IssuesJson = { visibility, line: loc.Location.line, column: loc.Location.col, - procedure: Procname.to_string procname, + procedure: Typ.Procname.to_string procname, procedure_id, procedure_start_line, file, @@ -651,8 +651,8 @@ let module IssuesXml = { let attributes = [("id", string_of_int !xml_issues_id)]; let error_class = Exceptions.err_class_string eclass; let error_line = string_of_int loc.Location.line; - let procedure_name = Procname.to_string proc_name; - let procedure_id = Procname.to_filename proc_name; + let procedure_name = Typ.Procname.to_string proc_name; + let procedure_id = Typ.Procname.to_filename proc_name; let filename = SourceFile.to_string source_file; let bug_hash = get_bug_hash kind type_str procedure_id filename node_key error_desc; let forest = [ @@ -694,10 +694,10 @@ let module CallsCsv = { let stats = summary.Specs.stats; let caller_name = Specs.get_proc_name summary; let do_call (callee_name, loc) trace => { - pp "\"%s\"," (Escape.escape_csv (Procname.to_string caller_name)); - pp "\"%s\"," (Escape.escape_csv (Procname.to_filename caller_name)); - pp "\"%s\"," (Escape.escape_csv (Procname.to_string callee_name)); - pp "\"%s\"," (Escape.escape_csv (Procname.to_filename callee_name)); + pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_string caller_name)); + pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_filename caller_name)); + pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_string callee_name)); + pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_filename callee_name)); pp "%s," (SourceFile.to_string summary.Specs.attributes.ProcAttributes.loc.Location.file); pp "%d," loc.Location.line; pp "%a@\n" Specs.CallStats.pp_trace trace @@ -864,7 +864,7 @@ let module Summary = { } else { L.stdout "Procedure: %a@\n%a@." - Procname.pp + Typ.Procname.pp proc_name (Specs.pp_summary_text whole_seconds::Config.whole_seconds) summary @@ -875,7 +875,7 @@ let module Summary = { let write_summary_latex fmt summary => { let proc_name = Specs.get_proc_name summary; Latex.pp_section - fmt ("Analysis of function " ^ Latex.convert_string (Procname.to_string proc_name)); + fmt ("Analysis of function " ^ Latex.convert_string (Typ.Procname.to_string proc_name)); F.fprintf fmt "@[%a@]" (Specs.pp_summary_latex Black whole_seconds::Config.whole_seconds) summary }; @@ -942,16 +942,16 @@ let module PreconditionStats = { switch (Prop.CategorizePreconditions.categorize preconditions) { | Prop.CategorizePreconditions.Empty => incr nr_empty; - L.stdout "Procedure: %a footprint:Empty@." Procname.pp proc_name + L.stdout "Procedure: %a footprint:Empty@." Typ.Procname.pp proc_name | Prop.CategorizePreconditions.OnlyAllocation => incr nr_onlyallocation; - L.stdout "Procedure: %a footprint:OnlyAllocation@." Procname.pp proc_name + L.stdout "Procedure: %a footprint:OnlyAllocation@." Typ.Procname.pp proc_name | Prop.CategorizePreconditions.NoPres => incr nr_nopres; - L.stdout "Procedure: %a footprint:NoPres@." Procname.pp proc_name + L.stdout "Procedure: %a footprint:NoPres@." Typ.Procname.pp proc_name | Prop.CategorizePreconditions.DataConstraints => incr nr_dataconstraints; - L.stdout "Procedure: %a footprint:DataConstraints@." Procname.pp proc_name + L.stdout "Procedure: %a footprint:DataConstraints@." Typ.Procname.pp proc_name } }; let pp_stats () => { @@ -1379,7 +1379,7 @@ let pp_summary_and_issues formats_by_report_kind => { }; { LintIssues.load_issues_to_errlog_map Config.lint_issues_dir_name; - Procname.Map.iter + Typ.Procname.Map.iter (pp_lint_issues filters formats_by_report_kind linereader) !LintIssues.errLogMap }; finalize_and_close_files formats_by_report_kind stats pdflatex diff --git a/infer/src/backend/OndemandCapture.ml b/infer/src/backend/OndemandCapture.ml index 8413f6bee..45ef34d17 100644 --- a/infer/src/backend/OndemandCapture.ml +++ b/infer/src/backend/OndemandCapture.ml @@ -40,19 +40,19 @@ let try_capture (attributes : ProcAttributes.t) : ProcAttributes.t option = Logging.out "Captured file %a to get procedure %a but it wasn't found there@\n" SourceFile.pp definition_file - Procname.pp attributes.proc_name + Typ.Procname.pp attributes.proc_name ) ) else ( Logging.out "Wanted to capture file %a to get procedure %a but file was already captured@\n" SourceFile.pp definition_file - Procname.pp attributes.proc_name + Typ.Procname.pp attributes.proc_name ) in match definition_file_opt with | None -> Logging.out "Couldn't find source file for %a (declared in %a)@\n" - Procname.pp attributes.proc_name + Typ.Procname.pp attributes.proc_name SourceFile.pp decl_file | Some file -> try_compile file ); diff --git a/infer/src/backend/PropUtil.re b/infer/src/backend/PropUtil.re index 022eef928..0d11016db 100644 --- a/infer/src/backend/PropUtil.re +++ b/infer/src/backend/PropUtil.re @@ -12,7 +12,7 @@ let get_name_of_local (curr_f: Procdesc.t) (x, _) => Pvar.mk x (Procdesc.get_pro /* returns a list of local static variables (ie local variables defined static) in a proposition */ let get_name_of_objc_static_locals (curr_f: Procdesc.t) p => { - let pname = Procname.to_string (Procdesc.get_proc_name curr_f); + let pname = Typ.Procname.to_string (Procdesc.get_proc_name curr_f); let local_static e => switch e { /* is a local static if it's a global and it has a static local name */ diff --git a/infer/src/backend/abs.mli b/infer/src/backend/abs.mli index e3923635f..be33027b5 100644 --- a/infer/src/backend/abs.mli +++ b/infer/src/backend/abs.mli @@ -16,27 +16,27 @@ open! IStd type rules (** Abstract a proposition. *) -val abstract : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t +val abstract : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Check whether the prop contains junk. If it does, and [Config.allowleak] is true, remove the junk, otherwise raise a Leak exception. *) val abstract_junk : ?original_prop:Prop.normal Prop.t -> - Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t + Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Abstract a proposition but don't pay a SymOp *) -val abstract_no_symop : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t +val abstract_no_symop : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Get the current rules discoveres *) val get_current_rules : unit -> rules (** Abstract each proposition in [propset] *) -val lifted_abstract : Procname.t -> Tenv.t -> Propset.t -> Propset.t +val lifted_abstract : Typ.Procname.t -> Tenv.t -> Propset.t -> Propset.t (** Remove redundant elements in an array, and check for junk afterwards *) val remove_redundant_array_elements : - Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t + Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Reset the abstraction rules discovered *) val reset_current_rules : unit -> unit diff --git a/infer/src/backend/builtin.ml b/infer/src/backend/builtin.ml index 92bfe46fa..45dafac8b 100644 --- a/infer/src/backend/builtin.ml +++ b/infer/src/backend/builtin.ml @@ -19,7 +19,7 @@ type args = { path : Paths.Path.t; ret_id : (Ident.t * Typ.t) option; args : (Exp.t * Typ.t) list; - proc_name : Procname.t; + proc_name : Typ.Procname.t; loc : Location.t; } @@ -30,33 +30,33 @@ type t = args -> ret_typ type registered = t (** builtin function names for which we do symbolic execution *) -let builtin_functions = Procname.Hash.create 4 +let builtin_functions = Typ.Procname.Hash.create 4 let check_register_populated () = (* check if BuiltinDefn were loaded before accessing register *) - if Int.equal (Procname.Hash.length builtin_functions) 0 then + if Int.equal (Typ.Procname.Hash.length builtin_functions) 0 then failwith "Builtins were not initialized" (** check if the function is a builtin *) let is_registered name = - Procname.Hash.mem builtin_functions name || (check_register_populated (); false) + Typ.Procname.Hash.mem builtin_functions name || (check_register_populated (); false) (** get the symbolic execution handler associated to the builtin function name *) let get name : t option = - try Some (Procname.Hash.find builtin_functions name) + try Some (Typ.Procname.Hash.find builtin_functions name) with Not_found -> (check_register_populated (); None) -(** register a builtin [Procname.t] and symbolic execution handler *) +(** register a builtin [Typ.Procname.t] and symbolic execution handler *) let register proc_name sym_exe_fun : registered = - Procname.Hash.replace builtin_functions proc_name sym_exe_fun; + Typ.Procname.Hash.replace builtin_functions proc_name sym_exe_fun; sym_exe_fun (** print the functions registered *) let pp_registered fmt () = let builtin_names = ref [] in - Procname.Hash.iter (fun name _ -> builtin_names := name :: !builtin_names) builtin_functions; - builtin_names := List.sort ~cmp:Procname.compare !builtin_names; - let pp pname = Format.fprintf fmt "%a@\n" Procname.pp pname in + Typ.Procname.Hash.iter (fun name _ -> builtin_names := name :: !builtin_names) builtin_functions; + builtin_names := List.sort ~cmp:Typ.Procname.compare !builtin_names; + let pp pname = Format.fprintf fmt "%a@\n" Typ.Procname.pp pname in Format.fprintf fmt "Registered builtins:@\n @["; List.iter ~f:pp !builtin_names; Format.fprintf fmt "@]@." diff --git a/infer/src/backend/builtin.mli b/infer/src/backend/builtin.mli index 1e931ffbd..2df99e270 100644 --- a/infer/src/backend/builtin.mli +++ b/infer/src/backend/builtin.mli @@ -19,7 +19,7 @@ type args = { path : Paths.Path.t; ret_id : (Ident.t * Typ.t) option; args : (Exp.t * Typ.t) list; - proc_name : Procname.t; + proc_name : Typ.Procname.t; loc : Location.t; } @@ -29,13 +29,13 @@ type t = args -> ret_typ type registered -val register : Procname.t -> t -> registered -(** Register a builtin [Procname.t] and symbolic execution handler *) +val register : Typ.Procname.t -> t -> registered +(** Register a builtin [Typ.Procname.t] and symbolic execution handler *) -val is_registered : Procname.t -> bool +val is_registered : Typ.Procname.t -> bool (** Check if the function is a builtin *) -val get : Procname.t -> t option +val get : Typ.Procname.t -> t option (** Get the symbolic execution handler associated to the builtin function name *) val print_and_exit : unit -> 'a diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 672e3ab53..970f7693c 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -14,11 +14,11 @@ module L = Logging (** Module to register and invoke callbacks *) type proc_callback_args = { - get_proc_desc : Procname.t -> Procdesc.t option; - get_procs_in_file : Procname.t -> Procname.t list; + get_proc_desc : Typ.Procname.t -> Procdesc.t option; + get_procs_in_file : Typ.Procname.t -> Typ.Procname.t list; idenv : Idenv.t; tenv : Tenv.t; - proc_name : Procname.t; + proc_name : Typ.Procname.t; proc_desc : Procdesc.t; } @@ -26,9 +26,9 @@ type proc_callback_t = proc_callback_args -> unit type cluster_callback_t = Exe_env.t -> - Procname.t list -> - (Procname.t -> Procdesc.t option) -> - (Idenv.t * Tenv.t * Procname.t * Procdesc.t) list -> + Typ.Procname.t list -> + (Typ.Procname.t -> Procdesc.t option) -> + (Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit let procedure_callbacks = ref [] @@ -54,7 +54,7 @@ let get_procedure_definition exe_env proc_name = (idenv, tenv, proc_name, proc_desc, language)) (Exe_env.get_proc_desc exe_env proc_name) -let get_language proc_name = if Procname.is_java proc_name then Config.Java else Config.Clang +let get_language proc_name = if Typ.Procname.is_java proc_name then Config.Java else Config.Clang let reset_summary proc_name = @@ -163,8 +163,8 @@ let iterate_callbacks call_graph exe_env = let cluster_id proc_name = match proc_name with - | Procname.Java pname_java -> - Procname.java_get_class_name pname_java + | Typ.Procname.Java pname_java -> + Typ.Procname.java_get_class_name pname_java | _ -> "unknown" in let cluster proc_names = diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index 985e25fe1..162313bac 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -12,11 +12,11 @@ open! IStd (** Module to register and invoke callbacks *) type proc_callback_args = { - get_proc_desc : Procname.t -> Procdesc.t option; - get_procs_in_file : Procname.t -> Procname.t list; + get_proc_desc : Typ.Procname.t -> Procdesc.t option; + get_procs_in_file : Typ.Procname.t -> Typ.Procname.t list; idenv : Idenv.t; tenv : Tenv.t; - proc_name : Procname.t; + proc_name : Typ.Procname.t; proc_desc : Procdesc.t; } @@ -30,9 +30,9 @@ type proc_callback_t = proc_callback_args -> unit type cluster_callback_t = Exe_env.t -> - Procname.t list -> - (Procname.t -> Procdesc.t option) -> - (Idenv.t * Tenv.t * Procname.t * Procdesc.t) list -> + Typ.Procname.t list -> + (Typ.Procname.t -> Procdesc.t option) -> + (Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit (** register a procedure callback *) diff --git a/infer/src/backend/dom.mli b/infer/src/backend/dom.mli index 1cba10888..61921c7f2 100644 --- a/infer/src/backend/dom.mli +++ b/infer/src/backend/dom.mli @@ -16,7 +16,7 @@ open! IStd (** Join two pathsets *) val pathset_join : - Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t -> Paths.PathSet.t * Paths.PathSet.t + Typ.Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t -> Paths.PathSet.t * Paths.PathSet.t val join_time : float ref @@ -25,7 +25,7 @@ val proplist_collapse_pre : Tenv.t -> Prop.normal Prop.t list -> Prop.normal Spe val pathset_collapse : Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t (** reduce the pathset only based on implication checking. *) -val pathset_collapse_impl : Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t +val pathset_collapse_impl : Typ.Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t (** {2 Meet Operators} *) diff --git a/infer/src/backend/dotty.ml b/infer/src/backend/dotty.ml index 8a7aec2dc..e5e646199 100644 --- a/infer/src/backend/dotty.ml +++ b/infer/src/backend/dotty.ml @@ -951,7 +951,7 @@ let pp_proplist_parsed2dotty_file filename plist = (* channel. You have to compute an interprocedural cfg first *) let pp_cfgnodename pname fmt (n : Procdesc.Node.t) = - F.fprintf fmt "\"%s_%d\"" (Procname.to_filename pname) (Procdesc.Node.get_id n :> int) + F.fprintf fmt "\"%s_%d\"" (Typ.Procname.to_filename pname) (Procdesc.Node.get_id n :> int) let pp_etlist fmt etl = List.iter ~f:(fun (id, ty) -> @@ -965,7 +965,7 @@ let pp_cfgnodelabel pdesc fmt (n : Procdesc.Node.t) = let pp_label fmt n = match Procdesc.Node.get_kind n with | Procdesc.Node.Start_node pname -> - let pname_string = Procname.to_string pname in + let pname_string = Typ.Procname.to_string pname in Format.fprintf fmt "Start %s\\nFormals: %a\\nLocals: %a" pname_string pp_etlist (Procdesc.get_formals pdesc) @@ -978,7 +978,7 @@ let pp_cfgnodelabel pdesc fmt (n : Procdesc.Node.t) = if not (Annot.Method.is_empty method_annotation) then Format.fprintf fmt "\\nAnnotation: %a" (Annot.Method.pp pname_string) method_annotation | Procdesc.Node.Exit_node pname -> - Format.fprintf fmt "Exit %s" (Procname.to_string pname) + Format.fprintf fmt "Exit %s" (Typ.Procname.to_string pname) | Procdesc.Node.Join_node -> Format.fprintf fmt "+" | Procdesc.Node.Prune_node (is_true_branch, _, _) -> diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index e8cd344d0..463f690c8 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -26,8 +26,8 @@ let is_one_of_classes class_name classes = let is_method_of_objc_cpp_class pname classes = match pname with - | Procname.ObjC_Cpp name -> - let class_name = Procname.objc_cpp_get_class_name name in + | Typ.Procname.ObjC_Cpp name -> + let class_name = Typ.Procname.objc_cpp_get_class_name name in is_one_of_classes class_name classes | _ -> false @@ -219,7 +219,7 @@ let rec _find_normal_variable_load tenv (seen : Exp.Set.t) node id : DExp.t opti Sil.d_exp e; L.d_ln ()); _exp_lv_dexp tenv seen node e | Sil.Call (Some (id0, _), Exp.Const (Const.Cfun pn), (e, _):: _, _, _) - when Ident.equal id id0 && Procname.equal pn (Procname.from_string_c_fun "__cast") -> + when Ident.equal id id0 && Typ.Procname.equal pn (Typ.Procname.from_string_c_fun "__cast") -> if verbose then (L.d_str "find_normal_variable_load cast on "; @@ -897,7 +897,7 @@ let _explain_access tenv if verbose then (L.d_str "explain_dereference Binop.Leteref "; Sil.d_exp e; L.d_ln ()); Some e | Some Sil.Call (_, Exp.Const (Const.Cfun fn), [(e, _)], _, _) - when String.equal (Procname.to_string fn) "free" -> + when String.equal (Typ.Procname.to_string fn) "free" -> if verbose then (L.d_str "explain_dereference Sil.Call "; Sil.d_exp e; L.d_ln ()); Some e | Some Sil.Call (_, (Exp.Var _ as e), _, _, _) -> diff --git a/infer/src/backend/errdesc.mli b/infer/src/backend/errdesc.mli index 70c5a6d50..5fbb55aa3 100644 --- a/infer/src/backend/errdesc.mli +++ b/infer/src/backend/errdesc.mli @@ -42,7 +42,7 @@ val find_boolean_assignment : Procdesc.Node.t -> Pvar.t -> bool -> Procdesc.Node val exp_rv_dexp : Tenv.t -> Procdesc.Node.t -> Exp.t -> DecompiledExp.t option (** Produce a description of a persistent reference to an Android Context *) -val explain_context_leak : Procname.t -> Typ.t -> Ident.fieldname -> +val explain_context_leak : Typ.Procname.t -> Typ.t -> Ident.fieldname -> (Ident.fieldname option * Typ.t) list -> Localise.error_desc (** Produce a description of a mismatch between an allocation function and a deallocation function *) @@ -54,7 +54,7 @@ val explain_array_access : Tenv.t -> Localise.deref_str -> 'a Prop.t -> Location (** explain a class cast exception *) val explain_class_cast_exception : - Tenv.t -> Procname.t option -> Exp.t -> Exp.t -> Exp.t -> + Tenv.t -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> Procdesc.Node.t -> Location.t -> Localise.error_desc (** Explain a deallocate stack variable error *) @@ -112,7 +112,7 @@ val explain_unary_minus_applied_to_unsigned_expression : (** Explain a tainted value error *) val explain_tainted_value_reaching_sensitive_function : - Prop.normal Prop.t -> Exp.t -> PredSymb.taint_info -> Procname.t -> Location.t -> + Prop.normal Prop.t -> Exp.t -> PredSymb.taint_info -> Typ.Procname.t -> Location.t -> Localise.error_desc (** Produce a description of a leak by looking at the current state. diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index bc380e3b5..602fa8501 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -64,7 +64,7 @@ let create_file_data table source cg_fname = (** execution environment *) type t = { cg: Cg.t; (** global call graph *) - proc_map: file_data Procname.Hash.t; (** map from procedure name to file data *) + proc_map: file_data Typ.Procname.Hash.t; (** map from procedure name to file data *) file_map: file_data FilenameHash.t; (** map from cg fname to file data *) mutable source_files : SourceFile.Set.t; (** Source files in the execution environment *) } @@ -78,7 +78,7 @@ let freeze exe_env = exe_env (* TODO: unclear what this function is used for *) (** create a new execution environment *) let create () = { cg = Cg.create None; - proc_map = Procname.Hash.create 17; + proc_map = Typ.Procname.Hash.create 17; file_map = FilenameHash.create 1; source_files = SourceFile.Set.empty; } @@ -97,20 +97,20 @@ let add_cg (exe_env: t) (source_dir : DB.source_dir) = List.iter ~f:(fun pname -> - (match AttributesTable.find_file_capturing_procedure pname with - | None -> - () - | Some (source_captured, origin) -> - let multiply_defined = SourceFile.compare source source_captured <> 0 in - if multiply_defined then Cg.remove_node_defined cg pname; - if Config.check_duplicate_symbols && - multiply_defined && - origin <> `Include then - L.stderr "@.DUPLICATE_SYMBOLS source: %a source_captured:%a pname:%a@." - SourceFile.pp source - SourceFile.pp source_captured - Procname.pp pname - )) + (match AttributesTable.find_file_capturing_procedure pname with + | None -> + () + | Some (source_captured, origin) -> + let multiply_defined = SourceFile.compare source source_captured <> 0 in + if multiply_defined then Cg.remove_node_defined cg pname; + if Config.check_duplicate_symbols && + multiply_defined && + origin <> `Include then + L.stderr "@.DUPLICATE_SYMBOLS source: %a source_captured:%a pname:%a@." + SourceFile.pp source + SourceFile.pp source_captured + Typ.Procname.pp pname + )) defined_procs; Cg.extend exe_env.cg cg @@ -120,13 +120,13 @@ let get_cg exe_env = let get_file_data exe_env pname = try - Some (Procname.Hash.find exe_env.proc_map pname) + Some (Typ.Procname.Hash.find exe_env.proc_map pname) with Not_found -> begin let source_file_opt = match AttributesTable.load_attributes pname with | None -> - L.err "can't find tenv_cfg_object for %a@." Procname.pp pname; + L.err "can't find tenv_cfg_object for %a@." Typ.Procname.pp pname; None | Some proc_attributes when Config.reactive_capture -> let get_captured_file {ProcAttributes.source_file_captured} = source_file_captured in @@ -137,7 +137,7 @@ let get_file_data exe_env pname = let source_dir = DB.source_dir_from_source_file source_file in let cg_fname = DB.source_dir_get_internal_file source_dir ".cg" in let file_data = create_file_data exe_env.file_map source_file cg_fname in - Procname.Hash.replace exe_env.proc_map pname file_data; + Typ.Procname.Hash.replace exe_env.proc_map pname file_data; file_data in Option.map ~f:get_file_data_for_source source_file_opt end @@ -167,10 +167,10 @@ let get_tenv exe_env proc_name = tenv | None -> failwithf "get_tenv: tenv not found for %a in file %s" - Procname.pp proc_name (DB.filename_to_string file_data.tenv_file) + Typ.Procname.pp proc_name (DB.filename_to_string file_data.tenv_file) ) | None -> - failwithf "get_tenv: file_data not found for %a" Procname.pp proc_name + failwithf "get_tenv: file_data not found for %a" Typ.Procname.pp proc_name (** return the cfg associated to the procedure *) let get_cfg exe_env pname = @@ -201,4 +201,4 @@ let iter_files f exe_env = Option.iter ~f:(fun cfg -> f fname cfg) (file_data_to_cfg file_data); SourceFile.Set.add fname seen_files_acc end in - ignore (Procname.Hash.fold do_file exe_env.proc_map SourceFile.Set.empty) + ignore (Typ.Procname.Hash.fold do_file exe_env.proc_map SourceFile.Set.empty) diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index 2e2b9f3c9..f7156256d 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -32,16 +32,16 @@ val add_cg : initial -> DB.source_dir -> unit val get_cg : t -> Cg.t (** return the source file associated to the procedure *) -val get_source : t -> Procname.t -> SourceFile.t option +val get_source : t -> Typ.Procname.t -> SourceFile.t option (** return the type environment associated to the procedure *) -val get_tenv : t -> Procname.t -> Tenv.t +val get_tenv : t -> Typ.Procname.t -> Tenv.t (** return the cfg associated to the procedure *) -val get_cfg : t -> Procname.t -> Cfg.cfg option +val get_cfg : t -> Typ.Procname.t -> Cfg.cfg option (** return the proc desc associated to the procedure *) -val get_proc_desc : t -> Procname.t -> Procdesc.t option +val get_proc_desc : t -> Typ.Procname.t -> Procdesc.t option (** [iter_files f exe_env] applies [f] to the source file and tenv and cfg for each file in [exe_env] *) val iter_files : (SourceFile.t -> Cfg.cfg -> unit) -> t -> unit diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 558660da8..0429c916b 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -15,7 +15,7 @@ module L = Logging type path_filter = SourceFile.t -> bool type error_filter = Localise.t -> bool -type proc_filter = Procname.t -> bool +type proc_filter = Typ.Procname.t -> bool type filters = { @@ -57,8 +57,8 @@ let is_matching patterns = (** Check if a proc name is matching the name given as string. *) let match_method language proc_name method_name = not (BuiltinDecl.is_declared proc_name) && - Config.equal_language (Procname.get_language proc_name) language && - String.equal (Procname.get_method proc_name) method_name + Config.equal_language (Typ.Procname.get_language proc_name) language && + String.equal (Typ.Procname.get_method proc_name) method_name (* Module to create matcher based on strings present in the source file *) module FileContainsStringMatcher = struct @@ -108,7 +108,7 @@ type pattern = (* Module to create matcher based on source file names or class names and method names *) module FileOrProcMatcher = struct - type matcher = SourceFile.t -> Procname.t -> bool + type matcher = SourceFile.t -> Typ.Procname.t -> bool let default_matcher : matcher = fun _ _ -> false @@ -128,8 +128,8 @@ module FileOrProcMatcher = struct ~init:String.Map.empty m_patterns in let do_java pname_java = - let class_name = Procname.java_get_class_name pname_java - and method_name = Procname.java_get_method pname_java in + let class_name = Typ.Procname.java_get_class_name pname_java + and method_name = Typ.Procname.java_get_method pname_java in try let class_patterns = String.Map.find_exn pattern_map class_name in List.exists @@ -142,7 +142,7 @@ module FileOrProcMatcher = struct fun _ proc_name -> match proc_name with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> do_java pname_java | _ -> false diff --git a/infer/src/backend/inferconfig.mli b/infer/src/backend/inferconfig.mli index da02485af..7ff93e02d 100644 --- a/infer/src/backend/inferconfig.mli +++ b/infer/src/backend/inferconfig.mli @@ -16,7 +16,7 @@ type path_filter = SourceFile.t -> bool type error_filter = Localise.t -> bool (** Filter type for a procedure name *) -type proc_filter = Procname.t -> bool +type proc_filter = Typ.Procname.t -> bool type filters = { @@ -31,9 +31,9 @@ val do_not_filter : filters (** Create filters based on the config file *) val create_filters : Config.analyzer -> filters -val never_return_null_matcher : SourceFile.t -> Procname.t -> bool -val skip_translation_matcher : SourceFile.t -> Procname.t -> bool -val modeled_expensive_matcher : (string -> bool) -> Procname.t -> bool +val never_return_null_matcher : SourceFile.t -> Typ.Procname.t -> bool +val skip_translation_matcher : SourceFile.t -> Typ.Procname.t -> bool +val modeled_expensive_matcher : (string -> bool) -> Typ.Procname.t -> bool (** Load the config file and list the files to report on *) val test: unit -> unit diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index 25f48aaa6..42c0bffa4 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -223,30 +223,30 @@ let collect_preconditions tenv proc_name : Prop.normal Specs.Jprop.t list = let f p = Prop.prop_normal_vars_to_primed_vars tenv p in Propset.map tenv f pset in - L.d_strln ("#### Extracted footprint of " ^ Procname.to_string proc_name ^ ": ####"); + L.d_strln ("#### Extracted footprint of " ^ Typ.Procname.to_string proc_name ^ ": ####"); L.d_increase_indent 1; Propset.d Prop.prop_emp pset'; L.d_decrease_indent 1; L.d_ln (); L.d_ln (); let pset'' = collect_do_abstract_pre proc_name tenv pset' in let plist_meet = do_meet_pre tenv pset'' in - L.d_strln ("#### Footprint of " ^ Procname.to_string proc_name ^ " after Meet ####"); + L.d_strln ("#### Footprint of " ^ Typ.Procname.to_string proc_name ^ " after Meet ####"); L.d_increase_indent 1; Propgraph.d_proplist Prop.prop_emp plist_meet; L.d_decrease_indent 1; L.d_ln (); L.d_ln (); L.d_increase_indent 2; (* Indent for the join output *) let jplist = do_join_pre tenv plist_meet in L.d_decrease_indent 2; L.d_ln (); - L.d_strln ("#### Footprint of " ^ Procname.to_string proc_name ^ " after Join ####"); + L.d_strln ("#### Footprint of " ^ Typ.Procname.to_string proc_name ^ " after Join ####"); L.d_increase_indent 1; Specs.Jprop.d_list false jplist; L.d_decrease_indent 1; L.d_ln (); let jplist' = List.map ~f:(Specs.Jprop.map (Prop.prop_rename_primed_footprint_vars tenv)) jplist in - L.d_strln ("#### Renamed footprint of " ^ Procname.to_string proc_name ^ ": ####"); + L.d_strln ("#### Renamed footprint of " ^ Typ.Procname.to_string proc_name ^ ": ####"); L.d_increase_indent 1; Specs.Jprop.d_list false jplist'; L.d_decrease_indent 1; L.d_ln (); let jplist'' = let f p = Prop.prop_primed_vars_to_normal_vars tenv (collect_do_abstract_one proc_name tenv p) in List.map ~f:(Specs.Jprop.map f) jplist' in - L.d_strln ("#### Abstracted footprint of " ^ Procname.to_string proc_name ^ ": ####"); + L.d_strln ("#### Abstracted footprint of " ^ Typ.Procname.to_string proc_name ^ ": ####"); L.d_increase_indent 1; Specs.Jprop.d_list false jplist''; L.d_decrease_indent 1; L.d_ln(); jplist'' @@ -535,10 +535,10 @@ let forward_tabulate tenv pdesc wl source = if Specs.equal_phase (Specs.get_phase summary) Specs.FOOTPRINT then "FP" else "RE" in let status = Specs.get_status summary in F.sprintf - "[%s:%s] %s" phase_string (Specs.string_of_status status) (Procname.to_string proc_name) in + "[%s:%s] %s" phase_string (Specs.string_of_status status) (Typ.Procname.to_string proc_name) in L.d_strln ("**** " ^ (log_string pname) ^ " " ^ "Node: " ^ string_of_int (Procdesc.Node.get_id curr_node :> int) ^ ", " ^ - "Procedure: " ^ Procname.to_string pname ^ ", " ^ + "Procedure: " ^ Typ.Procname.to_string pname ^ ", " ^ "Session: " ^ string_of_int session ^ ", " ^ "Todo: " ^ string_of_int (Paths.PathSet.size pathset_todo) ^ " ****"); L.d_increase_indent 1; @@ -803,8 +803,8 @@ let collect_postconditions wl tenv pdesc : Paths.PathSet.t * Specs.Visitedset.t (* Assuming C++ developers use RAII, remove resources from the constructor posts *) let pathset = match pname with - | Procname.ObjC_Cpp _ -> - if (Procname.is_constructor pname) then + | Typ.Procname.ObjC_Cpp _ -> + if (Typ.Procname.is_constructor pname) then Paths.PathSet.map (fun prop -> Attribute.remove_resource tenv Racquire (Rmemory Mobjc) (Attribute.remove_resource tenv Racquire (Rmemory Mmalloc) @@ -814,7 +814,7 @@ let collect_postconditions wl tenv pdesc : Paths.PathSet.t * Specs.Visitedset.t | _ -> pathset in L.d_strln - ("#### [FUNCTION " ^ Procname.to_string pname ^ "] Analysis result ####"); + ("#### [FUNCTION " ^ Typ.Procname.to_string pname ^ "] Analysis result ####"); Propset.d Prop.prop_emp (Paths.PathSet.to_propset tenv pathset); L.d_ln (); let res = @@ -831,7 +831,7 @@ let collect_postconditions wl tenv pdesc : Paths.PathSet.t * Specs.Visitedset.t | exn when (match exn with Exceptions.Leak _ -> true | _ -> false) -> L.d_strln"Leak in post collection"; assert false in L.d_strln - ("#### [FUNCTION " ^ Procname.to_string pname ^ "] Postconditions after join ####"); + ("#### [FUNCTION " ^ Typ.Procname.to_string pname ^ "] Postconditions after join ####"); L.d_increase_indent 1; Propset.d Prop.prop_emp (Paths.PathSet.to_propset tenv (fst res)); L.d_decrease_indent 1; @@ -912,7 +912,7 @@ let execute_filter_prop wl tenv pdesc init_node (precondition : Prop.normal Spec : Prop.normal Specs.spec option = let pname = Procdesc.get_proc_name pdesc in do_before_node source 0 init_node; - L.d_strln ("#### Start: RE-execution for " ^ Procname.to_string pname ^ " ####"); + L.d_strln ("#### Start: RE-execution for " ^ Typ.Procname.to_string pname ^ " ####"); L.d_indent 1; L.d_strln "Precond:"; Specs.Jprop.d_shallow precondition; L.d_ln (); L.d_ln (); @@ -930,7 +930,7 @@ let execute_filter_prop wl tenv pdesc init_node (precondition : Prop.normal Spec forward_tabulate tenv pdesc wl source; do_before_node source 0 init_node; L.d_strln_color Green - ("#### Finished: RE-execution for " ^ Procname.to_string pname ^ " ####"); + ("#### Finished: RE-execution for " ^ Typ.Procname.to_string pname ^ " ####"); L.d_increase_indent 1; L.d_strln "Precond:"; Prop.d_prop (Specs.Jprop.to_prop precondition); L.d_ln (); @@ -953,7 +953,7 @@ let execute_filter_prop wl tenv pdesc init_node (precondition : Prop.normal Spec with RE_EXE_ERROR -> do_before_node source 0 init_node; Printer.force_delayed_prints (); - L.d_strln_color Red ("#### [FUNCTION " ^ Procname.to_string pname ^ "] ...ERROR"); + L.d_strln_color Red ("#### [FUNCTION " ^ Typ.Procname.to_string pname ^ "] ...ERROR"); L.d_increase_indent 1; L.d_strln "when starting from pre:"; Prop.d_prop (Specs.Jprop.to_prop precondition); @@ -966,7 +966,7 @@ let execute_filter_prop wl tenv pdesc init_node (precondition : Prop.normal Spec let get_procs_and_defined_children call_graph = List.map ~f:(fun (n, ns) -> - (n, Procname.Set.elements ns)) + (n, Typ.Procname.Set.elements ns)) (Cg.get_nodes_and_defined_children call_graph) let pp_intra_stats wl proc_desc fmt _ = @@ -988,7 +988,7 @@ type exe_phase = (unit -> unit) * (unit -> Prop.normal Specs.spec list * Specs.p and [get_results ()] returns the results computed. This function is architected so that [get_results ()] can be called even after [go ()] was interrupted by and exception. *) -let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Procdesc.t) source +let perform_analysis_phase tenv (pname : Typ.Procname.t) (pdesc : Procdesc.t) source : exe_phase = let summary = Specs.get_summary_unsafe "perform_analysis_phase" pname in let start_node = Procdesc.get_start_node pdesc in @@ -1008,7 +1008,7 @@ let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Procdesc.t) source let add pset prop = Paths.PathSet.add_renamed_prop prop (Paths.Path.start start_node) pset in Propset.fold add Paths.PathSet.empty init_props in - L.out "@.#### Start: Footprint Computation for %a ####@." Procname.pp pname; + L.out "@.#### Start: Footprint Computation for %a ####@." Typ.Procname.pp pname; L.d_increase_indent 1; L.d_strln "initial props ="; Propset.d Prop.prop_emp init_props; L.d_ln (); L.d_ln(); @@ -1023,12 +1023,12 @@ let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Procdesc.t) source let get_results (wl : Worklist.t) () = State.process_execution_failures Reporting.log_warning pname; let results = collect_analysis_result tenv wl pdesc in - L.out "#### [FUNCTION %a] ... OK #####@\n" Procname.pp pname; + L.out "#### [FUNCTION %a] ... OK #####@\n" Typ.Procname.pp pname; L.out "#### Finished: Footprint Computation for %a %a ####@." - Procname.pp pname + Typ.Procname.pp pname (pp_intra_stats wl pdesc) pname; L.out "#### [FUNCTION %a] Footprint Analysis result ####@\n%a@." - Procname.pp pname + Typ.Procname.pp pname (Paths.PathSet.pp Pp.text) results; let specs = try extract_specs tenv pdesc results with | Exceptions.Leak _ -> @@ -1048,7 +1048,7 @@ let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Procdesc.t) source (Specs.get_specs pname) in let valid_specs = ref [] in let go () = - L.out "@.#### Start: Re-Execution for %a ####@." Procname.pp pname; + L.out "@.#### Start: Re-Execution for %a ####@." Typ.Procname.pp pname; let filter p = let wl = path_set_create_worklist pdesc in let speco = execute_filter_prop wl tenv pdesc start_node p source in @@ -1069,22 +1069,22 @@ let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Procdesc.t) source ignore (List.map ~f:filter candidate_preconditions) in let get_results () = let specs = !valid_specs in - L.out "#### [FUNCTION %a] ... OK #####@\n" Procname.pp pname; - L.out "#### Finished: Re-Execution for %a ####@." Procname.pp pname; + L.out "#### [FUNCTION %a] ... OK #####@\n" Typ.Procname.pp pname; + L.out "#### Finished: Re-Execution for %a ####@." Typ.Procname.pp pname; let valid_preconditions = List.map ~f:(fun spec -> spec.Specs.pre) specs in let filename = DB.Results_dir.path_to_filename (DB.Results_dir.Abs_source_dir source) - [(Procname.to_filename pname)] in + [(Typ.Procname.to_filename pname)] in if Config.write_dotty then Dotty.pp_speclist_dotty_file filename specs; L.out "@.@.================================================"; - L.out "@. *** CANDIDATE PRECONDITIONS FOR %a: " Procname.pp pname; + L.out "@. *** CANDIDATE PRECONDITIONS FOR %a: " Typ.Procname.pp pname; L.out "@.================================================@."; L.out "@.%a @.@." (Specs.Jprop.pp_list Pp.text false) candidate_preconditions; L.out "@.@.================================================"; - L.out "@. *** VALID PRECONDITIONS FOR %a: " Procname.pp pname; + L.out "@. *** VALID PRECONDITIONS FOR %a: " Typ.Procname.pp pname; L.out "@.================================================@."; L.out "@.%a @.@." (Specs.Jprop.pp_list Pp.text true) valid_preconditions; specs, Specs.RE_EXECUTION in @@ -1173,9 +1173,9 @@ let report_runtime_exceptions tenv pdesc summary = is_public_method && (match pname with - | Procname.Java pname_java -> - Procname.java_is_static pname - && String.equal (Procname.java_get_method pname_java) "main" + | Typ.Procname.Java pname_java -> + Typ.Procname.java_is_static pname + && String.equal (Typ.Procname.java_get_method pname_java) "main" | _ -> false) in let is_annotated pdesc = @@ -1324,7 +1324,7 @@ let analyze_proc source exe_env proc_desc : Specs.summary = (** Perform the transition from [FOOTPRINT] to [RE_EXECUTION] in spec table *) let transition_footprint_re_exe tenv proc_name joined_pres = - L.out "Transition %a from footprint to re-exe@." Procname.pp proc_name; + L.out "Transition %a from footprint to re-exe@." Typ.Procname.pp proc_name; let summary = Specs.get_summary_unsafe "transition_footprint_re_exe" proc_name in let summary' = if Config.only_footprint then @@ -1375,7 +1375,7 @@ let perform_transition exe_env tenv proc_name source = with exn when SymOp.exn_not_failure exn -> apply_start_node (do_after_node source); Config.allow_leak := allow_leak; - L.err "Error in collect_preconditions for %a@." Procname.pp proc_name; + L.err "Error in collect_preconditions for %a@." Typ.Procname.pp proc_name; let err_name, _, ml_loc_opt, _, _, _, _ = Exceptions.recognize_exception exn in let err_str = "exception raised " ^ (Localise.to_string err_name) in L.err "Error: %s %a@." err_str L.pp_ml_loc_opt ml_loc_opt; @@ -1523,7 +1523,7 @@ let print_stats_cfg proc_shadowed source cfg = if proc_shadowed proc_desc || is_none (Specs.get_summary proc_name) then L.out "print_stats: ignoring function %a which is also defined in another file@." - Procname.pp proc_name + Typ.Procname.pp proc_name else let summary = Specs.get_summary_unsafe "print_stats_cfg" proc_name in let stats = summary.Specs.stats in diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 774d3e4b2..738aa9920 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -29,7 +29,7 @@ let dirs_to_analyze = type analyze_ondemand = SourceFile.t -> Procdesc.t -> Specs.summary -type get_proc_desc = Procname.t -> Procdesc.t option +type get_proc_desc = Typ.Procname.t -> Procdesc.t option type callbacks = { @@ -116,8 +116,8 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc L.log_progress_procedure (); if Config.trace_ondemand then L.stderr "[%d] run_proc_analysis %a -> %a@." !nesting - Procname.pp curr_pname - Procname.pp callee_pname; + Typ.Procname.pp curr_pname + Typ.Procname.pp callee_pname; let preprocess () = incr nesting; @@ -127,9 +127,9 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc Option.value_map ~f:(fun (attributes : ProcAttributes.t) -> let attribute_pname = attributes.proc_name in - if not (Procname.equal callee_pname attribute_pname) then - failwith ("ERROR: "^(Procname.to_string callee_pname) - ^" not equal to "^(Procname.to_string attribute_pname)); + if not (Typ.Procname.equal callee_pname attribute_pname) then + failwith ("ERROR: "^(Typ.Procname.to_string callee_pname) + ^" not equal to "^(Typ.Procname.to_string attribute_pname)); attributes.loc.file) ~default:SourceFile.empty attributes_opt in @@ -166,7 +166,7 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc summary with exn -> L.stderr "@.ONDEMAND EXCEPTION %a %s@.@.BACK TRACE@.%s@?" - Procname.pp callee_pname + Typ.Procname.pp callee_pname (Exn.to_string exn) (Printexc.get_backtrace ()); restore_global_state old_state; diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index 1a2a7076b..3466291b3 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -17,7 +17,7 @@ val dirs_to_analyze : String.Set.t option type analyze_ondemand = SourceFile.t -> Procdesc.t -> Specs.summary -type get_proc_desc = Procname.t -> Procdesc.t option +type get_proc_desc = Typ.Procname.t -> Procdesc.t option type callbacks = { @@ -38,10 +38,10 @@ val analyze_proc_desc : performs an on-demand analysis of proc_name triggered during the analysis of curr_pdesc. *) val analyze_proc_name : - propagate_exceptions:bool -> Procdesc.t -> Procname.t -> Specs.summary option + propagate_exceptions:bool -> Procdesc.t -> Typ.Procname.t -> Specs.summary option (** Check if the procedure called needs to be analyzed. *) -val procedure_should_be_analyzed : Procname.t -> bool +val procedure_should_be_analyzed : Typ.Procname.t -> bool (** Set the callbacks used to perform on-demand analysis. *) val set_callbacks : callbacks -> unit diff --git a/infer/src/backend/paths.ml b/infer/src/backend/paths.ml index e2094798c..173388ed0 100644 --- a/infer/src/backend/paths.ml +++ b/infer/src/backend/paths.ml @@ -24,7 +24,7 @@ module Path : sig type session = int (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) - val add_call : bool -> t -> Procname.t -> t -> t + val add_call : bool -> t -> Typ.Procname.t -> t -> t (** check whether a path contains another path *) val contains : t -> t -> bool @@ -84,7 +84,7 @@ end = struct type _stats = stats let compare__stats _ _ = 0 - type _procname = Procname.t + type _procname = Typ.Procname.t let compare__procname _ _ = 0 type _string_option = string option @@ -434,9 +434,9 @@ end = struct match Procdesc.Node.get_kind curr_node with | Procdesc.Node.Join_node -> () (* omit join nodes from error traces *) | Procdesc.Node.Start_node pname -> - let name = Procname.to_string pname in - let name_id = Procname.to_filename pname in - let descr = "start of procedure " ^ (Procname.to_simplified_string pname) in + let name = Typ.Procname.to_string pname in + let name_id = Typ.Procname.to_filename pname in + let descr = "start of procedure " ^ (Typ.Procname.to_simplified_string pname) in let node_tags = [(Io_infer.Xml.tag_kind,"procedure_start"); (Io_infer.Xml.tag_name, name); @@ -459,9 +459,9 @@ end = struct (Io_infer.Xml.tag_branch, if is_true_branch then "true" else "false")] in trace := Errlog.make_trace_element level curr_loc descr node_tags :: !trace | Procdesc.Node.Exit_node pname -> - let descr = "return from a call to " ^ (Procname.to_string pname) in - let name = Procname.to_string pname in - let name_id = Procname.to_filename pname in + let descr = "return from a call to " ^ (Typ.Procname.to_string pname) in + let name = Typ.Procname.to_string pname in + let name_id = Typ.Procname.to_filename pname in let node_tags = [(Io_infer.Xml.tag_kind,"procedure_end"); (Io_infer.Xml.tag_name, name); diff --git a/infer/src/backend/paths.mli b/infer/src/backend/paths.mli index 423c9a0f4..92ab00942 100644 --- a/infer/src/backend/paths.mli +++ b/infer/src/backend/paths.mli @@ -19,7 +19,7 @@ module Path : sig type session = int (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) - val add_call : bool -> t -> Procname.t -> t -> t + val add_call : bool -> t -> Typ.Procname.t -> t -> t (** check whether a path contains another path *) val contains : t -> t -> bool diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index b923183a4..edcfeea1b 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 - List.sort ~cmp:(fun (_, p1) (_, p2) -> Procname.compare p1 p2) overrides in + List.sort ~cmp:(fun (_, p1) (_, p2) -> Typ.Procname.compare p1 p2) overrides in (match sorted_overrides with | ((_, target_pname) :: _) as all_targets -> let targets_to_add = @@ -192,7 +192,7 @@ let remove_dead_frontend_stores pdesc liveness_inv_map = let add_nullify_instrs pdesc tenv liveness_inv_map = let address_taken_vars = - if Procname.is_java (Procdesc.get_proc_name pdesc) + if Typ.Procname.is_java (Procdesc.get_proc_name pdesc) then AddressTaken.Domain.empty (* can't take the address of a variable in Java *) else let initial = AddressTaken.Domain.empty in @@ -312,7 +312,7 @@ let do_abstraction pdesc = let do_dynamic_dispatch pdesc cg tenv = let pname = Procdesc.get_proc_name pdesc in - if Procname.is_java pname && + if Typ.Procname.is_java pname && (Config.dynamic_dispatch = `Interface || Config.dynamic_dispatch = `Sound) then add_dispatch_calls pdesc cg tenv; Procdesc.signal_did_preanalysis pdesc diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 76c15f769..a0673a0e0 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -97,10 +97,10 @@ let is_visited node = when starting and finishing the processing of a node *) module NodesHtml : sig val start_node : - int -> Location.t -> Procname.t -> Procdesc.Node.t list -> + int -> Location.t -> Typ.Procname.t -> Procdesc.Node.t list -> Procdesc.Node.t list -> Procdesc.Node.t list -> SourceFile.t -> bool - val finish_node : Procname.t -> int -> SourceFile.t -> unit + val finish_node : Typ.Procname.t -> int -> SourceFile.t -> unit end = struct let log_files = Hashtbl.create 11 @@ -123,7 +123,7 @@ end = struct loc.Location.line; F.fprintf fmt "PROC: %a LINE:%a\n" (Io_infer.Html.pp_proc_link [".."] proc_name) - (Escape.escape_xml (Procname.to_string proc_name)) + (Escape.escape_xml (Typ.Procname.to_string proc_name)) (Io_infer.Html.pp_line_link source [".."]) loc.Location.line; F.fprintf fmt "
PREDS:@\n"; List.iter ~f:(fun node -> @@ -423,10 +423,10 @@ let write_proc_html source whole_seconds pdesc = let fd, fmt = Io_infer.Html.create (DB.Results_dir.Abs_source_dir source) - [Procname.to_filename pname] in + [Typ.Procname.to_filename pname] in F.fprintf fmt "

Procedure %a

@\n" (Io_infer.Html.pp_line_link source - ~text: (Some (Escape.escape_xml (Procname.to_string pname))) + ~text: (Some (Escape.escape_xml (Typ.Procname.to_string pname))) []) linenum; List.iter @@ -556,7 +556,7 @@ let write_html_file linereader filename procs = | Procdesc.Node.Start_node proc_name -> let num_specs = List.length (Specs.get_specs proc_name) in let label = - (Escape.escape_xml (Procname.to_string proc_name)) ^ + (Escape.escape_xml (Typ.Procname.to_string proc_name)) ^ ": " ^ (string_of_int num_specs) ^ " specs" in diff --git a/infer/src/backend/prover.ml b/infer/src/backend/prover.ml index 111aab037..ce631b0e0 100644 --- a/infer/src/backend/prover.ml +++ b/infer/src/backend/prover.ml @@ -1638,7 +1638,7 @@ let get_overrides_of tenv supertype pname = | Tstruct name -> ( match Tenv.lookup tenv name with | Some { methods } -> - List.exists ~f:(fun m -> Procname.equal pname m) methods + List.exists ~f:(fun m -> Typ.Procname.equal pname m) methods | None -> false ) @@ -1649,7 +1649,7 @@ let get_overrides_of tenv supertype pname = if not (Typ.equal typ supertype) && Subtyping_check.check_subtype tenv typ supertype then (* only select the ones that implement [pname] as overrides *) let resolved_pname = - Procname.replace_class pname tname in + Typ.Procname.replace_class pname tname in if typ_has_method resolved_pname typ then (typ, resolved_pname) :: overrides_acc else overrides_acc else overrides_acc in diff --git a/infer/src/backend/prover.mli b/infer/src/backend/prover.mli index 8941aa6ab..584a49139 100644 --- a/infer/src/backend/prover.mli +++ b/infer/src/backend/prover.mli @@ -67,7 +67,7 @@ val get_bounds : Tenv.t -> Prop.normal Prop.t -> Exp.t -> IntLit.t option * IntL (** {2 Abduction prover} *) (** [check_implication p1 p2] returns true if [p1|-p2] *) -val check_implication : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> bool +val check_implication : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> bool type check = | Bounds_check @@ -86,7 +86,7 @@ type implication_result = frame)] where [sub] is a substitution which instantiates the primed vars of [p1] and [p2], which are assumed to be disjoint. *) val check_implication_for_footprint : - Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> implication_result + Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> implication_result (** {2 Cover: miminum set of pi's whose disjunction is equivalent to true} *) @@ -112,7 +112,7 @@ sig end -val get_overrides_of : Tenv.t -> Typ.t -> Procname.t -> (Typ.t * Procname.t) list +val get_overrides_of : Tenv.t -> Typ.t -> Typ.Procname.t -> (Typ.t * Typ.Procname.t) list diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index ef66c81ed..3a6e270d7 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -445,7 +445,7 @@ let mk_ptsto_exp_footprint | Config.Java -> Subtype.subtypes in let create_ptsto footprint_part off0 = match root, off0, typ with | Exp.Lvar pvar, [], Typ.Tfun _ -> - let fun_name = Procname.from_string_c_fun (Mangled.to_string (Pvar.get_name pvar)) in + let fun_name = Typ.Procname.from_string_c_fun (Mangled.to_string (Pvar.get_name pvar)) in let fun_exp = Exp.Const (Const.Cfun fun_name) in ([], Prop.mk_ptsto tenv root (Sil.Eexp (fun_exp, inst)) (Exp.Sizeof (typ, None, st))) | _, [], Typ.Tfun _ -> @@ -651,9 +651,9 @@ let add_guarded_by_constraints tenv prop lexp pdesc = let dollar_normalize s = String.map s ~f:(function '$' -> '.' | c -> c) in String.is_suffix ~suffix:(dollar_normalize guarded_by_str) (dollar_normalize (class_str ^ ".class")) in let guarded_by_str_is_current_class guarded_by_str = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> (* programmers write @GuardedBy("MyClass.class") when the field is guarded by the class *) - guarded_by_str_is_class guarded_by_str (Procname.java_get_class_name java_pname) + guarded_by_str_is_class guarded_by_str (Typ.Procname.java_get_class_name java_pname) | _ -> false in let guarded_by_str_is_class_this class_name guarded_by_str = @@ -665,8 +665,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc = (* return true if [guarded_by_str] is a suffix of ".this" *) let guarded_by_str_is_super_class_this guarded_by_str pname = match pname with - | Procname.Java java_pname -> - let current_class_type_name = (Procname.java_get_class_type_name java_pname) in + | Typ.Procname.Java java_pname -> + let current_class_type_name = (Typ.Procname.java_get_class_type_name java_pname) in let comparison class_type_name _ = guarded_by_str_is_class_this (Typename.to_string class_type_name) guarded_by_str in PatternMatch.supertype_exists tenv comparison current_class_type_name @@ -675,8 +675,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc = (* return true if [guarded_by_str] is as suffix of ".this" *) let guarded_by_str_is_current_class_this guarded_by_str = function - | Procname.Java java_pname -> - guarded_by_str_is_class_this (Procname.java_get_class_name java_pname) guarded_by_str + | Typ.Procname.Java java_pname -> + guarded_by_str_is_class_this (Typ.Procname.java_get_class_name java_pname) guarded_by_str | _ -> false in let extract_guarded_by_str item_annot = @@ -804,7 +804,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc = | None -> false in let is_synchronized_on_class guarded_by_str = guarded_by_str_is_current_class guarded_by_str pname && - Procdesc.is_java_synchronized pdesc && Procname.java_is_static pname in + Procdesc.is_java_synchronized pdesc && Typ.Procname.java_is_static pname in let warn accessed_fld guarded_by_str = let loc = State.get_loc () in let err_desc = @@ -825,7 +825,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc = Procdesc.is_java_synchronized pdesc) || (guarded_by_str_is_current_class guarded_by_str pname && - Procdesc.is_java_synchronized pdesc && Procname.java_is_static pname) || + Procdesc.is_java_synchronized pdesc && Typ.Procname.java_is_static pname) || (* or the prop says we already have the lock *) List.exists ~f:(function @@ -862,7 +862,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc = prop.Prop.sigma in Procdesc.get_access pdesc <> PredSymb.Private && not (Annotations.pdesc_return_annot_ends_with pdesc Annotations.visibleForTesting) && - not (Procname.java_is_access_method (Procdesc.get_proc_name pdesc)) && + not (Typ.Procname.java_is_access_method (Procdesc.get_proc_name pdesc)) && not (is_accessible_through_local_ref lexp) && not guardedby_is_self_referential && not (proc_has_suppress_guarded_by_annot pdesc) @@ -1320,7 +1320,7 @@ let check_dereference_error tenv pdesc (prop : Prop.normal Prop.t) lexp loc = let is_nullable_attr = function | Sil.Apred ((Aretval (pname, ret_attr) | Aundef (pname, ret_attr, _, _)), _) when Annotations.ia_is_nullable ret_attr -> - nullable_obj_str := Some (Procname.to_string pname); + nullable_obj_str := Some (Typ.Procname.to_string pname); true | _ -> false in List.exists ~f:is_nullable_attr (Attribute.get_for_exp tenv prop exp) in @@ -1492,8 +1492,8 @@ let rearrange ?(report_deref_errors=true) pdesc tenv lexp typ prop loc if report_deref_errors then check_dereference_error tenv pdesc prop nlexp (State.get_loc ()); let pname = Procdesc.get_proc_name pdesc in let prop' = - if Config.csl_analysis && !Config.footprint && Procname.is_java pname && - not (Procname.is_constructor pname || Procname.is_class_initializer pname) + if Config.csl_analysis && !Config.footprint && Typ.Procname.is_java pname && + not (Typ.Procname.is_constructor pname || Typ.Procname.is_class_initializer pname) then add_guarded_by_constraints tenv prop lexp pdesc else prop in match Prop.prop_iter_create prop' with diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 06e7d5906..8a8a987c3 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -19,7 +19,7 @@ type log_t = exn -> unit -type log_issue = Procname.t -> log_t +type log_issue = Typ.Procname.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t @@ -64,8 +64,8 @@ let log_issue failwithf "Trying to report error on procedure %a, but cannot because no summary exists for this \ procedure. Did you mean to log the error on the caller of %a instead?" - Procname.pp proc_name - Procname.pp proc_name + Typ.Procname.pp proc_name + Typ.Procname.pp proc_name let log_error = log_issue Exceptions.Kerror let log_warning = log_issue Exceptions.Kwarning diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index bf678885b..f28a190ed 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -19,7 +19,7 @@ type log_t = exn -> unit -type log_issue = Procname.t -> log_t +type log_issue = Typ.Procname.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index 578d1ec5d..b03688be0 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -225,9 +225,9 @@ let normalized_specs_to_specs = module CallStats = struct (** module for tracing stats of function calls *) module PnameLocHash = Hashtbl.Make (struct - type t = Procname.t * Location.t - let hash (pname, loc) = Hashtbl.hash (Procname.hash_pname pname, loc.Location.line) - let equal = [%compare.equal: Procname.t * Location.t] + type t = Typ.Procname.t * Location.t + let hash (pname, loc) = Hashtbl.hash (Typ.Procname.hash_pname pname, loc.Location.line) + let equal = [%compare.equal: Typ.Procname.t * Location.t] end) (** kind of result of a procedure call *) @@ -278,14 +278,14 @@ module CallStats = struct (** module for tracing stats of function calls *) PnameLocHash.iter (fun x tr -> elems := (x, tr) :: !elems) t; let sorted_elems = let compare (pname_loc1, _) (pname_loc2, _) = - [%compare: Procname.t * Location.t] pname_loc1 pname_loc2 in + [%compare: Typ.Procname.t * Location.t] pname_loc1 pname_loc2 in List.sort ~cmp:compare !elems in List.iter ~f:(fun (x, tr) -> f x tr) sorted_elems (* let pp fmt t = let do_call (pname, loc) tr = - F.fprintf fmt "%a %a: %a@\n" Procname.pp pname Location.pp loc pp_trace tr in + F.fprintf fmt "%a %a: %a@\n" Typ.Procname.pp pname Location.pp loc pp_trace tr in iter do_call t *) end @@ -347,11 +347,11 @@ type summary = { proc_desc_option : Procdesc.t option; } -type spec_tbl = summary Procname.Hash.t +type spec_tbl = summary Typ.Procname.Hash.t -let spec_tbl: spec_tbl = Procname.Hash.create 128 +let spec_tbl: spec_tbl = Typ.Procname.Hash.create 128 -let clear_spec_tbl () = Procname.Hash.clear spec_tbl +let clear_spec_tbl () = Typ.Procname.Hash.clear spec_tbl (** pretty print analysis time; if [whole_seconds] is true, only print time in seconds *) let pp_time whole_seconds fmt t = @@ -430,7 +430,7 @@ let get_signature summary = "%a %a" (Typ.pp_full Pp.text) summary.attributes.ProcAttributes.ret_type - Procname.pp summary.attributes.ProcAttributes.proc_name in + Typ.Procname.pp summary.attributes.ProcAttributes.proc_name in let decl = F.asprintf "%t" pp in decl ^ "(" ^ !s ^ ")" @@ -515,14 +515,14 @@ let summary_compact sh summary = { summary with payload = payload_compact sh summary.payload } (** Add the summary to the table for the given function *) -let add_summary (proc_name : Procname.t) (summary: summary) : unit = +let add_summary (proc_name : Typ.Procname.t) (summary: summary) : unit = L.out "Adding summary for %a@\n@[ %a@]@." - Procname.pp proc_name + Typ.Procname.pp proc_name (pp_summary_text ~whole_seconds:false) summary; - Procname.Hash.replace spec_tbl proc_name summary + Typ.Procname.Hash.replace spec_tbl proc_name summary let specs_filename pname = - let pname_file = Procname.to_filename pname in + let pname_file = Typ.Procname.to_filename pname in pname_file ^ Config.specs_files_suffix (** path to the .specs file for the given procedure in the current results directory *) @@ -582,7 +582,7 @@ let load_summary_to_spec_table proc_name = let rec get_summary proc_name = try - Some (Procname.Hash.find spec_tbl proc_name) + Some (Typ.Procname.Hash.find spec_tbl proc_name) with Not_found -> if load_summary_to_spec_table proc_name then get_summary proc_name @@ -591,7 +591,7 @@ let rec get_summary proc_name = let get_summary_unsafe s proc_name = match get_summary proc_name with | None -> - failwithf "[%s] Specs.get_summary_unsafe: %a Not found" s Procname.pp proc_name + failwithf "[%s] Specs.get_summary_unsafe: %a Not found" s Typ.Procname.pp proc_name | Some summary -> summary (** Check if the procedure is from a library: @@ -673,7 +673,7 @@ let get_flag summary key = let get_specs_formals proc_name = match get_summary proc_name with | None -> - raise (Failure ("Specs.get_specs_formals: " ^ (Procname.to_string proc_name) ^ "Not_found")) + raise (Failure ("Specs.get_specs_formals: " ^ (Typ.Procname.to_string proc_name) ^ "Not_found")) | Some summary -> let specs = get_specs_from_payload summary in let formals = get_formals summary in @@ -709,7 +709,7 @@ let store_summary (summ1: summary) = (** Set the current status for the proc *) let set_status proc_name status = match get_summary proc_name with - | None -> raise (Failure ("Specs.set_status: " ^ (Procname.to_string proc_name) ^ " Not_found")) + | None -> raise (Failure ("Specs.set_status: " ^ (Typ.Procname.to_string proc_name) ^ " Not_found")) | Some summary -> add_summary proc_name { summary with status = status } let empty_payload = @@ -745,7 +745,7 @@ let init_summary ProcAttributes.proc_flags = proc_flags; }; proc_desc_option; } in - Procname.Hash.replace spec_tbl proc_attributes.ProcAttributes.proc_name summary + Typ.Procname.Hash.replace spec_tbl proc_attributes.ProcAttributes.proc_name summary (** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) let reset_summary proc_name attributes_opt proc_desc_option = diff --git a/infer/src/backend/specs.mli b/infer/src/backend/specs.mli index 34a9170a5..94724748e 100644 --- a/infer/src/backend/specs.mli +++ b/infer/src/backend/specs.mli @@ -94,10 +94,10 @@ module CallStats : sig type trace = (call_result * bool) list (** iterate over results of procedure calls *) - val iter : (Procname.t * Location.t -> trace -> unit) -> t -> unit + val iter : (Typ.Procname.t * Location.t -> trace -> unit) -> t -> unit (** trace a procedure call *) - val trace : t -> Procname.t -> Location.t -> call_result -> bool -> unit + val trace : t -> Typ.Procname.t -> Location.t -> call_result -> bool -> unit (** pretty print a call trace *) val pp_trace : Format.formatter -> trace -> unit @@ -159,10 +159,10 @@ type summary = { } (** Add the summary to the table for the given function *) -val add_summary : Procname.t -> summary -> unit +val add_summary : Typ.Procname.t -> summary -> unit (** Check if a summary for a given procedure exists in the models directory *) -val summary_exists_in_models : Procname.t -> bool +val summary_exists_in_models : Typ.Procname.t -> bool (** remove all the elements from the spec table *) val clear_spec_tbl : unit -> unit @@ -171,10 +171,10 @@ val clear_spec_tbl : unit -> unit val d_spec : 'a spec -> unit (** Return the summary option for the procedure name *) -val get_summary : Procname.t -> summary option +val get_summary : Typ.Procname.t -> summary option (** Get the procedure name *) -val get_proc_name : summary -> Procname.t +val get_proc_name : summary -> Typ.Procname.t (** Get the attributes of the procedure. *) val get_attributes : summary -> ProcAttributes.t @@ -195,16 +195,16 @@ val get_phase : summary -> phase val get_signature : summary -> string (** Return the specs for the proc in the spec table *) -val get_specs : Procname.t -> Prop.normal spec list +val get_specs : Typ.Procname.t -> Prop.normal spec list (** Return the specs and formal parameters for the proc in the spec table *) -val get_specs_formals : Procname.t -> Prop.normal spec list * (Mangled.t * Typ.t) list +val get_specs_formals : Typ.Procname.t -> Prop.normal spec list * (Mangled.t * Typ.t) list (** Get the specs from the payload of the summary. *) val get_specs_from_payload : summary -> Prop.normal spec list (** @deprecated Return the summary for the procedure name. Raises an exception when not found. *) -val get_summary_unsafe : string -> Procname.t -> summary +val get_summary_unsafe : string -> Typ.Procname.t -> summary (** Return the status (active v.s. inactive) of a procedure summary *) val get_status : summary -> status @@ -217,19 +217,19 @@ val is_active : summary -> bool val init_summary : ( Procdesc.Node.id list * (* nodes *) ProcAttributes.proc_flags * (* procedure flags *) - (Procname.t * Location.t) list * (* calls *) + (Typ.Procname.t * Location.t) list * (* calls *) ProcAttributes.t * (* attributes of the procedure *) Procdesc.t option) (* procdesc option *) -> unit (** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) -val reset_summary : Procname.t -> ProcAttributes.t option -> Procdesc.t option -> unit +val reset_summary : Typ.Procname.t -> ProcAttributes.t option -> Procdesc.t option -> unit (** Load procedure summary from the given file *) val load_summary : DB.filename -> summary option (** Check if a procedure summary exists for the given procedure name *) -val summary_exists : Procname.t -> bool +val summary_exists : Typ.Procname.t -> bool (** Cast a list of normalized specs to a list of specs *) val normalized_specs_to_specs : NormSpec.t list -> Prop.normal spec list @@ -258,20 +258,20 @@ val pdesc_resolve_attributes : Procdesc.t -> ProcAttributes.t then look at the attributes table. If no attributes can be found, return None. *) -val proc_resolve_attributes : Procname.t -> ProcAttributes.t option +val proc_resolve_attributes : Typ.Procname.t -> ProcAttributes.t option (** Check if the procedure is from a library: It's not defined, and there is no spec file for it. *) val proc_is_library : ProcAttributes.t -> bool (** Set the current status for the proc *) -val set_status : Procname.t -> status -> unit +val set_status : Typ.Procname.t -> status -> unit (** Convert spec into normal form w.r.t. variable renaming *) val spec_normalize : Tenv.t -> Prop.normal spec -> NormSpec.t (** path to the .specs file for the given procedure in the current results dir *) -val res_dir_specs_filename : Procname.t -> DB.filename +val res_dir_specs_filename : Typ.Procname.t -> DB.filename (** Save summary for the procedure into the spec database *) val store_summary : summary -> unit diff --git a/infer/src/backend/state.ml b/infer/src/backend/state.ml index 9eda91c6b..5ee1965f1 100644 --- a/infer/src/backend/state.ml +++ b/infer/src/backend/state.ml @@ -275,7 +275,7 @@ let get_session () = let get_path_pos () = let pname = match get_prop_tenv_pdesc () with | Some (_, _, pdesc) -> Procdesc.get_proc_name pdesc - | None -> Procname.from_string_c_fun "unknown_procedure" in + | None -> Typ.Procname.from_string_c_fun "unknown_procedure" in let nid = get_node_id () in (pname, (nid :> int)) @@ -307,7 +307,7 @@ let mark_instr_fail exn = fs.instr_fail <- fs.instr_fail + 1 type log_issue = - Procname.t -> + Typ.Procname.t -> ?loc: Location.t -> ?node_id: (int * int) -> ?session: int -> diff --git a/infer/src/backend/state.mli b/infer/src/backend/state.mli index 99312350a..e7710ab71 100644 --- a/infer/src/backend/state.mli +++ b/infer/src/backend/state.mli @@ -85,7 +85,7 @@ val mark_instr_ok : unit -> unit val mk_find_duplicate_nodes: Procdesc.t -> (Procdesc.Node.t -> Procdesc.NodeSet.t) type log_issue = - Procname.t -> + Typ.Procname.t -> ?loc: Location.t -> ?node_id: (int * int) -> ?session: int -> @@ -94,7 +94,7 @@ type log_issue = unit (** Process the failures during symbolic execution of a procedure *) -val process_execution_failures : log_issue -> Procname.t -> unit +val process_execution_failures : log_issue -> Typ.Procname.t -> unit (** Reset all the global data. *) val reset : unit -> unit diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index e727c9f56..dae8eb1d9 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -55,7 +55,7 @@ let get_blocks_nullified node = captured variables in the block we obtain a leak. *) let check_block_retain_cycle tenv caller_pname prop block_nullified = let mblock = Pvar.get_name block_nullified in - let block_pname = Procname.mangled_objc_block (Mangled.to_string mblock) in + let block_pname = Typ.Procname.mangled_objc_block (Mangled.to_string mblock) in let block_captured = match AttributesTable.load_attributes block_pname with | Some attributes -> @@ -366,10 +366,10 @@ and prune_union tenv ~positive condition1 condition2 prop = let dangerous_functions = let dangerous_list = ["gets"] in - ref ((List.map ~f:Procname.from_string_c_fun) dangerous_list) + ref ((List.map ~f:Typ.Procname.from_string_c_fun) dangerous_list) let check_inherently_dangerous_function caller_pname callee_pname = - if List.exists ~f:(Procname.equal callee_pname) !dangerous_functions then + if List.exists ~f:(Typ.Procname.equal callee_pname) !dangerous_functions then let exn = Exceptions.Inherently_dangerous_function (Localise.desc_inherently_dangerous_function callee_pname) in @@ -472,7 +472,7 @@ let check_deallocate_static_memory prop_after = let method_exists right_proc_name methods = if Config.curr_language_is Config.Java then - List.exists ~f:(fun meth_name -> Procname.equal right_proc_name meth_name) methods + List.exists ~f:(fun meth_name -> Typ.Procname.equal right_proc_name meth_name) methods else (* ObjC/C++ case : The attribute map will only exist when we have code for the method or the method has been called directly somewhere. It can still be that this is not the case but we have a model for the method. *) @@ -486,7 +486,7 @@ let resolve_method tenv class_name proc_name = let rec resolve (class_name: Typename.t) = visited := Typename.Set.add class_name !visited; let right_proc_name = - Procname.replace_class proc_name class_name in + Typ.Procname.replace_class proc_name class_name in match class_name, Tenv.lookup tenv class_name with | TN_csu (Class _, _), Some { methods; supers } -> if method_exists right_proc_name methods then @@ -521,15 +521,15 @@ let resolve_typename prop receiver_exp = (** If the dynamic type of the receiver actual T_actual is a subtype of the reciever type T_formal in the signature of [pname], resolve [pname] to T_actual.[pname]. *) -let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t list = +let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Typ.Procname.t list = let resolve receiver_exp pname prop = match resolve_typename prop receiver_exp with | Some class_name -> resolve_method tenv class_name pname | None -> pname in let get_receiver_typ pname fallback_typ = match pname with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> begin - let name = Procname.java_get_class_type_name pname_java in + let name = Typ.Procname.java_get_class_type_name pname_java in match Tenv.lookup tenv name with | Some _ -> Typ.Tptr (Tstruct name, Pk_pointer) | None -> fallback_typ @@ -568,7 +568,7 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t let resolved_pname = do_resolve callee_pname receiver_exp actual_receiver_typ in let feasible_targets = List.filter ~f:may_dispatch_to targets in (* make sure [resolved_pname] is not a duplicate *) - if List.mem ~equal:Procname.equal feasible_targets resolved_pname + if List.mem ~equal:Typ.Procname.equal feasible_targets resolved_pname then feasible_targets else resolved_pname :: feasible_targets else @@ -577,7 +577,7 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t match call_flags.CallFlags.cf_targets with | target :: _ when call_flags.CallFlags.cf_interface && receiver_types_equal callee_pname actual_receiver_typ && - Procname.equal resolved_target callee_pname -> + Typ.Procname.equal resolved_target callee_pname -> (* "production mode" of dynamic dispatch for Java: unsound, but faster. the handling is restricted to interfaces: if we can't resolve an interface call, we pick the first implementation of the interface and call it *) @@ -590,9 +590,9 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t (** Resolve the name of the procedure to call based on the type of the arguments *) -let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = +let resolve_java_pname tenv prop args pname_java call_flags : Typ.Procname.java = let resolve_from_args resolved_pname_java args = - let parameters = Procname.java_get_parameters resolved_pname_java in + let parameters = Typ.Procname.java_get_parameters resolved_pname_java in if List.length args <> List.length parameters then resolved_pname_java else @@ -601,10 +601,10 @@ let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = ~f:(fun accu (arg_exp, _) name -> match resolve_typename prop arg_exp with | Some class_name -> - (Procname.split_classname (Typename.name class_name)) :: accu + (Typ.Procname.split_classname (Typename.name class_name)) :: accu | None -> name :: accu) - ~init:[] args (Procname.java_get_parameters resolved_pname_java) |> List.rev in - Procname.java_replace_parameters resolved_pname_java resolved_params in + ~init:[] args (Typ.Procname.java_get_parameters resolved_pname_java) |> List.rev in + Typ.Procname.java_replace_parameters resolved_pname_java resolved_params in let resolved_pname_java, other_args = match args with | [] -> @@ -615,8 +615,8 @@ let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = match resolve_typename prop first_arg with | Some class_name -> begin - match resolve_method tenv class_name (Procname.Java pname_java) with - | Procname.Java resolved_pname_java -> + match resolve_method tenv class_name (Typ.Procname.Java pname_java) with + | Typ.Procname.Java resolved_pname_java -> resolved_pname_java | _ -> pname_java @@ -625,7 +625,7 @@ let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = pname_java end in resolved, other_args - | _ :: other_args when Procname.is_constructor (Procname.Java pname_java) -> + | _ :: other_args when Typ.Procname.is_constructor (Typ.Procname.Java pname_java) -> pname_java, other_args | args -> pname_java, args in @@ -635,11 +635,11 @@ let resolve_java_pname tenv prop args pname_java call_flags : Procname.java = (** Resolve the procedure name and run the analysis of the resolved procedure if not already analyzed *) let resolve_and_analyze - tenv caller_pdesc prop args callee_proc_name call_flags : Procname.t * Specs.summary option = + tenv caller_pdesc prop args callee_proc_name call_flags : Typ.Procname.t * Specs.summary option = (* TODO (#15748878): Fix conflict with method overloading by encoding in the procedure name whether the method is defined or generated by the specialization *) let analyze_ondemand resolved_pname : Specs.summary option = - if Procname.equal resolved_pname callee_proc_name then + if Typ.Procname.equal resolved_pname callee_proc_name then Ondemand.analyze_proc_name ~propagate_exceptions:true caller_pdesc callee_proc_name else (* Create the type sprecialized procedure description and analyze it directly *) @@ -656,8 +656,8 @@ let resolve_and_analyze (Ondemand.get_proc_desc callee_proc_name)) in Option.bind resolved_proc_desc_option analyze in let resolved_pname = match callee_proc_name with - | Procname.Java callee_proc_name_java -> - Procname.Java + | Typ.Procname.Java callee_proc_name_java -> + Typ.Procname.Java (resolve_java_pname tenv prop args callee_proc_name_java call_flags) | _ -> callee_proc_name in @@ -668,11 +668,11 @@ let resolve_and_analyze to be only the protocol. *) let call_constructor_url_update_args pname actual_params = let url_pname = - Procname.Java - (Procname.java + Typ.Procname.Java + (Typ.Procname.java (Typename.Java.from_string "java.net.URL") None "" - [(Some "java.lang"), "String"] Procname.Non_Static) in - if (Procname.equal url_pname pname) then + [(Some "java.lang"), "String"] Typ.Procname.Non_Static) in + if (Typ.Procname.equal url_pname pname) then (match actual_params with | [this; (Exp.Const (Const.Cstr s), atype)] -> let parts = Str.split (Str.regexp_string "://") s in @@ -705,9 +705,9 @@ let receiver_self receiver prop = a check for null, which is considered good practice. *) let force_objc_init_return_nil pdesc callee_pname tenv ret_id pre path receiver = let current_pname = Procdesc.get_proc_name pdesc in - if Procname.is_constructor callee_pname && + if Typ.Procname.is_constructor callee_pname && receiver_self receiver pre && - !Config.footprint && Procname.is_constructor current_pname then + !Config.footprint && Typ.Procname.is_constructor current_pname then match ret_id with | Some (ret_id, _) -> let propset = prune_ne tenv ~positive:false (Exp.Var ret_id) Exp.zero pre in @@ -728,7 +728,7 @@ let handle_objc_instance_method_call_or_skip pdesc tenv actual_pars path callee_ ret_id res = let path_description = "Message " ^ - (Procname.to_simplified_string callee_pname) ^ + (Typ.Procname.to_simplified_string callee_pname) ^ " with receiver nil returns nil." in let receiver = (match actual_pars with | (e, _):: _ -> e @@ -756,7 +756,7 @@ let handle_objc_instance_method_call_or_skip pdesc tenv actual_pars path callee_ let path = Paths.Path.add_description path path_description in L.d_strln ("Object-C method " ^ - Procname.to_string callee_pname ^ + Typ.Procname.to_string callee_pname ^ " called with nil receiver. Returning 0/nil"); (* We wish to nullify the result. However, in some cases, we want to add the attribute OBJC_NULL to it so that we *) @@ -826,10 +826,10 @@ let add_struct_value_to_footprint tenv abduced_pv typ prop = prop', struct_strexp let add_constraints_on_retval tenv pdesc prop ret_exp ~has_nullable_annot typ callee_pname callee_loc= - if Procname.is_infer_undefined callee_pname then prop + if Typ.Procname.is_infer_undefined callee_pname then prop else let is_rec_call pname = (* TODO: (t7147096) extend this to detect mutual recursion *) - Procname.equal pname (Procdesc.get_proc_name pdesc) in + Typ.Procname.equal pname (Procdesc.get_proc_name pdesc) in let already_has_abduced_retval p abduced_ret_pv = List.exists ~f:(fun hpred -> match hpred with @@ -1028,7 +1028,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in Reporting.log_info current_pname exn; L.d_strln - ("Undefined function " ^ Procname.to_string callee_pname + ("Undefined function " ^ Typ.Procname.to_string callee_pname ^ ", returning undefined value."); (match Specs.get_summary current_pname with | None -> () @@ -1155,8 +1155,8 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path let attrs_opt = let attr_opt = Option.map ~f:Procdesc.get_attributes callee_pdesc_opt in match attr_opt, resolved_pname with - | Some attrs, Procname.ObjC_Cpp _ -> Some attrs - | None, Procname.ObjC_Cpp _ -> AttributesTable.load_attributes resolved_pname + | Some attrs, Typ.Procname.ObjC_Cpp _ -> Some attrs + | None, Typ.Procname.ObjC_Cpp _ -> AttributesTable.load_attributes resolved_pname | _ -> None in let objc_property_accessor_ret_typ_opt = match attrs_opt with @@ -1203,7 +1203,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path end else begin L.d_str "Unknown function pointer "; Sil.d_exp fun_exp; L.d_strln ", returning undefined value."; - let callee_pname = Procname.from_string_c_fun "__function_pointer__" in + let callee_pname = Typ.Procname.from_string_c_fun "__function_pointer__" in unknown_or_scan_call ~is_scan:false None Annot.Item.empty Builtin.{ pdesc= current_pdesc; instr; tenv; prop_= prop_r; path; ret_id; args= n_actual_params; proc_name= callee_pname; loc; } @@ -1213,8 +1213,8 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path let eprop = Prop.expose prop_ in match List.partition_tf ~f:(function - | Sil.Hpointsto (Exp.Lvar pvar', _, _) -> Pvar.equal pvar pvar' - | _ -> false) eprop.Prop.sigma with + | Sil.Hpointsto (Exp.Lvar pvar', _, _) -> Pvar.equal pvar pvar' + | _ -> false) eprop.Prop.sigma with | [Sil.Hpointsto(e, se, typ)], sigma' -> let sigma'' = let se' = execute_nullify_se se in @@ -1439,7 +1439,7 @@ and unknown_or_scan_call ~is_scan ret_type_option ret_annots let pre_final = (* in Java, assume that skip functions close resources passed as params *) let pre_1 = - if Procname.is_java callee_pname + if Typ.Procname.is_java callee_pname then remove_file_attribute pre else pre in let pre_2 = match ret_id, ret_type_option with @@ -1588,7 +1588,7 @@ and proc_call summary {Builtin.pdesc; tenv; prop_= pre; path; ret_id; args= actu L.d_str "formal parameters: "; Typ.d_list formal_types; L.d_ln (); actual_pars | [], _ -> - L.d_str ("**** ERROR: Procedure " ^ Procname.to_string callee_pname); + L.d_str ("**** ERROR: Procedure " ^ Typ.Procname.to_string callee_pname); L.d_strln (" mismatch in the number of parameters ****"); L.d_str "actual parameters: "; Sil.d_exp_list (List.map ~f:fst actual_pars); L.d_ln (); L.d_str "formal parameters: "; Typ.d_list formal_types; L.d_ln (); diff --git a/infer/src/backend/symExec.mli b/infer/src/backend/symExec.mli index 4bdeaebef..af2300d44 100644 --- a/infer/src/backend/symExec.mli +++ b/infer/src/backend/symExec.mli @@ -32,12 +32,12 @@ val unknown_or_scan_call : is_scan:bool -> Typ.t option -> Annot.Item.t -> Built val check_variadic_sentinel : ?fails_on_nil:bool -> int -> int * int -> Builtin.t val check_untainted : - Tenv.t -> Exp.t -> PredSymb.taint_kind -> Procname.t -> Procname.t -> Prop.normal Prop.t -> + Tenv.t -> Exp.t -> PredSymb.taint_kind -> Typ.Procname.t -> Typ.Procname.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Check for arithmetic problems and normalize an expression. *) val check_arith_norm_exp : - Tenv.t -> Procname.t -> Exp.t -> Prop.normal Prop.t -> Exp.t * Prop.normal Prop.t + Tenv.t -> Typ.Procname.t -> Exp.t -> Prop.normal Prop.t -> Exp.t * Prop.normal Prop.t val prune : Tenv.t -> positive:bool -> Exp.t -> Prop.normal Prop.t -> Propset.t @@ -45,4 +45,4 @@ val prune : Tenv.t -> positive:bool -> Exp.t -> Prop.normal Prop.t -> Propset.t the procname that the method name will actually resolve to at runtime. For example, if we have a procname like Foo.toString() and Foo does not override toString(), we must resolve the call to toString(). We will end up with Super.toString() where Super is some superclass of Foo. *) -val resolve_method : Tenv.t -> Typename.t -> Procname.t -> Procname.t +val resolve_method : Tenv.t -> Typename.t -> Typ.Procname.t -> Typ.Procname.t diff --git a/infer/src/backend/tabulation.ml b/infer/src/backend/tabulation.ml index cbab5631b..c19680e68 100644 --- a/infer/src/backend/tabulation.ml +++ b/infer/src/backend/tabulation.ml @@ -30,7 +30,7 @@ type deref_error = | Deref_freed of PredSymb.res_action (** dereference a freed pointer *) | Deref_minusone (** dereference -1 *) | Deref_null of PredSymb.path_pos (** dereference null *) - | Deref_undef of Procname.t * Location.t * PredSymb.path_pos + | Deref_undef of Typ.Procname.t * Location.t * PredSymb.path_pos (** dereference a value coming from the given undefined function *) | Deref_undef_exp (** dereference an undefined expression *) @@ -116,7 +116,7 @@ let spec_rename_vars pname spec = (** Find and number the specs for [proc_name], after renaming their vars, and also return the parameters *) -let spec_find_rename trace_call (proc_name : Procname.t) +let spec_find_rename trace_call (proc_name : Typ.Procname.t) : (int * Prop.exposed Specs.spec) list * Pvar.t list = try let count = ref 0 in @@ -127,7 +127,7 @@ let spec_find_rename trace_call (proc_name : Procname.t) begin trace_call Specs.CallStats.CR_not_found; raise (Exceptions.Precondition_not_found - (Localise.verbatim_desc (Procname.to_string proc_name), __POS__)) + (Localise.verbatim_desc (Typ.Procname.to_string proc_name), __POS__)) end; let formal_parameters = List.map ~f:(fun (x, _) -> Pvar.mk_callee x proc_name) formals in @@ -135,10 +135,10 @@ let spec_find_rename trace_call (proc_name : Procname.t) with Not_found -> begin L.d_strln ("ERROR: found no entry for procedure " ^ - Procname.to_string proc_name ^ + Typ.Procname.to_string proc_name ^ ". Give up..."); raise (Exceptions.Precondition_not_found - (Localise.verbatim_desc (Procname.to_string proc_name), __POS__)) + (Localise.verbatim_desc (Typ.Procname.to_string proc_name), __POS__)) end (** Process a splitting coming straight from a call to the prover: @@ -898,7 +898,7 @@ let mk_posts tenv ret_id prop callee_pname callee_attrs posts = let last_call_ret_non_null = List.exists ~f:(function - | Sil.Apred (Aretval (pname, _), [exp]) when Procname.equal callee_pname pname -> + | Sil.Apred (Aretval (pname, _), [exp]) when Typ.Procname.equal callee_pname pname -> Prover.check_disequal tenv prop exp Exp.zero | _ -> false) (Attribute.get_all prop) in @@ -1264,8 +1264,8 @@ let exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc re let returns_nullable ret_annot = Annotations.ia_is_nullable ret_annot in let should_add_ret_attr _ = let is_likely_getter = function - | Procname.Java pn_java -> - Int.equal (List.length (Procname.java_get_parameters pn_java)) 0 + | Typ.Procname.Java pn_java -> + Int.equal (List.length (Typ.Procname.java_get_parameters pn_java)) 0 | _ -> false in (Config.idempotent_getters && @@ -1298,8 +1298,8 @@ let exe_function_call ("Found " ^ string_of_int nspecs ^ " specs for function " ^ - Procname.to_string callee_pname); - L.d_strln ("START EXECUTING SPECS FOR " ^ Procname.to_string callee_pname ^ " from state"); + Typ.Procname.to_string callee_pname); + L.d_strln ("START EXECUTING SPECS FOR " ^ Typ.Procname.to_string callee_pname ^ " from state"); Prop.d_prop prop; L.d_ln (); let exe_one_spec (n, spec) = exe_spec diff --git a/infer/src/backend/tabulation.mli b/infer/src/backend/tabulation.mli index 3346133a8..5926eef03 100644 --- a/infer/src/backend/tabulation.mli +++ b/infer/src/backend/tabulation.mli @@ -28,13 +28,13 @@ val find_dereference_without_null_check_in_sexp : Sil.strexp -> (int * PredSymb. (** raise a cast exception *) val create_cast_exception : - Tenv.t -> Logging.ml_loc -> Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn + Tenv.t -> Logging.ml_loc -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn (** check if a prop is an exception *) -val prop_is_exn : Procname.t -> 'a Prop.t -> bool +val prop_is_exn : Typ.Procname.t -> 'a Prop.t -> bool (** when prop is an exception, return the exception name *) -val prop_get_exn_name : Procname.t -> 'a Prop.t -> Typename.t option +val prop_get_exn_name : Typ.Procname.t -> 'a Prop.t -> Typename.t option (** search in prop contains an error state *) val lookup_custom_errors : 'a Prop.t -> string option @@ -44,6 +44,6 @@ val d_splitting : splitting -> unit (** Execute the function call and return the list of results with return value *) val exe_function_call: - ProcAttributes.t -> Tenv.t -> (Ident.t * Typ.t) option -> Procdesc.t -> Procname.t -> + ProcAttributes.t -> Tenv.t -> (Ident.t * Typ.t) option -> Procdesc.t -> Typ.Procname.t -> Location.t -> (Exp.t * Typ.t) list -> Prop.normal Prop.t -> Paths.Path.t -> (Prop.normal Prop.t * Paths.Path.t) list diff --git a/infer/src/backend/taint.ml b/infer/src/backend/taint.ml index f79d474ba..093021383 100644 --- a/infer/src/backend/taint.ml +++ b/infer/src/backend/taint.ml @@ -262,20 +262,20 @@ let functions_with_tainted_params = [ (* turn string specificiation of Java method into a procname *) let java_method_to_procname java_method = - Procname.Java - (Procname.java + Typ.Procname.Java + (Typ.Procname.java (Typename.Java.from_string java_method.classname) - (Some (Procname.split_classname java_method.ret_type)) + (Some (Typ.Procname.split_classname java_method.ret_type)) java_method.method_name - (List.map ~f:Procname.split_classname java_method.params) - (if java_method.is_static then Procname.Static else Procname.Non_Static)) + (List.map ~f:Typ.Procname.split_classname java_method.params) + (if java_method.is_static then Typ.Procname.Static else Typ.Procname.Non_Static)) (* turn string specificiation of an objc method into a procname *) let objc_method_to_procname objc_method = - let method_kind = Procname.objc_method_kind_of_bool (not objc_method.is_static) in + let method_kind = Typ.Procname.objc_method_kind_of_bool (not objc_method.is_static) in let typename = Typename.Objc.from_string objc_method.classname in - Procname.ObjC_Cpp - (Procname.objc_cpp typename objc_method.method_name method_kind) + Typ.Procname.ObjC_Cpp + (Typ.Procname.objc_cpp typename objc_method.method_name method_kind) let taint_spec_to_taint_info taint_spec = let taint_source = @@ -306,7 +306,7 @@ let attrs_opt_get_annots = function (** returns true if [callee_pname] returns a tainted value *) let returns_tainted callee_pname callee_attrs_opt = let procname_matches taint_info = - Procname.equal taint_info.PredSymb.taint_source callee_pname in + Typ.Procname.equal taint_info.PredSymb.taint_source callee_pname in match List.find ~f:procname_matches sources with | Some taint_info -> Some taint_info.PredSymb.taint_kind @@ -320,7 +320,7 @@ let returns_tainted callee_pname callee_attrs_opt = let find_callee taint_infos callee_pname = List.find - ~f:(fun (taint_info, _) -> Procname.equal taint_info.PredSymb.taint_source callee_pname) + ~f:(fun (taint_info, _) -> Typ.Procname.equal taint_info.PredSymb.taint_source callee_pname) taint_infos (** returns list of zero-indexed argument numbers of [callee_pname] that may be tainted *) @@ -328,7 +328,7 @@ let accepts_sensitive_params callee_pname callee_attrs_opt = match find_callee taint_sinks callee_pname with | None -> let _, param_annots = attrs_opt_get_annots callee_attrs_opt in - let offset = if Procname.java_is_static callee_pname then 0 else 1 in + let offset = if Typ.Procname.java_is_static callee_pname then 0 else 1 in let indices_and_annots = List.mapi ~f:(fun param_num attr -> param_num + offset, attr) param_annots in let tag_tainted_indices acc (index, attr) = diff --git a/infer/src/backend/taint.mli b/infer/src/backend/taint.mli index cb6852fc0..eb99b9113 100644 --- a/infer/src/backend/taint.mli +++ b/infer/src/backend/taint.mli @@ -10,15 +10,15 @@ open! IStd (** returns true if [callee_pname] returns a tainted value *) -val returns_tainted : Procname.t -> ProcAttributes.t option -> PredSymb.taint_kind option +val returns_tainted : Typ.Procname.t -> ProcAttributes.t option -> PredSymb.taint_kind option (** returns list of zero-indexed argument numbers of [callee_pname] that may be tainted *) val accepts_sensitive_params : - Procname.t -> ProcAttributes.t option -> (int * PredSymb.taint_kind) list + Typ.Procname.t -> ProcAttributes.t option -> (int * PredSymb.taint_kind) list (** returns list of zero-indexed parameter numbers of [callee_pname] that should be considered tainted during symbolic execution *) -val tainted_params : Procname.t -> (int * PredSymb.taint_kind) list +val tainted_params : Typ.Procname.t -> (int * PredSymb.taint_kind) list (** returns the taint_kind of [fieldname] if it has a taint source annotation *) val has_taint_annotation : Ident.fieldname -> Typ.Struct.t -> bool diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index a26b984ec..2ee26e585 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -33,7 +33,7 @@ struct module Domain = Dom.Mem module Sem = BufferOverrunSemantics.Make (CFG) - type extras = Procname.t -> Procdesc.t option + type extras = Typ.Procname.t -> Procdesc.t option (* NOTE: heuristic *) let get_malloc_info : Exp.t -> Typ.t * Exp.t @@ -44,7 +44,7 @@ struct | x -> (Typ.Tint Typ.IChar, x) let model_malloc - : Procname.t -> (Ident.t * Typ.t) option -> (Exp.t * Typ.t) list -> CFG.node + : Typ.Procname.t -> (Ident.t * Typ.t) option -> (Exp.t * Typ.t) list -> CFG.node -> Dom.Mem.t -> Dom.Mem.t = fun pname ret params node mem -> match ret with @@ -56,7 +56,7 @@ struct | _ -> mem let model_realloc - : Procname.t -> (Ident.t * Typ.t) option -> (Exp.t * Typ.t) list -> CFG.node + : Typ.Procname.t -> (Ident.t * Typ.t) option -> (Exp.t * Typ.t) list -> CFG.node -> Dom.Mem.t -> Dom.Mem.t = fun pname ret params node mem -> model_malloc pname ret (List.tl_exn params) node mem @@ -87,11 +87,11 @@ struct | _ -> mem let handle_unknown_call - : Procname.t -> (Ident.t * Typ.t) option -> Procname.t + : Typ.Procname.t -> (Ident.t * Typ.t) option -> Typ.Procname.t -> (Exp.t * Typ.t) list -> CFG.node -> Dom.Mem.t -> Location.t -> Dom.Mem.t = fun pname ret callee_pname params node mem loc -> - match Procname.get_method callee_pname with + match Typ.Procname.get_method callee_pname with | "malloc" | "__new_array" -> model_malloc pname ret params node mem | "realloc" -> model_realloc pname ret params node mem @@ -101,7 +101,7 @@ struct | _ -> model_unknown_itv ret mem let rec declare_array - : Procname.t -> CFG.node -> Loc.t -> Typ.t -> IntLit.t -> inst_num:int + : Typ.Procname.t -> CFG.node -> Loc.t -> Typ.t -> IntLit.t -> inst_num:int -> dimension:int -> Dom.Mem.astate -> Dom.Mem.astate = fun pname node loc typ len ~inst_num ~dimension mem -> let size = IntLit.to_int len |> Itv.of_int in @@ -123,7 +123,7 @@ struct | _ -> mem let declare_symbolic_array - : Procname.t -> Tenv.t -> CFG.node -> Loc.t -> Typ.t -> inst_num:int + : Typ.Procname.t -> Tenv.t -> CFG.node -> Loc.t -> Typ.t -> inst_num:int -> sym_num:int -> dimension:int -> Dom.Mem.astate -> Dom.Mem.astate * int = fun pname tenv node loc typ ~inst_num ~sym_num ~dimension mem -> let offset = Itv.make_sym pname sym_num in @@ -187,7 +187,7 @@ struct |> fst3 let instantiate_ret - : Tenv.t -> Procdesc.t option -> Procname.t -> (Exp.t * Typ.t) list + : Tenv.t -> Procdesc.t option -> Typ.Procname.t -> (Exp.t * Typ.t) list -> Dom.Mem.t -> Dom.Summary.t -> Location.t -> Dom.Val.astate = fun tenv callee_pdesc callee_pname params caller_mem summary loc -> let callee_entry_mem = Dom.Summary.get_input summary in @@ -279,10 +279,10 @@ module Sem = BufferOverrunSemantics.Make (CFG) module Report = struct - type extras = Procname.t -> Procdesc.t option + type extras = Typ.Procname.t -> Procdesc.t option let add_condition - : Procname.t -> CFG.node -> Exp.t -> Location.t -> Dom.Mem.astate + : Typ.Procname.t -> CFG.node -> Exp.t -> Location.t -> Dom.Mem.astate -> Dom.ConditionSet.t -> Dom.ConditionSet.t = fun pname node exp loc mem cond_set -> let array_access = @@ -318,7 +318,7 @@ struct | None -> cond_set let instantiate_cond - : Tenv.t -> Procname.t -> Procdesc.t option -> (Exp.t * Typ.t) list + : Tenv.t -> Typ.Procname.t -> Procdesc.t option -> (Exp.t * Typ.t) list -> Dom.Mem.t -> Summary.summary -> Location.t -> Dom.ConditionSet.t = fun tenv caller_pname callee_pdesc params caller_mem summary loc -> let callee_entry_mem = Dom.Summary.get_input summary in @@ -402,7 +402,7 @@ struct in match alarm with | None -> () - | Some bucket when Procname.equal pname caller_pname -> + | Some bucket when Typ.Procname.equal pname caller_pname -> let description = Dom.Condition.to_string cond in let error_desc = Localise.desc_buffer_overrun bucket description in let exn = Exceptions.Checkers (Localise.to_string Localise.buffer_overrun, error_desc) in @@ -436,10 +436,10 @@ let compute_post Some (entry_mem, exit_mem, cond_set) | _ -> None -let print_summary : Procname.t -> Dom.Summary.t -> unit +let print_summary : Typ.Procname.t -> Dom.Summary.t -> unit = fun proc_name s -> F.fprintf F.err_formatter "@.@[Summary of %a :@," - Procname.pp proc_name; + Typ.Procname.pp proc_name; Dom.Summary.pp_summary F.err_formatter s; F.fprintf F.err_formatter "@]@." diff --git a/infer/src/bufferoverrun/bufferOverrunDomain.ml b/infer/src/bufferoverrun/bufferOverrunDomain.ml index 8fda74239..b8771a616 100644 --- a/infer/src/bufferoverrun/bufferOverrunDomain.ml +++ b/infer/src/bufferoverrun/bufferOverrunDomain.ml @@ -21,13 +21,13 @@ struct type t = { idx : Itv.astate; size : Itv.astate; - proc_name : Procname.t; + proc_name : Typ.Procname.t; loc : Location.t; trace : trace; id : string } [@@deriving compare] -and trace = Intra of Procname.t - | Inter of Procname.t * Procname.t * Location.t +and trace = Intra of Typ.Procname.t + | Inter of Typ.Procname.t * Typ.Procname.t * Location.t [@@deriving compare] and astate = t @@ -60,7 +60,7 @@ let pp : F.formatter -> t -> unit else match c.trace with Inter (_, pname, loc) -> - let pname = Procname.to_string pname in + let pname = Typ.Procname.to_string pname in F.fprintf fmt "%a < %a at %a by call %s() at %s" Itv.pp c.idx Itv.pp c.size pp_location c pname (string_of_location loc) | Intra _ -> F.fprintf fmt "%a < %a at %a" Itv.pp c.idx Itv.pp c.size pp_location c @@ -71,10 +71,10 @@ let get_location : t -> Location.t let get_trace : t -> trace = fun c -> c.trace -let get_proc_name : t -> Procname.t +let get_proc_name : t -> Typ.Procname.t = fun c -> c.proc_name -let make : Procname.t -> Location.t -> string -> idx:Itv.t -> size:Itv.t -> t +let make : Typ.Procname.t -> Location.t -> string -> idx:Itv.t -> size:Itv.t -> t = fun proc_name loc id ~idx ~size -> { proc_name; idx; size; loc; id ; trace = Intra proc_name } @@ -129,11 +129,11 @@ let to_string : t -> string ^ (match c.trace with Inter (_, pname, _) -> " by call " - ^ Procname.to_string pname + ^ Typ.Procname.to_string pname ^ "() " | Intra _ -> "") -let subst : t -> Itv.Bound.t Itv.SubstMap.t -> Procname.t -> Procname.t -> Location.t -> t +let subst : t -> Itv.Bound.t Itv.SubstMap.t -> Typ.Procname.t -> Typ.Procname.t -> Location.t -> t = fun c subst_map caller_pname callee_pname loc -> if Itv.is_symbolic c.idx || Itv.is_symbolic c.size then { c with idx = Itv.subst c.idx subst_map; @@ -152,11 +152,11 @@ struct end) let add_bo_safety - : Procname.t -> Location.t -> string -> idx:Itv.t -> size:Itv.t -> t -> t + : Typ.Procname.t -> Location.t -> string -> idx:Itv.t -> size:Itv.t -> t -> t = fun pname loc id ~idx ~size cond -> add (Condition.make pname loc id ~idx ~size) cond - let subst : t -> Itv.Bound.t Itv.SubstMap.t -> Procname.t -> Procname.t -> Location.t -> t + let subst : t -> Itv.Bound.t Itv.SubstMap.t -> Typ.Procname.t -> Typ.Procname.t -> Location.t -> t = fun x subst_map caller_pname callee_pname loc -> fold (fun e -> add (Condition.subst e subst_map caller_pname callee_pname loc)) x empty @@ -270,7 +270,7 @@ struct let modify_itv : Itv.t -> t -> t = fun i x -> { x with itv = i } - let make_sym : Procname.t -> int -> t + let make_sym : Typ.Procname.t -> int -> t = fun pname i -> { bot with itv = Itv.make_sym pname i } let unknown_bit : t -> t diff --git a/infer/src/bufferoverrun/bufferOverrunSemantics.ml b/infer/src/bufferoverrun/bufferOverrunSemantics.ml index 70aaa4945..c19698ae3 100644 --- a/infer/src/bufferoverrun/bufferOverrunSemantics.ml +++ b/infer/src/bufferoverrun/bufferOverrunSemantics.ml @@ -123,9 +123,9 @@ struct | Binop.LOr -> Val.lor_sem v1 v2 | Binop.PtrFld -> raise Not_implemented - let get_allocsite : Procname.t -> CFG.node -> int -> int -> string + let get_allocsite : Typ.Procname.t -> CFG.node -> int -> int -> string = fun proc_name node inst_num dimension -> - let proc_name = Procname.to_string proc_name in + let proc_name = Typ.Procname.to_string proc_name in let node_num = CFG.hash node |> string_of_int in let inst_num = string_of_int inst_num in let dimension = string_of_int dimension in @@ -133,7 +133,7 @@ struct |> Allocsite.make let eval_array_alloc - : Procname.t -> CFG.node -> Typ.t -> Itv.t -> Itv.t -> int -> int -> Val.t + : Typ.Procname.t -> CFG.node -> Typ.t -> Itv.t -> Itv.t -> int -> int -> Val.t = fun pdesc node typ offset size inst_num dimension -> let allocsite = get_allocsite pdesc node inst_num dimension in let stride = sizeof typ |> Itv.of_int in diff --git a/infer/src/bufferoverrun/itv.ml b/infer/src/bufferoverrun/itv.ml index ce43e1783..60592f525 100644 --- a/infer/src/bufferoverrun/itv.ml +++ b/infer/src/bufferoverrun/itv.ml @@ -18,17 +18,17 @@ let sym_size = ref 0 module Symbol = struct - type t = Procname.t * int [@@deriving compare] + type t = Typ.Procname.t * int [@@deriving compare] let eq = [%compare.equal : t] - let get_new : Procname.t -> t + let get_new : Typ.Procname.t -> t = fun pname -> let i = !sym_size in sym_size := !sym_size + 1; (pname, i) - let make : Procname.t -> int -> t + let make : Typ.Procname.t -> int -> t = fun pname i -> (pname, i) let pp : F.formatter -> t -> unit @@ -36,7 +36,7 @@ struct if Config.bo_debug <= 1 then F.fprintf fmt "s$%d" (snd x) else - F.fprintf fmt "%s-s$%d" (fst x |> Procname.to_string) (snd x) + F.fprintf fmt "%s-s$%d" (fst x |> Typ.Procname.to_string) (snd x) end module SubstMap = Caml.Map.Make (Symbol) @@ -76,10 +76,10 @@ struct let le : t -> t -> bool = fun x y -> M.for_all (fun s v -> v <= find s y) x - let get_new : Procname.t -> t + let get_new : Typ.Procname.t -> t = fun pname -> M.add (Symbol.get_new pname) 1 empty - let make : Procname.t -> int -> t + let make : Typ.Procname.t -> int -> t = fun pname i -> M.add (Symbol.make pname i) 1 empty let eq : t -> t -> bool @@ -536,13 +536,13 @@ struct let of_int : int -> t = fun n -> (Bound.of_int n, Bound.of_int n) - let get_new_sym : Procname.t -> t + let get_new_sym : Typ.Procname.t -> t = fun pname -> let lower = Bound.of_sym (SymLinear.get_new pname) in let upper = Bound.of_sym (SymLinear.get_new pname) in (lower, upper) - let make_sym : Procname.t -> int -> t + let make_sym : Typ.Procname.t -> int -> t = fun pname i -> let lower = Bound.of_sym (SymLinear.make pname i) in let upper = Bound.of_sym (SymLinear.make pname (i+1)) in @@ -936,10 +936,10 @@ let plus : t -> t -> t let minus : t -> t -> t = lift2 ItvPure.minus -let get_new_sym : Procname.t -> t +let get_new_sym : Typ.Procname.t -> t = fun pname -> NonBottom (ItvPure.get_new_sym pname) -let make_sym : Procname.t -> int -> t +let make_sym : Typ.Procname.t -> int -> t = fun pname i -> NonBottom (ItvPure.make_sym pname i) let neg : t -> t diff --git a/infer/src/checkers/BoundedCallTree.ml b/infer/src/checkers/BoundedCallTree.ml index 40980d78a..d52a393db 100644 --- a/infer/src/checkers/BoundedCallTree.ml +++ b/infer/src/checkers/BoundedCallTree.ml @@ -14,7 +14,7 @@ module L = Logging (** find transitive procedure calls for each procedure *) -module ProcnameSet = PrettyPrintable.MakePPSet(Procname) +module ProcnameSet = PrettyPrintable.MakePPSet(Typ.Procname) module Domain = AbstractDomain.FiniteSet(ProcnameSet) @@ -33,7 +33,7 @@ module SpecSummary = Summary.Make (struct end) type extras_t = { - get_proc_desc : Procname.t -> Procdesc.t option; + get_proc_desc : Typ.Procname.t -> Procdesc.t option; stacktraces : Stacktrace.t list; } @@ -59,12 +59,12 @@ let stacktree_of_pdesc file = SourceFile.to_string loc.Location.file; line = Some loc.Location.line; blame_range = [line_range_of_pdesc pdesc] } in - { Stacktree_j.method_name = Procname.to_unique_id procname; + { Stacktree_j.method_name = Typ.Procname.to_unique_id procname; location = frame_loc; callees = callees } let stacktree_stub_of_procname procname = - { Stacktree_j.method_name = Procname.to_unique_id procname; + { Stacktree_j.method_name = Typ.Procname.to_unique_id procname; location = None; callees = [] } @@ -96,7 +96,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let dir = Filename.concat Config.results_dir "crashcontext" in let suffix = F.sprintf "%s_%d" location_type loc.Location.line in let fname = F.sprintf "%s.%s.json" - (Procname.to_filename caller) + (Typ.Procname.to_filename caller) suffix in let fpath = Filename.concat dir fname in Utils.create_dir dir; @@ -109,18 +109,18 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let caller = Procdesc.get_proc_name proc_data.ProcData.pdesc in let matches_proc frame = let matches_class pname = match pname with - | Procname.Java java_proc -> + | Typ.Procname.Java java_proc -> String.equal frame.Stacktrace.class_str - (Procname.java_get_class_name java_proc) - | Procname.ObjC_Cpp objc_cpp_prod -> + (Typ.Procname.java_get_class_name java_proc) + | Typ.Procname.ObjC_Cpp objc_cpp_prod -> String.equal frame.Stacktrace.class_str - (Procname.objc_cpp_get_class_name objc_cpp_prod) - | Procname.C _ -> true (* Needed for test code. *) - | Procname.Block _ | Procname.Linters_dummy_method -> + (Typ.Procname.objc_cpp_get_class_name objc_cpp_prod) + | Typ.Procname.C _ -> true (* Needed for test code. *) + | Typ.Procname.Block _ | Typ.Procname.Linters_dummy_method -> failwith "Proc type not supported by crashcontext: block" in - String.equal frame.Stacktrace.method_str (Procname.get_method caller) && + String.equal frame.Stacktrace.method_str (Typ.Procname.get_method caller) && matches_class caller in let all_frames = List.concat (List.map ~f:(fun trace -> trace.Stacktrace.frames) traces) in diff --git a/infer/src/checkers/SimpleChecker.ml b/infer/src/checkers/SimpleChecker.ml index 8d984b3c9..b0f7e5461 100644 --- a/infer/src/checkers/SimpleChecker.ml +++ b/infer/src/checkers/SimpleChecker.ml @@ -25,12 +25,12 @@ module type Spec = sig input is the previous state, current instruction, current node kind, current procedure and type environment. *) - val exec_instr : astate -> Sil.instr -> Procdesc.Node.nodekind -> Procname.t -> Tenv.t -> astate + val exec_instr : astate -> Sil.instr -> Procdesc.Node.nodekind -> Typ.Procname.t -> Tenv.t -> astate (** log errors here. input is a state, location where the state occurs in the source, and the current procedure. *) - val report : astate -> Location.t -> Procname.t -> unit + val report : astate -> Location.t -> Typ.Procname.t -> unit val compare : astate -> astate -> int end diff --git a/infer/src/checkers/SimpleChecker.mli b/infer/src/checkers/SimpleChecker.mli index 660a04f13..7c1ad20e8 100644 --- a/infer/src/checkers/SimpleChecker.mli +++ b/infer/src/checkers/SimpleChecker.mli @@ -15,8 +15,8 @@ sig val initial : astate val exec_instr : astate -> - Sil.instr -> Procdesc.Node.nodekind -> Procname.t -> Tenv.t -> astate - val report : astate -> Location.t -> Procname.t -> unit + Sil.instr -> Procdesc.Node.nodekind -> Typ.Procname.t -> Tenv.t -> astate + val report : astate -> Location.t -> Typ.Procname.t -> unit val compare : astate -> astate -> int end diff --git a/infer/src/checkers/Sink.ml b/infer/src/checkers/Sink.ml index 39cf5606a..8b81dff90 100644 --- a/infer/src/checkers/Sink.ml +++ b/infer/src/checkers/Sink.ml @@ -16,7 +16,7 @@ module type Kind = sig include TraceElem.Kind (** return the parameter index and sink kind for the given call site with the given actuals *) - val get : Procname.t -> (Exp.t * Typ.t) list -> Tenv.t -> (t * int * bool) list + val get : Typ.Procname.t -> (Exp.t * Typ.t) list -> Tenv.t -> (t * int * bool) list end module type S = sig diff --git a/infer/src/checkers/Sink.mli b/infer/src/checkers/Sink.mli index acc866b6e..fc987e2ad 100644 --- a/infer/src/checkers/Sink.mli +++ b/infer/src/checkers/Sink.mli @@ -13,7 +13,7 @@ module type Kind = sig include TraceElem.Kind (** return the parameter index and sink kind for the given call site with the given actuals *) - val get : Procname.t -> (Exp.t * Typ.t) list -> Tenv.t -> (t * int * bool) list + val get : Typ.Procname.t -> (Exp.t * Typ.t) list -> Tenv.t -> (t * int * bool) list end module type S = sig diff --git a/infer/src/checkers/SinkTrace.ml b/infer/src/checkers/SinkTrace.ml index 909f0a645..53cccc555 100644 --- a/infer/src/checkers/SinkTrace.ml +++ b/infer/src/checkers/SinkTrace.ml @@ -20,7 +20,7 @@ module type S = sig type sink_path = Passthroughs.t * (Sink.t * Passthroughs.t) list (** get a path for each of the reportable flows to a sink in this trace *) - val get_reportable_sink_paths : t -> trace_of_pname:(Procname.t -> t) -> sink_path list + val get_reportable_sink_paths : t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path list (** update sink with the given call site *) val with_callsite : t -> CallSite.t -> t diff --git a/infer/src/checkers/SinkTrace.mli b/infer/src/checkers/SinkTrace.mli index daf37fc4c..31e500793 100644 --- a/infer/src/checkers/SinkTrace.mli +++ b/infer/src/checkers/SinkTrace.mli @@ -18,7 +18,7 @@ module type S = sig type sink_path = Passthrough.Set.t * (Sink.t * Passthrough.Set.t) list (** get a path for each of the reportable flows to a sink in this trace *) - val get_reportable_sink_paths : t -> trace_of_pname:(Procname.t -> t) -> sink_path list + val get_reportable_sink_paths : t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path list (** update sink with the given call site *) val with_callsite : t -> CallSite.t -> t diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 7c23935a8..25d15b5d6 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -16,8 +16,8 @@ module GlobalsAccesses = SiofTrace.GlobalsAccesses let methods_whitelist = QualifiedCppName.quals_matcher_of_fuzzy_qual_names Config.siof_safe_methods -let is_whitelisted (pname : Procname.t) = - Procname.get_qualifiers pname +let is_whitelisted (pname : Typ.Procname.t) = + Typ.Procname.get_qualifiers pname |> QualifiedCppName.match_qualifiers methods_whitelist type siof_model = { @@ -42,7 +42,7 @@ let is_modelled = List.map models ~f:(fun {qual_name} -> qual_name) |> QualifiedCppName.quals_matcher_of_fuzzy_qual_names in fun pname -> - Procname.get_qualifiers pname + Typ.Procname.get_qualifiers pname |> QualifiedCppName.match_qualifiers models_matcher module Summary = Summary.Make (struct @@ -129,15 +129,15 @@ module TransferFunctions (CFG : ProcCfg.S) = struct ~f:(fun {qual_name; initialized_globals} -> if QualifiedCppName.quals_matcher_of_fuzzy_qual_names [qual_name] |> Fn.flip QualifiedCppName.match_qualifiers - (Procname.get_qualifiers callee_pname) then + (Typ.Procname.get_qualifiers callee_pname) then Some initialized_globals else None) in Domain.join astate (Domain.BottomSiofTrace.NonBottom SiofTrace.empty, Domain.VarNames.of_list init) | Call (_, Const (Cfun callee_pname), _::params_without_self, loc, _) - when Procname.is_c_method callee_pname && Procname.is_constructor callee_pname - && Procname.is_constexpr callee_pname -> + when Typ.Procname.is_c_method callee_pname && Typ.Procname.is_constructor callee_pname + && Typ.Procname.is_constexpr callee_pname -> add_params_globals astate pdesc loc params_without_self | Call (_, Const (Cfun callee_pname), params, loc, _) -> let callsite = CallSite.make callee_pname loc in @@ -250,7 +250,7 @@ let checker ({ Callbacks.proc_desc; } as callback) = ~make_extras:ProcData.make_empty_extras callback in let pname = Procdesc.get_proc_name proc_desc in - match Procname.get_global_name_of_initializer pname with + match Typ.Procname.get_global_name_of_initializer pname with | Some gname -> siof_check proc_desc gname post | None -> diff --git a/infer/src/checkers/SiofTrace.ml b/infer/src/checkers/SiofTrace.ml index 74253728e..5d5d3d5b4 100644 --- a/infer/src/checkers/SiofTrace.ml +++ b/infer/src/checkers/SiofTrace.ml @@ -62,7 +62,7 @@ end include SinkTrace.Make(TraceElem) let make_access kind loc = - let site = CallSite.make Procname.empty_block loc in + let site = CallSite.make Typ.Procname.empty_block loc in { TraceElem.kind = (`Access, kind); site; } let is_intraprocedural_access { TraceElem.kind=(kind, _); } = kind = `Access @@ -73,7 +73,7 @@ let trace_of_error loc gname path = if is_intraprocedural_access sink then Format.asprintf "%a" Sink.pp sink else - Format.asprintf "call to %a" Procname.pp (CallSite.pname callsite) in + Format.asprintf "call to %a" Typ.Procname.pp (CallSite.pname callsite) in let sink_should_nest sink = not (is_intraprocedural_access sink) in let trace_elem_of_global = Errlog.make_trace_element 0 loc diff --git a/infer/src/checkers/Source.ml b/infer/src/checkers/Source.ml index 4225d7cfb..41cb4e563 100644 --- a/infer/src/checkers/Source.ml +++ b/infer/src/checkers/Source.ml @@ -21,7 +21,7 @@ module type Kind = sig val unknown : t - val get : Procname.t -> Tenv.t -> t option + val get : Typ.Procname.t -> Tenv.t -> t option val get_tainted_formals : Procdesc.t -> Tenv.t -> (Mangled.t * Typ.t * t option) list end diff --git a/infer/src/checkers/Source.mli b/infer/src/checkers/Source.mli index df75342b4..5b9c4d6a7 100644 --- a/infer/src/checkers/Source.mli +++ b/infer/src/checkers/Source.mli @@ -19,7 +19,7 @@ module type Kind = sig val unknown : t (** return Some (kind) if the procedure is a taint source, None otherwise *) - val get : Procname.t -> Tenv.t -> t option + val get : Typ.Procname.t -> Tenv.t -> t option (** return each formal of the function paired with either Some(kind) if the formal is a taint source, or None if the formal is not a taint source *) diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 9141db7c8..948193309 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -52,9 +52,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | NoEffect let get_lock_model = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with | "java.util.concurrent.locks.Lock", "lock" -> Lock | ("java.util.concurrent.locks.ReentrantLock" @@ -71,9 +71,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | _ -> NoEffect end - | pname when Procname.equal pname BuiltinDecl.__set_locked_attribute -> + | pname when Typ.Procname.equal pname BuiltinDecl.__set_locked_attribute -> Lock - | pname when Procname.equal pname BuiltinDecl.__delete_locked_attribute -> + | pname when Typ.Procname.equal pname BuiltinDecl.__delete_locked_attribute -> Unlock | _ -> NoEffect @@ -211,10 +211,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_annotated_functional = has_return_annot Annotations.ia_is_functional in let is_modeled_functional = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, - Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, + Typ.Procname.java_get_method java_pname with | "android.content.res.Resources", method_name -> (* all methods of Resources are considered @Functional except for the ones in this blacklist *) @@ -236,13 +236,13 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let acquires_ownership pname tenv = let is_allocation pn = - Procname.equal pn BuiltinDecl.__new || Procname.equal pn BuiltinDecl.__new_array in + Typ.Procname.equal pn BuiltinDecl.__new || Typ.Procname.equal pn BuiltinDecl.__new_array in (* identify library functions that maintain ownership invariants behind the scenes *) let is_owned_in_library = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, - Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, + Typ.Procname.java_get_method java_pname with | "javax.inject.Provider", "get" -> (* in dependency injection, the library allocates fresh values behind the scenes *) true @@ -263,10 +263,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let exec_instr (astate : Domain.astate) { ProcData.pdesc; tenv; extras; } _ = let is_container_write pn tenv = match pn with - | Procname.Java java_pname -> - let typename = Typename.Java.from_string (Procname.java_get_class_name java_pname) in + | Typ.Procname.Java java_pname -> + let typename = Typename.Java.from_string (Typ.Procname.java_get_class_name java_pname) in let is_container_write_ typename _ = - match Typename.name typename, Procname.java_get_method java_pname with + match Typename.name typename, Typ.Procname.java_get_method java_pname with | "java.util.List", ("add" | "addAll" | "clear" | "remove" | "set") -> true | "java.util.Map", ("clear" | "put" | "putAll" | "remove") -> true | _ -> false in @@ -286,7 +286,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let dummy_fieldname = Ident.create_fieldname (Mangled.from_string - (container_write_string ^ (Procname.get_method callee_pname))) 0 in + (container_write_string ^ (Typ.Procname.get_method callee_pname))) 0 in let dummy_access_exp = Exp.Lfield (receiver_exp, dummy_fieldname, receiver_typ) in let callee_writes = match AccessPath.of_lhs_exp dummy_access_exp receiver_typ ~f_resolve_id with @@ -301,7 +301,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | _ -> failwithf "Call to %a is marked as a container write, but has no receiver" - Procname.pp callee_pname in + Typ.Procname.pp callee_pname in let get_summary caller_pdesc callee_pname actuals ~f_resolve_id callee_loc tenv = if is_container_write callee_pname tenv then @@ -312,9 +312,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct not is_locked && not (Procdesc.is_java_synchronized pdesc) in (* return true if the given procname boxes a primitive type into a reference type *) let is_box = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with | ("java.lang.Boolean" | "java.lang.Byte" | "java.lang.Char" | @@ -348,7 +348,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | Sil.Call (Some (ret_id, _), Const (Cfun callee_pname), (target_exp, target_typ) :: (Exp.Sizeof (cast_typ, _, _), _) :: _ , _, _) - when Procname.equal callee_pname BuiltinDecl.__cast -> + when Typ.Procname.equal callee_pname BuiltinDecl.__cast -> let lhs_access_path = AccessPath.of_id ret_id (Typ.Tptr (cast_typ, Pk_pointer)) in let attribute_map = propagate_attributes @@ -618,11 +618,11 @@ module Analyzer = AbstractInterpreter.Make (ProcCfg.Normal) (TransferFunctions) module Interprocedural = AbstractInterpreter.Interprocedural (Summary) (* a results table is a Map where a key is an a procedure environment, - i.e., something of type Idenv.t * Tenv.t * Procname.t * Procdesc.t + i.e., something of type Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t *) module ResultsTableType = Caml.Map.Make (struct - type t = Idenv.t * Tenv.t * Procname.t * Procdesc.t - let compare (_, _, pn1, _) (_,_,pn2,_) = Procname.compare pn1 pn2 + type t = Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t + let compare (_, _, pn1, _) (_,_,pn2,_) = Typ.Procname.compare pn1 pn2 end) (* we want to consider Builder classes and other safe immutablility-ensuring patterns as @@ -646,12 +646,12 @@ let is_immutable_collection_class class_name tenv = class_name let is_call_to_builder_class_method = function - | Procname.Java java_pname -> is_builder_class (Procname.java_get_class_name java_pname) + | Typ.Procname.Java java_pname -> is_builder_class (Typ.Procname.java_get_class_name java_pname) | _ -> false let is_call_to_immutable_collection_method tenv = function - | Procname.Java java_pname -> - is_immutable_collection_class (Procname.java_get_class_type_name java_pname) tenv + | Typ.Procname.Java java_pname -> + is_immutable_collection_class (Typ.Procname.java_get_class_type_name java_pname) tenv | _ -> false @@ -717,7 +717,7 @@ let pdesc_is_assumed_thread_safe pdesc tenv = find more bugs. this is just a temporary measure to avoid obvious false positives *) let should_analyze_proc pdesc tenv = let pn = Procdesc.get_proc_name pdesc in - not (Procname.is_class_initializer pn) && + not (Typ.Procname.is_class_initializer pn) && not (FbThreadSafety.is_logging_method pn) && not (is_call_to_builder_class_method pn) && not (is_call_to_immutable_collection_method tenv pn) && @@ -727,13 +727,13 @@ let should_analyze_proc pdesc tenv = (* return true if we should report on unprotected accesses during the procedure *) let should_report_on_proc (_, _, proc_name, proc_desc) = - not (Procname.java_is_autogen_method proc_name) && + not (Typ.Procname.java_is_autogen_method proc_name) && Procdesc.get_access proc_desc <> PredSymb.Private && not (Annotations.pdesc_return_annot_ends_with proc_desc Annotations.visibleForTesting) let analyze_procedure callback = let is_initializer tenv proc_name = - Procname.is_constructor proc_name || FbThreadSafety.is_custom_init tenv proc_name in + Typ.Procname.is_constructor proc_name || FbThreadSafety.is_custom_init tenv proc_name in let open ThreadSafetyDomain in let has_lock = false in let return_attrs = AttributeSetDomain.empty in @@ -807,8 +807,8 @@ let make_results_table get_proc_desc file_env = let get_current_class_and_threadsafe_superclasses tenv pname = match pname with - | Procname.Java java_pname -> - let current_class = Procname.java_get_class_type_name java_pname in + | Typ.Procname.Java java_pname -> + let current_class = Typ.Procname.java_get_class_type_name java_pname in let thread_safe_annotated_classes = PatternMatch.find_superclasses_with_attributes is_thread_safe tenv current_class @@ -950,7 +950,7 @@ let report_thread_safety_violations ( _, tenv, pname, pdesc) make_description tr Format.asprintf "access to %a" (pp_accesses_sink ~is_write_access:true) sink else Format.asprintf - "call to %a" Procname.pp (CallSite.pname (PathDomain.Sink.call_site sink)) in + "call to %a" Typ.Procname.pp (CallSite.pname (PathDomain.Sink.call_site sink)) in let loc = CallSite.loc (PathDomain.Sink.call_site initial_sink) in let ltr = PathDomain.to_sink_loc_trace ~desc_of_sink path in let msg = Localise.to_string Localise.thread_safety_violation in @@ -968,7 +968,7 @@ let make_unprotected_write_description tenv pname final_sink_site initial_sink_site final_sink _ = Format.asprintf "Unprotected write. Public method %a%s %s %a outside of synchronization.%s" - Procname.pp pname + Typ.Procname.pp pname (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (if is_container_write_sink final_sink then "mutates" else "writes to field") (pp_accesses_sink ~is_write_access:true) final_sink @@ -983,13 +983,13 @@ let make_read_write_race_description tenv pname final_sink_site initial_sink_sit conflicting_proc_envs in let pp_proc_name_list fmt proc_names = let pp_sep _ _ = F.fprintf fmt " , " in - F.pp_print_list ~pp_sep Procname.pp fmt proc_names in + F.pp_print_list ~pp_sep Typ.Procname.pp fmt proc_names in let conflicts_description = Format.asprintf "Potentially races with writes in method%s %a." (if List.length conflicting_proc_names > 1 then "s" else "") pp_proc_name_list conflicting_proc_names in Format.asprintf "Read/Write race. Public method %a%s reads from field %a. %s %s" - Procname.pp pname + Typ.Procname.pp pname (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (pp_accesses_sink ~is_write_access:false) final_sink conflicts_description diff --git a/infer/src/checkers/ThreadSafetyDomain.ml b/infer/src/checkers/ThreadSafetyDomain.ml index 852143a50..fa777b3fd 100644 --- a/infer/src/checkers/ThreadSafetyDomain.ml +++ b/infer/src/checkers/ThreadSafetyDomain.ml @@ -40,7 +40,7 @@ module TraceElem = struct end let make_access kind loc = - let site = CallSite.make Procname.empty_block loc in + let site = CallSite.make Typ.Procname.empty_block loc in TraceElem.make kind site module LocksDomain = AbstractDomain.BooleanAnd diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index a20e6ae2b..f7908eaf5 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -53,7 +53,7 @@ module type S = sig (** get a path for each of the reportable source -> sink flows in this trace. specifying [cur_site] restricts the reported paths to ones introduced by the call at [cur_site] *) val get_reportable_paths : - ?cur_site:CallSite.t -> t -> trace_of_pname:(Procname.t -> t) -> path list + ?cur_site:CallSite.t -> t -> trace_of_pname:(Typ.Procname.t -> t) -> path list (** create a loc_trace from a path; [source_should_nest s] should be true when we are going one deeper into a call-chain, ie when lt_level should be bumper in the next loc_trace_elem, and @@ -87,7 +87,7 @@ module type S = sig val pp : F.formatter -> t -> unit (** pretty-print a path in the context of the given procname *) - val pp_path : Procname.t -> F.formatter -> path -> unit + val pp_path : Typ.Procname.t -> F.formatter -> path -> unit end (** Expand a trace element (i.e., a source or sink) into a list of trace elements bottoming out in @@ -216,7 +216,7 @@ module Make (Spec : Spec) = struct Source.pp original_source Sink.pp final_sink pp_sources sources_passthroughs - Procname.pp cur_pname + Typ.Procname.pp cur_pname pp_passthroughs cur_passthroughs pp_sinks (List.rev sinks_passthroughs) @@ -269,18 +269,18 @@ module Make (Spec : Spec) = struct let to_loc_trace ?(desc_of_source=fun source -> let callsite = Source.call_site source in - Format.asprintf "return from %a" Procname.pp (CallSite.pname callsite)) + Format.asprintf "return from %a" Typ.Procname.pp (CallSite.pname callsite)) ?(source_should_nest=(fun _ -> true)) ?(desc_of_sink=fun sink -> let callsite = Sink.call_site sink in - Format.asprintf "call to %a" Procname.pp (CallSite.pname callsite)) + Format.asprintf "call to %a" Typ.Procname.pp (CallSite.pname callsite)) ?(sink_should_nest=(fun _ -> true)) (passthroughs, sources, sinks) = let trace_elems_of_passthroughs lt_level passthroughs acc0 = let trace_elem_of_passthrough passthrough acc = let passthrough_site = Passthrough.site passthrough in - let desc = F.asprintf "flow through %a" Procname.pp (CallSite.pname passthrough_site) in + let desc = F.asprintf "flow through %a" Typ.Procname.pp (CallSite.pname passthrough_site) in (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 = diff --git a/infer/src/checkers/Trace.mli b/infer/src/checkers/Trace.mli index dd2e3f5ed..5cc8d40ec 100644 --- a/infer/src/checkers/Trace.mli +++ b/infer/src/checkers/Trace.mli @@ -54,7 +54,7 @@ module type S = sig (** get a path for each of the reportable source -> sink flows in this trace. specifying [cur_site] restricts the reported paths to ones introduced by the call at [cur_site] *) val get_reportable_paths : - ?cur_site:CallSite.t -> t -> trace_of_pname:(Procname.t -> t) -> path list + ?cur_site:CallSite.t -> t -> trace_of_pname:(Typ.Procname.t -> t) -> path list (** create a loc_trace from a path; [source_should_nest s] should be true when we are going one deeper into a call-chain, ie when lt_level should be bumper in the next loc_trace_elem, and @@ -89,7 +89,7 @@ module type S = sig val pp : F.formatter -> t -> unit (** pretty-print a path in the context of the given procname *) - val pp_path : Procname.t -> F.formatter -> path -> unit + val pp_path : Typ.Procname.t -> F.formatter -> path -> unit end module Make (Spec : Spec) : S with module Source = Spec.Source and module Sink = Spec.Sink diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index a1dbeace7..0b3f459d9 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -113,10 +113,10 @@ let expensive_overrides_unexpensive = let annotation_reachability_error = "CHECKERS_ANNOTATION_REACHABILITY_ERROR" let is_modeled_expensive tenv = function - | Procname.Java proc_name_java as proc_name -> + | Typ.Procname.Java proc_name_java as proc_name -> not (BuiltinDecl.is_declared proc_name) && let is_subclass = - let classname = Typename.Java.from_string (Procname.java_get_class_name proc_name_java) in + let classname = Typename.Java.from_string (Typ.Procname.java_get_class_name proc_name_java) in PatternMatch.is_subtype_of_str tenv classname in Inferconfig.modeled_expensive_matcher is_subclass proc_name | _ -> @@ -124,12 +124,12 @@ let is_modeled_expensive tenv = function let is_allocator tenv pname = match pname with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> let is_throwable () = let class_name = - Typename.Java.from_string (Procname.java_get_class_name pname_java) in + Typename.Java.from_string (Typ.Procname.java_get_class_name pname_java) in PatternMatch.is_throwable tenv class_name in - Procname.is_constructor pname + Typ.Procname.is_constructor pname && not (BuiltinDecl.is_declared pname) && not (is_throwable ()) | _ -> @@ -171,7 +171,7 @@ let update_trace loc trace = Errlog.make_trace_element 0 loc "" [] :: trace let string_of_pname = - Procname.to_simplified_string ~withclass:true + Typ.Procname.to_simplified_string ~withclass:true let report_allocation_stack src_annot pname fst_call_loc trace stack_str constructor_pname call_loc = @@ -180,7 +180,7 @@ let report_allocation_stack let description = Printf.sprintf "Method `%s` annotated with `@%s` allocates `%s` via `%s%s`" - (Procname.to_simplified_string pname) + (Typ.Procname.to_simplified_string pname) src_annot constr_str stack_str @@ -198,7 +198,7 @@ let report_annotation_stack src_annot snk_annot src_pname loc trace stack_str sn let description = Printf.sprintf "Method `%s` annotated with `@%s` calls `%s%s` where `%s` is annotated with `@%s`" - (Procname.to_simplified_string src_pname) + (Typ.Procname.to_simplified_string src_pname) src_annot stack_str exp_pname_str @@ -232,8 +232,8 @@ let report_call_stack end_of_stack lookup_next_calls report call_site calls = ~f:(fun (accu, set) call_site -> let p = CallSite.pname call_site in let loc = CallSite.loc call_site in - if Procname.Set.mem p set then (accu, set) - else ((p, loc) :: accu, Procname.Set.add p set)) + if Typ.Procname.Set.mem p set then (accu, set) + else ((p, loc) :: accu, Typ.Procname.Set.add p set)) ~init:([], visited_pnames) next_calls in List.iter ~f:(loop fst_call_loc updated_visited (new_trace, new_stack_str)) unseen_pnames in @@ -242,7 +242,7 @@ let report_call_stack end_of_stack lookup_next_calls report call_site calls = let fst_callee_pname = CallSite.pname fst_call_site in let fst_call_loc = CallSite.loc fst_call_site in let start_trace = update_trace (CallSite.loc call_site) [] in - loop fst_call_loc Procname.Set.empty (start_trace, "") (fst_callee_pname, fst_call_loc)) + loop fst_call_loc Typ.Procname.Set.empty (start_trace, "") (fst_callee_pname, fst_call_loc)) calls module TransferFunctions (CFG : ProcCfg.S) = struct @@ -255,8 +255,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct rarely to not affect the performances *) let is_unlikely pname = match pname with - | Procname.Java java_pname -> - String.equal (Procname.java_get_method java_pname) "unlikely" + | Typ.Procname.Java java_pname -> + String.equal (Typ.Procname.java_get_method java_pname) "unlikely" | _ -> false let is_tracking_exp astate = function @@ -356,8 +356,8 @@ module Interprocedural = struct let description = Printf.sprintf "Method `%s` overrides unannotated method `%s` and cannot be annotated with `@%s`" - (Procname.to_string proc_name) - (Procname.to_string overridden_pname) + (Typ.Procname.to_string proc_name) + (Typ.Procname.to_string overridden_pname) Annotations.expensive in let exn = Exceptions.Checkers diff --git a/infer/src/checkers/annotations.mli b/infer/src/checkers/annotations.mli index cc9d84603..74024bf52 100644 --- a/infer/src/checkers/annotations.mli +++ b/infer/src/checkers/annotations.mli @@ -95,8 +95,8 @@ val pdesc_has_return_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool value. the function [attrs_of_pname] should resolve the proc attributes of [pname]. Specs.proc_resolve_attributes is a good choice for this resolution function. *) val pname_has_return_annot : - Procname.t -> - attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> + Typ.Procname.t -> + attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> (Annot.Item.t -> bool) -> bool diff --git a/infer/src/checkers/checkDeadCode.ml b/infer/src/checkers/checkDeadCode.ml index 256559c93..61c59fd96 100644 --- a/infer/src/checkers/checkDeadCode.ml +++ b/infer/src/checkers/checkDeadCode.ml @@ -103,7 +103,7 @@ let callback_check_dead_code { Callbacks.proc_desc; proc_name; tenv } = let do_check () = begin - if verbose then L.stderr "@.--@.PROC: %a@." Procname.pp proc_name; + if verbose then L.stderr "@.--@.PROC: %a@." Typ.Procname.pp proc_name; let transitions = DFDead.run tenv proc_desc State.initial in let exit_node = Procdesc.get_exit_node proc_desc in match transitions exit_node with diff --git a/infer/src/checkers/checkTraceCallSequence.ml b/infer/src/checkers/checkTraceCallSequence.ml index 134d8b92d..1af7161ac 100644 --- a/infer/src/checkers/checkTraceCallSequence.ml +++ b/infer/src/checkers/checkTraceCallSequence.ml @@ -46,14 +46,14 @@ let report_warning tenv description pn pd loc = module APIs = struct let method_match pn pkgname cname mname = match pn with - | Procname.Java pn_java -> - String.equal (Procname.java_get_method pn_java) mname + | Typ.Procname.Java pn_java -> + String.equal (Typ.Procname.java_get_method pn_java) mname && (match pkgname with | "" -> - String.equal (Procname.java_get_simple_class_name pn_java) cname + String.equal (Typ.Procname.java_get_simple_class_name pn_java) cname | _ -> - String.equal (Procname.java_get_class_name pn_java) (pkgname ^ "." ^ cname)) + String.equal (Typ.Procname.java_get_class_name pn_java) (pkgname ^ "." ^ cname)) | _ -> false let is_begin pn = @@ -184,10 +184,10 @@ module Automaton = struct (** Transfer function for a procedure call. *) let do_call tenv caller_pn caller_pd callee_pn (s : State.t) loc : State.t = let method_name () = match callee_pn with - | Procname.Java pname_java -> - Procname.java_get_method pname_java + | Typ.Procname.Java pname_java -> + Typ.Procname.java_get_method pname_java | _ -> - Procname.to_simplified_string callee_pn in + Typ.Procname.to_simplified_string callee_pn in if APIs.is_begin callee_pn then begin if verbose then L.stderr " calling %s@." (method_name ()); @@ -332,7 +332,7 @@ let callback_check_trace_call_sequence { Callbacks.proc_desc; proc_name; idenv; let do_check () = begin - if verbose then L.stderr "@.--@.PROC: %a@." Procname.pp proc_name; + if verbose then L.stderr "@.--@.PROC: %a@." Typ.Procname.pp proc_name; let transitions = DFTrace.run tenv proc_desc State.balanced in let exit_node = Procdesc.get_exit_node proc_desc in match transitions exit_node with diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index 6471c9245..7aed81831 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -39,10 +39,10 @@ module ST = struct let summary = Specs.get_summary_unsafe "ST.pname_add" proc_name in add summary key value - let files_open = ref Procname.Set.empty + let files_open = ref Typ.Procname.Set.empty let pname_find proc_name key = - if Procname.Set.mem proc_name !files_open then + if Typ.Procname.Set.mem proc_name !files_open then let summary = Specs.get_summary_unsafe "ST.pname_find" proc_name in ProcAttributes.proc_flags_find summary.Specs.attributes.ProcAttributes.proc_flags key else begin @@ -50,7 +50,7 @@ module ST = struct | None -> raise Not_found | Some summary -> begin - files_open := Procname.Set.add proc_name !files_open; + files_open := Typ.Procname.Set.add proc_name !files_open; ProcAttributes.proc_flags_find summary.Specs.attributes.ProcAttributes.proc_flags key end end @@ -136,7 +136,7 @@ module ST = struct L.stdout "%s: %a: %s@." kind SourceFile.pp loc.Location.file - (Procname.to_string proc_name); + (Typ.Procname.to_string proc_name); L.stdout "%s@." description end; Reporting.log_error proc_name ~loc ~ltr:trace exn @@ -145,7 +145,7 @@ end let report_calls_and_accesses tenv callback proc_desc instr = let proc_name = Procdesc.get_proc_name proc_desc in - let callee = Procname.to_string proc_name in + let callee = Typ.Procname.to_string proc_name in match PatternMatch.get_java_field_access_signature instr with | Some (bt, fn, ft) -> ST.report_error tenv @@ -191,7 +191,7 @@ let callback_check_write_to_parcel_java let is_write_to_parcel this_expr this_type = let method_match () = - String.equal (Procname.java_get_method pname_java) "writeToParcel" in + String.equal (Typ.Procname.java_get_method pname_java) "writeToParcel" in let expr_match () = Exp.is_this this_expr in let type_match () = let class_name = Typename.Java.from_string "android.os.Parcelable" in @@ -202,7 +202,7 @@ let callback_check_write_to_parcel_java method_match () && expr_match () && type_match () in let is_parcel_constructor proc_name = - Procname.is_constructor proc_name && + Typ.Procname.is_constructor proc_name && PatternMatch.has_formal_method_argument_type_names proc_desc pname_java ["android.os.Parcel"] in @@ -220,9 +220,9 @@ let callback_check_write_to_parcel_java let is_serialization_node node = match Procdesc.Node.get_callees node with | [] -> false - | [Procname.Java pname_java] -> - let class_name = Procname.java_get_class_name pname_java in - let method_name = Procname.java_get_method pname_java in + | [Typ.Procname.Java pname_java] -> + let class_name = Typ.Procname.java_get_class_name pname_java in + let method_name = Typ.Procname.java_get_method pname_java in (try String.equal class_name "android.os.Parcel" && (String.equal (String.sub method_name ~pos:0 ~len:5) "write" @@ -232,9 +232,9 @@ let callback_check_write_to_parcel_java | _ -> assert false in let is_inverse rc_ wc_ = match rc_, wc_ with - | Procname.Java rc, Procname.Java wc -> - let rn = Procname.java_get_method rc in - let wn = Procname.java_get_method wc in + | Typ.Procname.Java rc, Typ.Procname.Java wc -> + let rn = Typ.Procname.java_get_method rc in + let wn = Typ.Procname.java_get_method wc in let postfix_length = String.length wn - 5 in (* covers writeList <-> readArrayList etc. *) (try String.equal @@ -262,17 +262,17 @@ let callback_check_write_to_parcel_java | rc:: rcs, wc:: wcs -> if not (is_inverse rc wc) then L.stdout "Serialization missmatch in %a for %a and %a@." - Procname.pp args.Callbacks.proc_name - Procname.pp rc - Procname.pp wc + Typ.Procname.pp args.Callbacks.proc_name + Typ.Procname.pp rc + Typ.Procname.pp wc else check_match (rcs, wcs) | rc:: _, [] -> L.stdout "Missing write in %a: for %a@." - Procname.pp args.Callbacks.proc_name Procname.pp rc + Typ.Procname.pp args.Callbacks.proc_name Typ.Procname.pp rc | _, wc:: _ -> L.stdout "Missing read in %a: for %a@." - Procname.pp args.Callbacks.proc_name Procname.pp wc + Typ.Procname.pp args.Callbacks.proc_name Typ.Procname.pp wc | _ -> () in @@ -284,7 +284,7 @@ let callback_check_write_to_parcel_java if is_write_to_parcel this_exp this_type then begin if !verbose then L.stdout "Serialization check for %a@." - Procname.pp args.Callbacks.proc_name; + Typ.Procname.pp args.Callbacks.proc_name; try match parcel_constructors tenv this_type with | x :: _ -> @@ -293,7 +293,7 @@ let callback_check_write_to_parcel_java | None -> raise Not_found) | _ -> L.stdout "No parcel constructor found for %a@." - Procname.pp args.Callbacks.proc_name + Typ.Procname.pp args.Callbacks.proc_name with Not_found -> if !verbose then L.stdout "Methods not available@." end @@ -303,7 +303,7 @@ let callback_check_write_to_parcel_java (** Looks for writeToParcel methods and checks whether read is in reverse *) let callback_check_write_to_parcel ({ Callbacks.proc_name } as args) = match proc_name with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> callback_check_write_to_parcel_java pname_java args | _ -> () @@ -334,7 +334,7 @@ let callback_monitor_nullcheck { Callbacks.proc_desc; idenv; proc_name } = List.exists ~f:(equal_formal_param exp) (Lazy.force class_formal_names) in let is_nullcheck pn = match pn with - | Procname.Java pn_java -> + | Typ.Procname.Java pn_java -> PatternMatch.java_proc_name_with_class_method pn_java "com.google.common.base.Preconditions" "checkNotNull" | _ -> @@ -376,10 +376,10 @@ let callback_monitor_nullcheck { Callbacks.proc_desc; idenv; proc_name } = if is_formal_param arg1 then handle_check_of_formal arg1; if !verbose then (match proc_name with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> L.stdout "call in %s %s: %a with first arg: %a@." - (Procname.java_get_class_name pname_java) - (Procname.java_get_method pname_java) + (Typ.Procname.java_get_class_name pname_java) + (Typ.Procname.java_get_method pname_java) (Sil.pp_instr Pp.text) instr Exp.pp arg1 | _ -> @@ -432,7 +432,7 @@ let callback_find_deserialization { Callbacks.proc_desc; get_proc_desc; idenv; p | _ -> false in (match reverse_find_instr is_return_instr (Procdesc.get_exit_node proc_desc') with | Some (Sil.Store (_, _, Exp.Const (Const.Cclass n), _)) -> Ident.name_to_string n - | _ -> "<" ^ (Procname.to_string proc_name') ^ ">") + | _ -> "<" ^ (Typ.Procname.to_string proc_name') ^ ">") | None -> "?" in let get_actual_arguments node instr = match instr with @@ -544,12 +544,12 @@ let callback_check_field_access { Callbacks.proc_desc } = let callback_print_c_method_calls { Callbacks.tenv; proc_desc; proc_name } = let do_instr node = function | Sil.Call (_, Exp.Const (Const.Cfun pn), (e, _):: _, loc, _) - when Procname.is_c_method pn -> + when Typ.Procname.is_c_method pn -> let receiver = match Errdesc.exp_rv_dexp tenv node e with | Some de -> DecompiledExp.to_string de | None -> "?" in let description = - Printf.sprintf "['%s' %s]" receiver (Procname.to_string pn) in + Printf.sprintf "['%s' %s]" receiver (Typ.Procname.to_string pn) in ST.report_error tenv proc_name proc_desc @@ -558,7 +558,7 @@ let callback_print_c_method_calls { Callbacks.tenv; proc_desc; proc_name } = description | Sil.Call (_, Exp.Const (Const.Cfun pn), _, loc, _) -> let description = - Printf.sprintf "call to %s" (Procname.to_string pn) in + Printf.sprintf "call to %s" (Typ.Procname.to_string pn) in ST.report_error tenv proc_name proc_desc diff --git a/infer/src/checkers/checkers.mli b/infer/src/checkers/checkers.mli index a540e7aa2..e9fa6329f 100644 --- a/infer/src/checkers/checkers.mli +++ b/infer/src/checkers/checkers.mli @@ -15,15 +15,15 @@ open! IStd (** State that persists in the .specs files. *) module ST : sig (** Add a key/value pair. *) - val pname_add : Procname.t -> string -> string -> unit + val pname_add : Typ.Procname.t -> string -> string -> unit (** Find the value associated to the key. Raise Not_found if it does not exist. *) - val pname_find: Procname.t -> string -> string + val pname_find: Typ.Procname.t -> string -> string (** Report an error. *) val report_error: Tenv.t -> - Procname.t -> + Typ.Procname.t -> Procdesc.t -> string -> Location.t -> diff --git a/infer/src/checkers/constantPropagation.ml b/infer/src/checkers/constantPropagation.ml index 957e0f9ab..36fa30f8e 100644 --- a/infer/src/checkers/constantPropagation.ml +++ b/infer/src/checkers/constantPropagation.ml @@ -55,13 +55,13 @@ module ConstantFlow = Dataflow.MakeDF(struct (ConstantMap.add key value ConstantMap.empty) in let has_class pn name = match pn with - | Procname.Java pn_java -> - String.equal (Procname.java_get_class_name pn_java) name + | Typ.Procname.Java pn_java -> + String.equal (Typ.Procname.java_get_class_name pn_java) name | _ -> false in let has_method pn name = match pn with - | Procname.Java pn_java -> - String.equal (Procname.java_get_method pn_java) name + | Typ.Procname.Java pn_java -> + String.equal (Typ.Procname.java_get_method pn_java) name | _ -> false in diff --git a/infer/src/checkers/dataflow.ml b/infer/src/checkers/dataflow.ml index dd9dd08ad..87a8a3b7e 100644 --- a/infer/src/checkers/dataflow.ml +++ b/infer/src/checkers/dataflow.ml @@ -31,7 +31,7 @@ module type DFStateType = sig val do_node : Tenv.t -> Procdesc.Node.t -> t -> (t list) * (t list) (** Can proc throw an exception? *) - val proc_throws : Procname.t -> throws + val proc_throws : Typ.Procname.t -> throws end (** Type for the dataflow API. *) @@ -47,7 +47,7 @@ module type DF = sig end (** Determine if the node can throw an exception. *) -let node_throws pdesc node (proc_throws : Procname.t -> throws) : throws = +let node_throws pdesc node (proc_throws : Typ.Procname.t -> throws) : throws = let instr_throws instr = let is_return pvar = let ret_pvar = Procdesc.get_ret_var pdesc in @@ -58,7 +58,7 @@ let node_throws pdesc node (proc_throws : Procname.t -> throws) : throws = Throws | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) when BuiltinDecl.is_declared callee_pn -> - if Procname.equal callee_pn BuiltinDecl.__cast + if Typ.Procname.equal callee_pn BuiltinDecl.__cast then DontKnow else DoesNotThrow | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) -> diff --git a/infer/src/checkers/dataflow.mli b/infer/src/checkers/dataflow.mli index a7539071a..941bd55d2 100644 --- a/infer/src/checkers/dataflow.mli +++ b/infer/src/checkers/dataflow.mli @@ -29,7 +29,7 @@ module type DFStateType = sig val do_node : Tenv.t -> Procdesc.Node.t -> t -> (t list) * (t list) (** Can proc throw an exception? *) - val proc_throws : Procname.t -> throws + val proc_throws : Typ.Procname.t -> throws end (** Type for the dataflow API. *) diff --git a/infer/src/checkers/fragmentRetainsViewChecker.ml b/infer/src/checkers/fragmentRetainsViewChecker.ml index f0d7e2736..48218e95b 100644 --- a/infer/src/checkers/fragmentRetainsViewChecker.ml +++ b/infer/src/checkers/fragmentRetainsViewChecker.ml @@ -24,7 +24,7 @@ let callback_fragment_retains_view_java pname_java { Callbacks.proc_desc; tenv } = (* TODO: complain if onDestroyView is not defined, yet the Fragment has View fields *) (* TODO: handle fields nullified in callees in the same file *) - let is_on_destroy_view = String.equal (Procname.java_get_method pname_java) "onDestroyView" in + let is_on_destroy_view = String.equal (Typ.Procname.java_get_method pname_java) "onDestroyView" in let fld_typ_is_view = function | Typ.Tptr (Tstruct tname, _) -> AndroidFramework.is_view tenv tname | _ -> false in @@ -35,7 +35,7 @@ let callback_fragment_retains_view_java if is_on_destroy_view then begin let class_typename = - Typename.Java.from_string (Procname.java_get_class_name pname_java) in + Typename.Java.from_string (Typ.Procname.java_get_class_name pname_java) in match Tenv.lookup tenv class_typename with | Some { fields } when AndroidFramework.is_fragment tenv class_typename -> let declared_view_fields = @@ -44,16 +44,16 @@ let callback_fragment_retains_view_java (* report if a field is declared by C, but not nulled out in C.onDestroyView *) List.iter ~f:(fun (fname, fld_typ, _) -> - if not (Ident.FieldSet.mem fname fields_nullified) then - report_error - (Tstruct class_typename) fname fld_typ (Procname.Java pname_java) proc_desc) + if not (Ident.FieldSet.mem fname fields_nullified) then + report_error + (Tstruct class_typename) fname fld_typ (Typ.Procname.Java pname_java) proc_desc) declared_view_fields | _ -> () end let callback_fragment_retains_view ({ Callbacks.proc_name } as args) = match proc_name with - | Procname.Java pname_java -> + | Typ.Procname.Java pname_java -> callback_fragment_retains_view_java pname_java args | _ -> () diff --git a/infer/src/checkers/immutableChecker.ml b/infer/src/checkers/immutableChecker.ml index 90e07a16d..85379328e 100644 --- a/infer/src/checkers/immutableChecker.ml +++ b/infer/src/checkers/immutableChecker.ml @@ -37,7 +37,7 @@ let check_immutable_cast tenv curr_pname curr_pdesc typ_expected typ_found_opt l Format.asprintf "Method %s returns %a but the return type is %a. \ Make sure that users of this method do not try to modify the collection." - (Procname.to_simplified_string curr_pname) + (Typ.Procname.to_simplified_string curr_pname) Typename.pp name_given Typename.pp name_expected in Checkers.ST.report_error tenv diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index 0d09e1863..72035f7f1 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -31,8 +31,8 @@ let type_is_object typ = let java_proc_name_with_class_method pn_java class_with_path method_name = (try - String.equal (Procname.java_get_class_name pn_java) class_with_path && - String.equal (Procname.java_get_method pn_java) method_name + String.equal (Typ.Procname.java_get_class_name pn_java) class_with_path && + String.equal (Typ.Procname.java_get_method pn_java) method_name with _ -> false) (** Holds iff the predicate holds on a supertype of the named type, including the type itself *) @@ -161,7 +161,7 @@ let get_vararg_type_names tenv | Sil.Call (Some (t1, _), Exp.Const (Const.Cfun pn), _, _, _):: Sil.Store (Exp.Lvar iv, _, Exp.Var t2, _):: is -> (Pvar.equal ivar iv && Ident.equal t1 t2 && - Procname.equal pn (Procname.from_string_c_fun "__new_array")) + Typ.Procname.equal pn (Typ.Procname.from_string_c_fun "__new_array")) || initializes_array is | _:: is -> initializes_array is | _ -> false in @@ -215,13 +215,13 @@ let has_formal_proc_argument_type_names proc_desc argument_type_names = let has_formal_method_argument_type_names cfg pname_java argument_type_names = has_formal_proc_argument_type_names - cfg ((Procname.java_get_class_name pname_java):: argument_type_names) + cfg ((Typ.Procname.java_get_class_name pname_java):: argument_type_names) let is_getter pname_java = - Str.string_match (Str.regexp "get*") (Procname.java_get_method pname_java) 0 + Str.string_match (Str.regexp "get*") (Typ.Procname.java_get_method pname_java) 0 let is_setter pname_java = - Str.string_match (Str.regexp "set*") (Procname.java_get_method pname_java) 0 + Str.string_match (Str.regexp "set*") (Typ.Procname.java_get_method pname_java) 0 (** Returns the signature of a field access (class name, field name, field type name) *) let get_java_field_access_signature = function @@ -234,10 +234,10 @@ let get_java_field_access_signature = function let get_java_method_call_formal_signature = function | Sil.Call (_, Exp.Const (Const.Cfun pn), (_, tt):: args, _, _) -> (match pn with - | Procname.Java pn_java -> + | Typ.Procname.Java pn_java -> let arg_names = List.map ~f:(function | _, t -> get_type_name t) args in - let rt_name = Procname.java_get_return_type pn_java in - let m_name = Procname.java_get_method pn_java in + let rt_name = Typ.Procname.java_get_return_type pn_java in + let m_name = Typ.Procname.java_get_method pn_java in Some (get_type_name tt, m_name, arg_names, rt_name) | _ -> None) @@ -285,8 +285,8 @@ let method_is_initializer | Some this_type -> if type_has_initializer tenv this_type then match proc_attributes.ProcAttributes.proc_name with - | Procname.Java pname_java -> - let mname = Procname.java_get_method pname_java in + | Typ.Procname.Java pname_java -> + let mname = Typ.Procname.java_get_method pname_java in List.exists ~f:(String.equal mname) initializer_methods | _ -> false @@ -311,7 +311,7 @@ let java_get_vararg_values node pvar idenv = | None -> () in !values -let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t) list = +let proc_calls resolve_attributes pdesc filter : (Typ.Procname.t * ProcAttributes.t) list = let res = ref [] in let do_instruction _ instr = match instr with | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) -> @@ -333,11 +333,11 @@ let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t) let override_exists f tenv proc_name = let rec super_type_exists tenv super_class_name = let super_proc_name = - Procname.replace_class proc_name super_class_name in + Typ.Procname.replace_class proc_name super_class_name in match Tenv.lookup tenv super_class_name with | Some ({ methods; supers; }) -> let is_override pname = - Procname.equal pname super_proc_name && not (Procname.is_constructor pname) in + Typ.Procname.equal pname super_proc_name && not (Typ.Procname.is_constructor pname) in List.exists ~f:(fun pname -> is_override pname && f pname) methods || List.exists ~f:(super_type_exists tenv) supers | _ -> @@ -345,8 +345,8 @@ let override_exists f tenv proc_name = f proc_name || match proc_name with - | Procname.Java proc_name_java -> - let type_name = Typename.Java.from_string (Procname.java_get_class_name proc_name_java) in + | Typ.Procname.Java proc_name_java -> + let type_name = Typename.Java.from_string (Typ.Procname.java_get_class_name proc_name_java) in List.exists ~f:(super_type_exists tenv) (type_get_direct_supertypes tenv (Typ.Tstruct type_name)) @@ -386,18 +386,18 @@ let is_throwable tenv typename = (** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, including for supertypes*) let check_class_attributes check tenv = function - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> let check_class_annots _ { Typ.Struct.annots; } = check annots in supertype_exists tenv check_class_annots - (Procname.java_get_class_type_name java_pname) + (Typ.Procname.java_get_class_type_name java_pname) | _ -> false (** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, for the current class only*) let check_current_class_attributes check tenv = function - | Procname.Java java_pname -> - (match Tenv.lookup tenv (Procname.java_get_class_type_name java_pname) with + | Typ.Procname.Java java_pname -> + (match Tenv.lookup tenv (Typ.Procname.java_get_class_type_name java_pname) with | Some (struct_typ) -> check struct_typ.annots | _ -> false ) diff --git a/infer/src/checkers/patternMatch.mli b/infer/src/checkers/patternMatch.mli index db2197670..b92f37ff4 100644 --- a/infer/src/checkers/patternMatch.mli +++ b/infer/src/checkers/patternMatch.mli @@ -39,16 +39,16 @@ val get_type_name : Typ.t -> string val get_vararg_type_names : Tenv.t -> Procdesc.Node.t -> Pvar.t -> string list val has_formal_method_argument_type_names : - Procdesc.t -> Procname.java -> string list -> bool + Procdesc.t -> Typ.Procname.java -> string list -> bool (** Check if the method is one of the known initializer methods. *) val method_is_initializer : Tenv.t -> ProcAttributes.t -> bool (** Is this a getter proc name? *) -val is_getter : Procname.java -> bool +val is_getter : Typ.Procname.java -> bool (** Is this a setter proc name? *) -val is_setter : Procname.java -> bool +val is_setter : Typ.Procname.java -> bool (** Is the type a direct subtype of the typename? *) val is_immediate_subtype : Tenv.t -> Typename.t -> Typename.t -> bool @@ -73,22 +73,22 @@ val java_get_const_type_name : Const.t -> string (** Get the values of a vararg parameter given the pvar used to assign the elements. *) val java_get_vararg_values : Procdesc.Node.t -> Pvar.t -> Idenv.t -> Exp.t list -val java_proc_name_with_class_method : Procname.java -> string -> string -> bool +val java_proc_name_with_class_method : Typ.Procname.java -> string -> string -> bool (** Return the callees that satisfy [filter]. *) val proc_calls : - (Procname.t -> ProcAttributes.t option) -> + (Typ.Procname.t -> ProcAttributes.t option) -> Procdesc.t -> - (Procname.t -> ProcAttributes.t -> bool) -> - (Procname.t * ProcAttributes.t) list + (Typ.Procname.t -> ProcAttributes.t -> bool) -> + (Typ.Procname.t * ProcAttributes.t) list (** Return true if applying the given predicate to an override of [procname] or [procname] itself returns true. For the moment, this only works for Java *) -val override_exists : (Procname.t -> bool) -> Tenv.t -> Procname.t -> bool +val override_exists : (Typ.Procname.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool (** Apply the given predicate to procname and each override of [procname]. For the moment, this only works for Java *) -val override_iter : (Procname.t -> unit) -> Tenv.t -> Procname.t -> unit +val override_iter : (Typ.Procname.t -> unit) -> Tenv.t -> Typ.Procname.t -> unit val type_get_annotation : Tenv.t -> Typ.t -> Annot.Item.t option @@ -122,11 +122,11 @@ val is_runtime_exception : Tenv.t -> Typename.t -> bool (** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, including supertypes*) -val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> bool +val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool (** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, for current class only*) -val check_current_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> bool +val check_current_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool (** find superclasss with attributes (e.g., @ThreadSafe), including current class*) val find_superclasses_with_attributes : (Annot.Item.t -> bool) -> Tenv.t diff --git a/infer/src/checkers/printfArgs.ml b/infer/src/checkers/printfArgs.ml index fd4cb8fa7..435aef857 100644 --- a/infer/src/checkers/printfArgs.ml +++ b/infer/src/checkers/printfArgs.ml @@ -45,9 +45,9 @@ let add_printf_like_function plf = let printf_like_function - (proc_name: Procname.t): printf_signature option = + (proc_name: Typ.Procname.t): printf_signature option = List.find - ~f:(fun printf -> String.equal printf.unique_id (Procname.to_unique_id proc_name)) + ~f:(fun printf -> String.equal printf.unique_id (Typ.Procname.to_unique_id proc_name)) !printf_like_functions let default_format_type_name @@ -114,12 +114,12 @@ let printf_args_name = "CHECKERS_PRINTF_ARGS" let check_printf_args_ok tenv (node: Procdesc.Node.t) (instr: Sil.instr) - (proc_name: Procname.t) + (proc_name: Typ.Procname.t) (proc_desc: Procdesc.t): unit = (* Check if format string lines up with arguments *) let rec check_type_names instr_loc n_arg instr_proc_name fmt_type_names arg_type_names = - let instr_name = Procname.to_simplified_string instr_proc_name in + let instr_name = Typ.Procname.to_simplified_string instr_proc_name in let instr_line = Location.to_string instr_loc in match (fmt_type_names, arg_type_names) with | ft:: fs, gt:: gs -> @@ -203,7 +203,7 @@ let check_printf_args_ok tenv L.stderr "%s Exception when analyzing %s: %s@." printf_args_name - (Procname.to_string proc_name) + (Typ.Procname.to_string proc_name) (Exn.to_string e)) | None -> ()) | _ -> () diff --git a/infer/src/checkers/printfArgs.mli b/infer/src/checkers/printfArgs.mli index cb7052262..e332dbcb2 100644 --- a/infer/src/checkers/printfArgs.mli +++ b/infer/src/checkers/printfArgs.mli @@ -20,6 +20,6 @@ type printf_signature = { val add_printf_like_function : printf_signature -> unit val check_printf_args_ok : - Tenv.t -> Procdesc.Node.t -> Sil.instr -> Procname.t -> Procdesc.t -> unit + Tenv.t -> Procdesc.Node.t -> Sil.instr -> Typ.Procname.t -> Procdesc.t -> unit val callback_printf_args: Callbacks.proc_callback_t diff --git a/infer/src/checkers/repeatedCallsChecker.ml b/infer/src/checkers/repeatedCallsChecker.ml index 3cbd34d17..16b02478a 100644 --- a/infer/src/checkers/repeatedCallsChecker.ml +++ b/infer/src/checkers/repeatedCallsChecker.ml @@ -68,8 +68,8 @@ struct let node_allocates node : Location.t option = let found = ref None in let proc_is_new pn = - Procname.equal pn BuiltinDecl.__new || - Procname.equal pn BuiltinDecl.__new_array in + Typ.Procname.equal pn BuiltinDecl.__new || + Typ.Procname.equal pn BuiltinDecl.__new_array in let do_instr instr = match instr with | Sil.Call (_, Exp.Const (Const.Cfun pn), _, loc, _) when proc_is_new pn -> @@ -133,7 +133,7 @@ struct | Some alloc_loc -> let description = Format.asprintf "call to %s seen before on line %d (may allocate at %a:%d)" - (Procname.to_simplified_string callee_pname) + (Typ.Procname.to_simplified_string callee_pname) loc_old.Location.line SourceFile.pp alloc_loc.Location.file alloc_loc.Location.line in diff --git a/infer/src/checkers/sqlChecker.ml b/infer/src/checkers/sqlChecker.ml index 86ec89011..e96c58492 100644 --- a/infer/src/checkers/sqlChecker.ml +++ b/infer/src/checkers/sqlChecker.ml @@ -29,8 +29,8 @@ let callback_sql { Callbacks.proc_desc; proc_name; tenv } = (* Check for SQL string concatenations *) let do_instr const_map node instr = let do_call pn_java i1 i2 l = - if String.equal (Procname.java_get_class_name pn_java) "java.lang.StringBuilder" - && String.equal (Procname.java_get_method pn_java) "append" + if String.equal (Typ.Procname.java_get_class_name pn_java) "java.lang.StringBuilder" + && String.equal (Typ.Procname.java_get_method pn_java) "append" then begin let rvar1 = Exp.Var i1 in @@ -56,7 +56,7 @@ let callback_sql { Callbacks.proc_desc; proc_name; tenv } = | Sil.Call (_, Exp.Const (Const.Cfun pn), (Exp.Var i1, _):: (Exp.Var i2, _):: [], l, _) -> begin match pn with - | Procname.Java pn_java -> + | Typ.Procname.Java pn_java -> do_call pn_java i1 i2 l | _ -> () @@ -65,6 +65,6 @@ let callback_sql { Callbacks.proc_desc; proc_name; tenv } = try let const_map = ConstantPropagation.build_const_map tenv proc_desc in - if verbose then L.stdout "Analyzing %a...\n@." Procname.pp proc_name; + if verbose then L.stdout "Analyzing %a...\n@." Typ.Procname.pp proc_name; Procdesc.iter_instrs (do_instr const_map) proc_desc with _ -> () diff --git a/infer/src/checkers/summary.ml b/infer/src/checkers/summary.ml index 304769a7e..e3a053d35 100644 --- a/infer/src/checkers/summary.ml +++ b/infer/src/checkers/summary.ml @@ -25,11 +25,11 @@ module type S = sig (* type astate*) (** Write the [summary] for the procname to persistent storage. *) - val write_summary : Procname.t -> summary -> unit + val write_summary : Typ.Procname.t -> summary -> unit (** read and return the summary for [callee_pname] called from [caller_pdesc]. does the analysis to create the summary if needed *) - val read_summary : Procdesc.t -> Procname.t -> summary option + val read_summary : Procdesc.t -> Typ.Procname.t -> summary option end module Make (H : Helper) = struct @@ -41,7 +41,7 @@ module Make (H : Helper) = struct let payload = H.update_payload summary global_summary.Specs.payload in Specs.store_summary { global_summary with payload; } | None -> - failwithf "Summary for %a should exist, but does not!@." Procname.pp pname + failwithf "Summary for %a should exist, but does not!@." Typ.Procname.pp pname let read_summary caller_pdesc callee_pname = ignore (Ondemand.analyze_proc_name ~propagate_exceptions:false caller_pdesc callee_pname); diff --git a/infer/src/checkers/summary.mli b/infer/src/checkers/summary.mli index 2a0a5ce04..3fb29361c 100644 --- a/infer/src/checkers/summary.mli +++ b/infer/src/checkers/summary.mli @@ -22,11 +22,11 @@ module type S = sig (** Write the [summary] for the procname to persistent storage. Returns the summary actually written. *) - val write_summary : Procname.t -> summary -> unit + val write_summary : Typ.Procname.t -> summary -> unit (** read and return the summary for [callee_pname] called from [caller_pdesc]. does the analysis to create the summary if needed *) - val read_summary : Procdesc.t -> Procname.t -> summary option + val read_summary : Procdesc.t -> Typ.Procname.t -> summary option end diff --git a/infer/src/clang/CProcname.ml b/infer/src/clang/CProcname.ml index a8f797571..a96beb2e0 100644 --- a/infer/src/clang/CProcname.ml +++ b/infer/src/clang/CProcname.ml @@ -47,26 +47,26 @@ let mk_c_function translation_unit_context name function_decl_info_opt = | _ -> "" in let mangled = (Utils.string_crc_hex32 file) ^ mangled_name in if String.is_empty file && String.is_empty mangled_name then - Procname.from_string_c_fun name + Typ.Procname.from_string_c_fun name else - Procname.C (Procname.c name mangled) + Typ.Procname.C (Typ.Procname.c name mangled) let mk_cpp_method class_name method_name ?meth_decl mangled = let method_kind = match meth_decl with | Some (Clang_ast_t.CXXConstructorDecl (_, _, _, _, {xmdi_is_constexpr})) -> - Procname.CPPConstructor (mangled, xmdi_is_constexpr) + Typ.Procname.CPPConstructor (mangled, xmdi_is_constexpr) | _ -> - Procname.CPPMethod mangled in - Procname.ObjC_Cpp - (Procname.objc_cpp class_name method_name method_kind) + Typ.Procname.CPPMethod mangled in + Typ.Procname.ObjC_Cpp + (Typ.Procname.objc_cpp class_name method_name method_kind) let mk_objc_method class_typename method_name method_kind = - Procname.ObjC_Cpp - (Procname.objc_cpp class_typename method_name method_kind) + Typ.Procname.ObjC_Cpp + (Typ.Procname.objc_cpp class_typename method_name method_kind) let block_procname_with_index defining_proc i = Config.anonymous_block_prefix ^ - (Procname.to_string defining_proc) ^ + (Typ.Procname.to_string defining_proc) ^ Config.anonymous_block_num_sep ^ (string_of_int i) @@ -86,7 +86,7 @@ let get_fresh_block_index () = let mk_fresh_block_procname defining_proc = let name = block_procname_with_index defining_proc (get_fresh_block_index ()) in - Procname.mangled_objc_block name + Typ.Procname.mangled_objc_block name let get_class_typename method_decl_info = @@ -126,10 +126,10 @@ let from_decl translation_unit_context meth_decl = let class_typename = get_class_typename decl_info in let method_name = name_info.Clang_ast_t.ni_name in let is_instance = mdi.Clang_ast_t.omdi_is_instance_method in - let method_kind = Procname.objc_method_kind_of_bool is_instance in + let method_kind = Typ.Procname.objc_method_kind_of_bool is_instance in mk_objc_method class_typename method_name method_kind | BlockDecl _ -> let name = Config.anonymous_block_prefix ^ Config.anonymous_block_num_sep ^ (string_of_int (get_fresh_block_index ())) in - Procname.mangled_objc_block name + Typ.Procname.mangled_objc_block name | _ -> assert false diff --git a/infer/src/clang/CProcname.mli b/infer/src/clang/CProcname.mli index eba3d7d9c..b7c48a04c 100644 --- a/infer/src/clang/CProcname.mli +++ b/infer/src/clang/CProcname.mli @@ -11,26 +11,26 @@ open! IStd (** Given decl, return its procname. This function should be used for all procedures present in original AST *) -val from_decl : CFrontend_config.translation_unit_context -> Clang_ast_t.decl -> Procname.t +val from_decl : CFrontend_config.translation_unit_context -> Clang_ast_t.decl -> Typ.Procname.t (** WARNING: functions from this module should not be used if full decl is available in AST *) module NoAstDecl : sig - val c_function_of_string : CFrontend_config.translation_unit_context -> string -> Procname.t + val c_function_of_string : CFrontend_config.translation_unit_context -> string -> Typ.Procname.t - val cpp_method_of_string : Typename.t -> string -> Procname.t + val cpp_method_of_string : Typename.t -> string -> Typ.Procname.t - val objc_method_of_string_kind : Typename.t -> string -> Procname.objc_cpp_method_kind -> - Procname.t + val objc_method_of_string_kind : Typename.t -> string -> Typ.Procname.objc_cpp_method_kind -> + Typ.Procname.t end (** Makes a fresh name for a block defined inside the defining procedure. It updates the global block_counter *) -val mk_fresh_block_procname : Procname.t -> Procname.t +val mk_fresh_block_procname : Typ.Procname.t -> Typ.Procname.t (** Returns the next fresh name for a block defined inside the defining procedure It does not update the global block_counter *) -val get_next_block_pvar : Procname.t -> Pvar.t +val get_next_block_pvar : Typ.Procname.t -> Pvar.t val reset_block_counter : unit -> unit diff --git a/infer/src/clang/ast_expressions.ml b/infer/src/clang/ast_expressions.ml index e319837df..c400ed2e0 100644 --- a/infer/src/clang/ast_expressions.ml +++ b/infer/src/clang/ast_expressions.ml @@ -628,6 +628,6 @@ let create_assume_not_null_call decl_info var_name var_type = let bin_op_expr_info = make_general_expr_info create_BOOL_type `RValue `Ordinary in let bin_op = make_binary_stmt decl_ref_exp_cast null_expr stmt_info bin_op_expr_info boi in let parameters = [bin_op] in - let procname = Procname.to_string BuiltinDecl.__infer_assume in + let procname = Typ.Procname.to_string BuiltinDecl.__infer_assume in let qual_procname = CAst_utils.make_name_decl procname in create_call stmt_info var_decl_ptr qual_procname create_void_star_type parameters diff --git a/infer/src/clang/cContext.ml b/infer/src/clang/cContext.ml index 6a71e1b77..7b70770b2 100644 --- a/infer/src/clang/cContext.ml +++ b/infer/src/clang/cContext.ml @@ -38,7 +38,7 @@ type t = return_param_typ : Typ.t option; outer_context : t option; (** in case of objc blocks, the context of the method containing the block *) - mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t; + mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Typ.Procname.Map.t; label_map : str_node_map; } @@ -46,7 +46,7 @@ let create_context translation_unit_context tenv cg cfg procdesc curr_class retu is_objc_method outer_context = { translation_unit_context; tenv; cg; cfg; procdesc; curr_class; return_param_typ; is_objc_method; outer_context; - blocks_static_vars = Procname.Map.empty; + blocks_static_vars = Typ.Procname.Map.empty; label_map = Hashtbl.create 17; } @@ -118,7 +118,7 @@ let add_block_static_var context block_name static_var_typ = | Some outer_context, (static_var, _) when Pvar.is_global static_var -> (let new_static_vars, duplicate = try - let static_vars = Procname.Map.find block_name outer_context.blocks_static_vars in + let static_vars = Typ.Procname.Map.find block_name outer_context.blocks_static_vars in if List.mem ~equal:( fun (var1, _) (var2, _) -> Pvar.equal var1 var2 ) static_vars static_var_typ then @@ -128,12 +128,12 @@ let add_block_static_var context block_name static_var_typ = with Not_found -> [static_var_typ], false in if not duplicate then let blocks_static_vars = - Procname.Map.add block_name new_static_vars outer_context.blocks_static_vars in + Typ.Procname.Map.add block_name new_static_vars outer_context.blocks_static_vars in outer_context.blocks_static_vars <- blocks_static_vars) | _ -> () let static_vars_for_block context block_name = - try Procname.Map.find block_name context.blocks_static_vars + try Typ.Procname.Map.find block_name context.blocks_static_vars with Not_found -> [] let rec get_outer_procname context = diff --git a/infer/src/clang/cContext.mli b/infer/src/clang/cContext.mli index da156989d..5e4e7c3d9 100644 --- a/infer/src/clang/cContext.mli +++ b/infer/src/clang/cContext.mli @@ -33,7 +33,7 @@ type t = return_param_typ : Typ.t option; outer_context : t option; (** in case of objc blocks, the context of the method containing the block *) - mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t; + mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Typ.Procname.Map.t; label_map : str_node_map; } @@ -60,10 +60,10 @@ val get_tenv : t -> Tenv.t val create_context : CFrontend_config.translation_unit_context -> Tenv.t -> Cg.t -> Cfg.cfg -> Procdesc.t -> curr_class -> Typ.t option -> bool -> t option -> t -val add_block_static_var : t -> Procname.t -> (Pvar.t * Typ.t) -> unit +val add_block_static_var : t -> Typ.Procname.t -> (Pvar.t * Typ.t) -> unit -val static_vars_for_block : t -> Procname.t -> (Pvar.t * Typ.t) list +val static_vars_for_block : t -> Typ.Procname.t -> (Pvar.t * Typ.t) list val is_objc_instance : t -> bool -val get_outer_procname : t -> Procname.t +val get_outer_procname : t -> Typ.Procname.t diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index f32e47375..2ed6328c8 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -26,7 +26,7 @@ struct CMethod_trans.create_external_procdesc cfg procname is_objc_method None in Logging.out_debug - "@\n@\n>>---------- ADDING METHOD: '%s' ---------<<@\n@." (Procname.to_string procname); + "@\n@\n>>---------- ADDING METHOD: '%s' ---------<<@\n@." (Typ.Procname.to_string procname); try (match Cfg.find_proc_desc_from_name cfg procname with | Some procdesc -> @@ -38,7 +38,7 @@ struct let exit_node = Procdesc.get_exit_node procdesc in Logging.out_debug "\n\n>>---------- Start translating body of function: '%s' ---------<<\n@." - (Procname.to_string procname); + (Typ.Procname.to_string procname); let meth_body_nodes = T.instructions_trans context body extra_instrs exit_node in let proc_attributes = Procdesc.get_attributes procdesc in Procdesc.Node.add_locals_ret_declaration diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index ee8767acb..17904674c 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -179,7 +179,7 @@ let expand_checkers checkers = let get_err_log translation_unit_context method_decl_opt = let procname = match method_decl_opt with | Some method_decl -> CProcname.from_decl translation_unit_context method_decl - | None -> Procname.Linters_dummy_method in + | None -> Typ.Procname.Linters_dummy_method in LintIssues.get_err_log procname (* Add a frontend warning with a description desc at location loc to the errlog of a proc desc *) diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index f6871fa34..cda00b399 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -162,7 +162,7 @@ let mk_sil_var trans_unit_ctx named_decl_info decl_info_type_ptr_opt procname ou let mk_name = if var_decl_info.Clang_ast_t.vdi_is_static_local then Some (fun name_string _ -> - Mangled.from_string ((Procname.to_string outer_procname) ^ "_" ^ name_string)) + Mangled.from_string ((Typ.Procname.to_string outer_procname) ^ "_" ^ name_string)) else None in mk_sil_global_var trans_unit_ctx ?mk_name named_decl_info var_decl_info qt else if not should_be_mangled then Pvar.mk simple_name procname diff --git a/infer/src/clang/cGeneral_utils.mli b/infer/src/clang/cGeneral_utils.mli index c4b8431a8..0852f9c1f 100644 --- a/infer/src/clang/cGeneral_utils.mli +++ b/infer/src/clang/cGeneral_utils.mli @@ -53,7 +53,7 @@ val mk_sil_global_var : CFrontend_config.translation_unit_context -> Clang_ast_t.named_decl_info -> Clang_ast_t.var_decl_info -> Clang_ast_t.qual_type -> Pvar.t val mk_sil_var : CFrontend_config.translation_unit_context -> Clang_ast_t.named_decl_info -> - var_info option -> Procname.t -> Procname.t -> Pvar.t + var_info option -> Typ.Procname.t -> Typ.Procname.t -> Pvar.t (** true if the current language is C++ or ObjC++ *) val is_cpp_translation : CFrontend_config.translation_unit_context -> bool diff --git a/infer/src/clang/cMethod_signature.ml b/infer/src/clang/cMethod_signature.ml index defeb273c..380d4b366 100644 --- a/infer/src/clang/cMethod_signature.ml +++ b/infer/src/clang/cMethod_signature.ml @@ -13,7 +13,7 @@ open! IStd (** return type, location and whether its an instance method. *) type method_signature = { - mutable name : Procname.t; + mutable name : Typ.Procname.t; args : (Mangled.t * Clang_ast_t.qual_type) list; ret_type : Clang_ast_t.type_ptr; attributes : Clang_ast_t.attribute list; @@ -97,7 +97,7 @@ let replace_name_ms ms name = { ms with name } let ms_to_string ms = - "Method " ^ (Procname.to_string ms.name) ^ " " ^ + "Method " ^ (Typ.Procname.to_string ms.name) ^ " " ^ IList.to_string (fun (s1, s2) -> (Mangled.to_string s1) ^ ", " ^ (CAst_utils.string_of_qual_type s2)) ms.args diff --git a/infer/src/clang/cMethod_signature.mli b/infer/src/clang/cMethod_signature.mli index c0f5e879a..f1bbc49d6 100644 --- a/infer/src/clang/cMethod_signature.mli +++ b/infer/src/clang/cMethod_signature.mli @@ -14,9 +14,9 @@ open! IStd type method_signature -val ms_get_name : method_signature -> Procname.t +val ms_get_name : method_signature -> Typ.Procname.t -val ms_set_name : method_signature -> Procname.t -> unit +val ms_set_name : method_signature -> Typ.Procname.t -> unit val ms_get_args : method_signature -> (Mangled.t * Clang_ast_t.qual_type) list @@ -43,11 +43,11 @@ val ms_is_getter : method_signature -> bool val ms_is_setter : method_signature -> bool -val make_ms : Procname.t -> (Mangled.t * Clang_ast_t.qual_type) list -> Clang_ast_t.type_ptr +val make_ms : Typ.Procname.t -> (Mangled.t * Clang_ast_t.qual_type) list -> Clang_ast_t.type_ptr -> Clang_ast_t.attribute list -> Clang_ast_t.source_range -> bool -> ?is_cpp_virtual:bool -> CFrontend_config.clang_lang -> Clang_ast_t.pointer option -> Clang_ast_t.pointer option -> Typ.t option -> method_signature -val replace_name_ms : method_signature -> Procname.t -> method_signature +val replace_name_ms : method_signature -> Typ.Procname.t -> method_signature val ms_to_string : method_signature -> string diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index a225f9189..24e401530 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -219,7 +219,7 @@ let get_method_name_from_clang tenv ms_opt = match ObjcCategory_decl.get_base_class_name_from_category decl with | Some class_typename -> let procname = CMethod_signature.ms_get_name ms in - let new_procname = Procname.replace_class procname class_typename in + let new_procname = Typ.Procname.replace_class procname class_typename in CMethod_signature.ms_set_name ms new_procname; Some ms | None -> Some ms) @@ -261,8 +261,8 @@ let get_class_name_method_call_from_clang trans_unit_ctx tenv obj_c_message_expr | Some ms -> begin match CMethod_signature.ms_get_name ms with - | Procname.ObjC_Cpp objc_cpp -> - Some (Procname.objc_cpp_get_class_type_name objc_cpp) + | Typ.Procname.ObjC_Cpp objc_cpp -> + Some (Typ.Procname.objc_cpp_get_class_type_name objc_cpp) | _ -> None end @@ -391,7 +391,7 @@ let create_local_procdesc ?(set_objc_accessor_attr=false) trans_unit_ctx cfg ten fbody captured is_objc_inst_method = let defined = not (Int.equal (List.length fbody) 0) in let proc_name = CMethod_signature.ms_get_name ms in - let pname = Procname.to_string proc_name in + let pname = Typ.Procname.to_string proc_name in let attributes = sil_func_attributes_of_attributes (CMethod_signature.ms_get_attributes ms) in let method_ret_type = CMethod_signature.ms_get_ret_type ms in let method_annotation = @@ -487,7 +487,7 @@ let create_procdesc_with_pointer context pointer class_name_opt name = let add_default_method_for_class trans_unit_ctx class_name decl_info = let loc = CLocation.get_sil_location_from_range trans_unit_ctx decl_info.Clang_ast_t.di_source_range true in - let proc_name = Procname.get_default_objc_class_method class_name in + let proc_name = Typ.Procname.get_default_objc_class_method class_name in let attrs = { (ProcAttributes.default proc_name Config.Clang) with loc = loc; } in AttributesTable.store_attributes attrs diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index 8107c6e70..50fa6a6f2 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -30,7 +30,7 @@ val create_local_procdesc : ?set_objc_accessor_attr:bool -> CMethod_signature.method_signature -> Clang_ast_t.stmt list -> (Pvar.t * Typ.t) list -> bool -> bool -val create_external_procdesc : Cfg.cfg -> Procname.t -> bool -> (Typ.t * Typ.t list) option -> unit +val create_external_procdesc : Cfg.cfg -> Typ.Procname.t -> bool -> (Typ.t * Typ.t list) option -> unit val get_objc_method_data : Clang_ast_t.obj_c_message_expr_info -> (string * Clang_ast_t.pointer option * method_call_type) @@ -52,9 +52,9 @@ val get_method_name_from_clang : Tenv.t -> CMethod_signature.method_signature op CMethod_signature.method_signature option val create_procdesc_with_pointer : CContext.t -> Clang_ast_t.pointer -> Typename.t option -> - string -> Procname.t + string -> Typ.Procname.t val add_default_method_for_class : CFrontend_config.translation_unit_context -> Typename.t -> Clang_ast_t.decl_info -> unit -val get_procname_from_cpp_lambda : CContext.t -> Clang_ast_t.decl -> Procname.t +val get_procname_from_cpp_lambda : CContext.t -> Clang_ast_t.decl -> Typ.Procname.t diff --git a/infer/src/clang/cModule_type.ml b/infer/src/clang/cModule_type.ml index ff6efb6bb..20b63f892 100644 --- a/infer/src/clang/cModule_type.ml +++ b/infer/src/clang/cModule_type.ml @@ -9,7 +9,7 @@ open! IStd -type block_data = CContext.t * Clang_ast_t.type_ptr * Procname.t * (Pvar.t * Typ.t) list +type block_data = CContext.t * Clang_ast_t.type_ptr * Typ.Procname.t * (Pvar.t * Typ.t) list type instr_type = [ | `ClangStmt of Clang_ast_t.stmt diff --git a/infer/src/clang/cPredicates.ml b/infer/src/clang/cPredicates.ml index 9c388c492..b7e8db2ee 100644 --- a/infer/src/clang/cPredicates.ml +++ b/infer/src/clang/cPredicates.ml @@ -182,7 +182,7 @@ let is_objc_constructor context = let method_name = (match Clang_ast_proj.get_named_decl_tuple method_decl with | Some (_, mnd) -> mnd.Clang_ast_t.ni_name | _ -> "") in - Procname.is_objc_constructor method_name + Typ.Procname.is_objc_constructor method_name | _ -> false @@ -192,7 +192,7 @@ let is_objc_dealloc context = let method_name = (match Clang_ast_proj.get_named_decl_tuple method_decl with | Some (_, mnd) -> mnd.Clang_ast_t.ni_name | _ -> "") in - Procname.is_objc_dealloc method_name + Typ.Procname.is_objc_dealloc method_name | _ -> false let captures_cxx_references an = diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 20200d3c3..aa7d6c01b 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -29,7 +29,7 @@ struct let (selector, method_pointer_opt, mc_type) = CMethod_trans.get_objc_method_data obj_c_message_expr_info in let is_instance = mc_type <> CMethod_trans.MCStatic in - let method_kind = Procname.objc_method_kind_of_bool is_instance in + let method_kind = Typ.Procname.objc_method_kind_of_bool is_instance in let ms_opt = match method_pointer_opt with | Some pointer -> @@ -45,8 +45,8 @@ struct obj_c_message_expr_info act_params in CProcname.NoAstDecl.objc_method_of_string_kind class_name selector method_kind in let predefined_ms_opt = match proc_name with - | Procname.ObjC_Cpp objc_cpp -> - let class_name = Procname.objc_cpp_get_class_type_name objc_cpp in + | Typ.Procname.ObjC_Cpp objc_cpp -> + let class_name = Typ.Procname.objc_cpp_get_class_type_name objc_cpp in CTrans_models.get_predefined_model_method_signature class_name selector CProcname.NoAstDecl.objc_method_of_string_kind CFrontend_config.ObjC | _ -> @@ -69,7 +69,7 @@ struct let add_autorelease_call context exp typ sil_loc = - let method_name = Procname.get_method (Procdesc.get_proc_name context.CContext.procdesc) in + let method_name = Typ.Procname.get_method (Procdesc.get_proc_name context.CContext.procdesc) in if !Config.arc_mode && not (CTrans_utils.is_owning_name method_name) && ObjcInterface_decl.is_pointer_to_objc_class typ then @@ -147,7 +147,7 @@ struct let extract_block_from_tuple procname exps loc = let insts = ref [] in let make_function_name typ bn = - let bn'= Procname.to_string bn in + let bn'= Typ.Procname.to_string bn in let bn''= Mangled.from_string bn' in let block = Exp.Lvar (Pvar.mk bn'' procname) in let id = Ident.create_fresh Ident.knormal in @@ -454,9 +454,9 @@ struct let function_attr_opt = Option.bind decl_opt get_deprecated_attr_arg in match function_attr_opt with | Some attr when CTrans_models.is_modeled_attribute attr -> - Some (Procname.from_string_c_fun attr) + Some (Typ.Procname.from_string_c_fun attr) | _ when CTrans_models.is_modeled_builtin name -> - Some (Procname.from_string_c_fun (CFrontend_config.infer ^ name)) + Some (Typ.Procname.from_string_c_fun (CFrontend_config.infer ^ name)) | _ when CTrans_models.is_release_builtin name type_ptr -> Some BuiltinDecl.__objc_release_cf | _ when CTrans_models.is_retain_builtin name type_ptr -> @@ -1996,7 +1996,7 @@ struct CType_decl.class_from_pointer_type trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in let dictionary_literal_pname = BuiltinDecl.__objc_dictionary_literal in - let dictionary_literal_s = Procname.get_method dictionary_literal_pname in + let dictionary_literal_s = Typ.Procname.get_method dictionary_literal_pname in let obj_c_message_expr_info = Ast_expressions.make_obj_c_message_expr_info_class dictionary_literal_s typ None in let stmts = CGeneral_utils.swap_elements_list stmts in @@ -2077,7 +2077,7 @@ struct let captured_vars = List.map2_exn ~f:(fun id (pvar, typ) -> (Exp.Var id, pvar, typ)) ids captureds in let closure = Exp.Closure { name=block_pname; captured_vars } in - let block_name = Procname.to_string block_pname in + let block_name = Typ.Procname.to_string block_pname in let static_vars = CContext.static_vars_for_block context block_pname in let captured_static_vars = captureds @ static_vars in let alloc_block_instr = @@ -2282,13 +2282,13 @@ struct { res_trans_to_parent with exps = res_trans_call.exps } and gccAsmStmt_trans trans_state = - let pname = Procname.from_string_c_fun CFrontend_config.infer_skip_gcc_asm_stmt in + let pname = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_gcc_asm_stmt in call_function_with_args "GCCAsmStmt" pname trans_state and objc_cxx_throw_trans trans_state = call_function_with_args "ObjCCPPThrow" BuiltinDecl.objc_cpp_throw trans_state and cxxPseudoDestructorExpr_trans () = - let fun_name = Procname.from_string_c_fun CFrontend_config.infer_skip_fun in + let fun_name = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_fun in { empty_res_trans with exps = [(Exp.Const (Const.Cfun fun_name), Typ.Tvoid)] } and cxxTypeidExpr_trans trans_state stmt_info stmts expr_info = @@ -2326,7 +2326,7 @@ struct let sil_loc = CLocation.get_sil_location stmt_info trans_state.context in let type_pointer = expr_info.Clang_ast_t.ei_type_ptr in let typ = CType_decl.type_ptr_to_sil_type tenv type_pointer in - let fun_name = Procname.from_string_c_fun CFrontend_config.infer_skip_fun in + let fun_name = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_fun in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_param = { trans_state_pri with succ_nodes = [] } in let res_trans_subexpr_list = List.map ~f:(instruction trans_state_param) stmts in diff --git a/infer/src/clang/cTrans_models.ml b/infer/src/clang/cTrans_models.ml index ceeef2ab7..3cd317549 100644 --- a/infer/src/clang/cTrans_models.ml +++ b/infer/src/clang/cTrans_models.ml @@ -14,35 +14,35 @@ open Objc_models let class_equal class_typename class_name = String.equal (Typename.name class_typename) class_name let is_cf_non_null_alloc pname = - String.equal (Procname.to_string pname) CFrontend_config.cf_non_null_alloc + String.equal (Typ.Procname.to_string pname) CFrontend_config.cf_non_null_alloc let is_alloc pname = - String.equal (Procname.to_string pname) CFrontend_config.cf_alloc + String.equal (Typ.Procname.to_string pname) CFrontend_config.cf_alloc let is_alloc_model typ pname = if Specs.summary_exists pname then false else - let funct = Procname.to_string pname in + let funct = Typ.Procname.to_string pname in (* if (Core_foundation_model.is_core_lib_create typ funct) then print_endline ("\nCore Foundation create not modelled " ^(Typ.to_string typ)^" "^(funct));*) Core_foundation_model.is_core_lib_create typ funct let is_builtin_expect pname = - String.equal (Procname.to_string pname) CFrontend_config.builtin_expect + String.equal (Typ.Procname.to_string pname) CFrontend_config.builtin_expect let is_builtin_object_size pname = - String.equal (Procname.to_string pname) CFrontend_config.builtin_object_size + String.equal (Typ.Procname.to_string pname) CFrontend_config.builtin_object_size let is_replace_with_deref_first_arg pname = - String.equal (Procname.to_string pname) CFrontend_config.replace_with_deref_first_arg_attr + String.equal (Typ.Procname.to_string pname) CFrontend_config.replace_with_deref_first_arg_attr let is_retain_predefined_model typ pname = - let funct = Procname.to_string pname in + let funct = Typ.Procname.to_string pname in Core_foundation_model.is_core_lib_retain typ funct let is_release_predefined_model typ pname = - let funct = Procname.to_string pname in + let funct = Typ.Procname.to_string pname in Core_foundation_model.is_core_lib_release typ funct || Core_foundation_model.is_core_graphics_release typ funct @@ -77,14 +77,14 @@ let get_first_param_typedef_string_opt type_ptr = | _ -> None let is_release_builtin funct fun_type = - let pn = Procname.from_string_c_fun funct in + let pn = Typ.Procname.from_string_c_fun funct in if Specs.summary_exists pn then false else match get_first_param_typedef_string_opt fun_type with | Some typ -> is_release_predefined_model typ pn | _ -> false let is_retain_builtin funct fun_type = - let pn = Procname.from_string_c_fun funct in + let pn = Typ.Procname.from_string_c_fun funct in if Specs.summary_exists pn then false else match get_first_param_typedef_string_opt fun_type with | Some typ -> is_retain_predefined_model typ pn @@ -109,22 +109,22 @@ let is_retain_or_release funct = is_autorelease_method funct let is_toll_free_bridging pn = - let funct = (Procname.to_string pn) in + let funct = (Typ.Procname.to_string pn) in String.equal funct CFrontend_config.cf_bridging_release || String.equal funct CFrontend_config.cf_bridging_retain || String.equal funct CFrontend_config.cf_autorelease || String.equal funct CFrontend_config.ns_make_collectable let is_cf_retain_release pn = - Procname.equal pn BuiltinDecl.__objc_retain_cf - || Procname.equal pn BuiltinDecl.__objc_release_cf + Typ.Procname.equal pn BuiltinDecl.__objc_retain_cf + || Typ.Procname.equal pn BuiltinDecl.__objc_release_cf (** If the function is a builtin model, return the model, otherwise return the function *) let is_assert_log pname = match pname with - | Procname.ObjC_Cpp _ -> - is_assert_log_method (Procname.to_string pname) - | Procname.C _ -> is_assert_log_s (Procname.to_string pname) + | Typ.Procname.ObjC_Cpp _ -> + is_assert_log_method (Typ.Procname.to_string pname) + | Typ.Procname.C _ -> is_assert_log_s (Typ.Procname.to_string pname) | _ -> false @@ -150,7 +150,7 @@ let get_predefined_ms_stringWithUTF8String class_name method_name mk_procname la let id_type = Ast_expressions.create_id_type in let args = [(Mangled.from_string "x", Ast_expressions.create_char_star_qual_type ~is_const:true)] in - get_predefined_ms_method condition class_name method_name Procname.ObjCClassMethod + get_predefined_ms_method condition class_name method_name Typ.Procname.ObjCClassMethod mk_procname lang args id_type [] None let get_predefined_ms_retain_release method_name mk_procname lang = @@ -161,7 +161,7 @@ let get_predefined_ms_retain_release method_name mk_procname lang = let class_typename = Typename.Objc.from_string CFrontend_config.nsobject_cl in let class_type = Ast_expressions.create_class_qual_type class_typename in let args = [(Mangled.from_string CFrontend_config.self, class_type)] in - get_predefined_ms_method condition class_typename method_name Procname.ObjCInstanceMethod + get_predefined_ms_method condition class_typename method_name Typ.Procname.ObjCInstanceMethod mk_procname lang args return_type [] (get_builtinname method_name) let get_predefined_ms_autoreleasepool_init class_name method_name mk_procname lang = @@ -169,7 +169,7 @@ let get_predefined_ms_autoreleasepool_init class_name method_name mk_procname la String.equal method_name CFrontend_config.init && class_equal class_name CFrontend_config.nsautorelease_pool_cl in let class_type = Ast_expressions.create_class_qual_type class_name in - get_predefined_ms_method condition class_name method_name Procname.ObjCInstanceMethod + get_predefined_ms_method condition class_name method_name Typ.Procname.ObjCInstanceMethod mk_procname lang [(Mangled.from_string CFrontend_config.self, class_type)] Ast_expressions.create_void_type [] None @@ -181,7 +181,7 @@ let get_predefined_ms_nsautoreleasepool_release class_name method_name mk_procna class_equal class_name CFrontend_config.nsautorelease_pool_cl in let class_type = Ast_expressions.create_class_qual_type class_name in let args = [(Mangled.from_string CFrontend_config.self, class_type)] in - get_predefined_ms_method condition class_name method_name Procname.ObjCInstanceMethod + get_predefined_ms_method condition class_name method_name Typ.Procname.ObjCInstanceMethod mk_procname lang args Ast_expressions.create_void_type [] (Some BuiltinDecl.__objc_release_autorelease_pool) @@ -189,7 +189,7 @@ let get_predefined_ms_is_kind_of_class class_name method_name mk_procname lang = let condition = String.equal method_name CFrontend_config.is_kind_of_class in let class_type = Ast_expressions.create_class_qual_type class_name in let args = [(Mangled.from_string CFrontend_config.self, class_type)] in - get_predefined_ms_method condition class_name method_name Procname.ObjCInstanceMethod + get_predefined_ms_method condition class_name method_name Typ.Procname.ObjCInstanceMethod mk_procname lang args Ast_expressions.create_BOOL_type [] (Some BuiltinDecl.__instanceof) diff --git a/infer/src/clang/cTrans_models.mli b/infer/src/clang/cTrans_models.mli index 4994718cf..f9ede4273 100644 --- a/infer/src/clang/cTrans_models.mli +++ b/infer/src/clang/cTrans_models.mli @@ -9,21 +9,21 @@ open! IStd -val is_cf_non_null_alloc : Procname.t -> bool +val is_cf_non_null_alloc : Typ.Procname.t -> bool -val is_alloc : Procname.t -> bool +val is_alloc : Typ.Procname.t -> bool -val is_alloc_model : Typ.t -> Procname.t -> bool +val is_alloc_model : Typ.t -> Typ.Procname.t -> bool -val is_builtin_expect : Procname.t -> bool +val is_builtin_expect : Typ.Procname.t -> bool -val is_builtin_object_size : Procname.t -> bool +val is_builtin_object_size : Typ.Procname.t -> bool -val is_replace_with_deref_first_arg : Procname.t -> bool +val is_replace_with_deref_first_arg : Typ.Procname.t -> bool val is_objc_memory_model_controlled : string -> bool -val is_assert_log : Procname.t -> bool +val is_assert_log : Typ.Procname.t -> bool val is_handleFailureInMethod : string -> bool @@ -35,12 +35,12 @@ val is_retain_builtin : string -> Clang_ast_t.type_ptr -> bool val is_modeled_attribute : string -> bool -val is_toll_free_bridging : Procname.t -> bool +val is_toll_free_bridging : Typ.Procname.t -> bool -val is_cf_retain_release : Procname.t -> bool +val is_cf_retain_release : Typ.Procname.t -> bool val get_predefined_model_method_signature : Typename.t -> string -> - (Typename.t -> string -> Procname.objc_cpp_method_kind -> Procname.t) -> + (Typename.t -> string -> Typ.Procname.objc_cpp_method_kind -> Typ.Procname.t) -> CFrontend_config.clang_lang -> CMethod_signature.method_signature option val is_dispatch_function_name : string -> (string * int) option diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index aeefc15db..5ff3e2b8d 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -338,7 +338,7 @@ let objc_new_trans trans_state loc stmt_info cls_name function_type = let call_flags = { CallFlags.default with CallFlags.cf_virtual = is_instance; } in let pname = CProcname.NoAstDecl.objc_method_of_string_kind - cls_name CFrontend_config.init Procname.ObjCInstanceMethod in + cls_name CFrontend_config.init Typ.Procname.ObjCInstanceMethod in CMethod_trans.create_external_procdesc trans_state.context.CContext.cfg pname is_instance None; let args = [(alloc_ret_exp, alloc_ret_type)] in let ret_id_typ = Some (init_ret_id, alloc_ret_type) in diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index e7c4d7ba4..f01cf434b 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -101,14 +101,14 @@ val contains_opaque_value_expr : Clang_ast_t.stmt -> bool val get_decl_ref_info : Clang_ast_t.stmt -> Clang_ast_t.decl_ref val builtin_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info -> - Typ.t -> trans_result list -> Procname.t -> trans_result option + Typ.t -> trans_result list -> Typ.Procname.t -> trans_result option val cxx_method_builtin_trans : trans_state -> Location.t -> trans_result list -> - Procname.t -> trans_result option + Typ.Procname.t -> trans_result option val alloc_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info -> Typ.t -> bool -> - Procname.t option -> trans_result + Typ.Procname.t option -> trans_result val new_or_alloc_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info -> Clang_ast_t.type_ptr -> Typename.t option -> string -> trans_result @@ -116,7 +116,7 @@ val new_or_alloc_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info -> val cpp_new_trans : Location.t -> Typ.t -> Exp.t option -> trans_result val cast_trans : - (Exp.t * Typ.t) list -> Location.t -> Typ.t -> Procname.t -> (Sil.instr * Exp.t) option + (Exp.t * Typ.t) list -> Location.t -> Typ.t -> Typ.Procname.t -> (Sil.instr * Exp.t) option val dereference_var_sil : Exp.t * Typ.t -> Location.t -> Sil.instr list * Exp.t @@ -207,7 +207,7 @@ sig exception SelfClassException of Typename.t val add_self_parameter_for_super_instance : - CContext.t -> Procname.t -> Location.t -> Clang_ast_t.obj_c_message_expr_info -> + CContext.t -> Typ.Procname.t -> Location.t -> Clang_ast_t.obj_c_message_expr_info -> trans_result val is_var_self : Pvar.t -> bool -> bool diff --git a/infer/src/clang/cVar_decl.mli b/infer/src/clang/cVar_decl.mli index 8d8b43be8..09f86097d 100644 --- a/infer/src/clang/cVar_decl.mli +++ b/infer/src/clang/cVar_decl.mli @@ -12,9 +12,9 @@ open! IStd (** Process variable declarations by saving them as local or global variables. *) (** Computes the local variables of a function or method to be added to the procdesc *) -val sil_var_of_decl : CContext.t -> Clang_ast_t.decl -> Procname.t -> Pvar.t +val sil_var_of_decl : CContext.t -> Clang_ast_t.decl -> Typ.Procname.t -> Pvar.t -val sil_var_of_decl_ref : CContext.t -> Clang_ast_t.decl_ref -> Procname.t -> Pvar.t +val sil_var_of_decl_ref : CContext.t -> Clang_ast_t.decl_ref -> Typ.Procname.t -> Pvar.t val add_var_to_locals : Procdesc.t -> Clang_ast_t.decl -> Typ.t -> Pvar.t -> unit diff --git a/infer/src/eradicate/AnnotatedSignature.ml b/infer/src/eradicate/AnnotatedSignature.ml index 19b1d1622..a9d5b2e33 100644 --- a/infer/src/eradicate/AnnotatedSignature.ml +++ b/infer/src/eradicate/AnnotatedSignature.ml @@ -58,7 +58,7 @@ let pp proc_name fmt annotated_signature = F.fprintf fmt "%a%a %s (%a )" pp_ia ia (Typ.pp_full Pp.text) ret_type - (Procname.to_simplified_string proc_name) + (Typ.Procname.to_simplified_string proc_name) (Pp.comma_seq pp_annotated_param) annotated_signature.params let is_anonymous_inner_class_wrapper ann_sig proc_name = @@ -84,7 +84,7 @@ let is_anonymous_inner_class_wrapper ann_sig proc_name = name_is_x_number name && Annot.Item.is_empty ia && PatternMatch.type_is_object t in - Procname.java_is_anonymous_inner_class proc_name + Typ.Procname.java_is_anonymous_inner_class proc_name && check_ret ann_sig.ret && List.for_all ~f:check_param ann_sig.params && !x_param_found @@ -120,7 +120,7 @@ let mark proc_name ann asig (b, bs) = let fail () = L.stdout "INTERNAL ERROR: annotation for procedure %s has wrong number of arguments@." - (Procname.to_unique_id proc_name); + (Typ.Procname.to_unique_id proc_name); L.stdout " ANNOTATED SIGNATURE: %a@." (pp proc_name) asig; assert false in let rec combine l1 l2 = match l1, l2 with diff --git a/infer/src/eradicate/AnnotatedSignature.mli b/infer/src/eradicate/AnnotatedSignature.mli index 1c21c51b7..5f30931dc 100644 --- a/infer/src/eradicate/AnnotatedSignature.mli +++ b/infer/src/eradicate/AnnotatedSignature.mli @@ -23,7 +23,7 @@ type annotation = (** Check if the annotated signature is for a wrapper of an anonymous inner class method. These wrappers have the same name as the original method, every type is Object, and the parameters are called x0, x1, x2. *) -val is_anonymous_inner_class_wrapper : t -> Procname.t -> bool +val is_anonymous_inner_class_wrapper : t -> Typ.Procname.t -> bool (** Check if the given parameter has a Nullable annotation in the given signature *) val param_is_nullable : Pvar.t -> t -> bool @@ -32,7 +32,7 @@ val param_is_nullable : Pvar.t -> t -> bool val method_annotation_mark_return : annotation -> Annot.Method.t -> Annot.Method.t (** Mark the annotated signature with the given annotation map. *) -val mark : Procname.t -> annotation -> t -> bool * bool list -> t +val mark : Typ.Procname.t -> annotation -> t -> bool * bool list -> t (** Mark the return of the annotated signature with the given annotation. *) val mark_return : annotation -> t -> t @@ -44,4 +44,4 @@ val get : ProcAttributes.t -> t val mk_ia : annotation -> Annot.Item.t -> Annot.Item.t (** Pretty print a method signature with annotations. *) -val pp : Procname.t -> Format.formatter -> t -> unit +val pp : Typ.Procname.t -> Format.formatter -> t -> unit diff --git a/infer/src/eradicate/eradicate.ml b/infer/src/eradicate/eradicate.ml index 413cd3661..904836545 100644 --- a/infer/src/eradicate/eradicate.ml +++ b/infer/src/eradicate/eradicate.ml @@ -189,7 +189,7 @@ struct pname pdesc ann_sig linereader loc in let module Initializers = struct - type init = Procname.t * Procdesc.t + type init = Typ.Procname.t * Procdesc.t let equal_class_opt = [%compare.equal : string option] @@ -203,8 +203,8 @@ struct PredSymb.equal_access callee_attributes.ProcAttributes.access PredSymb.Private in let same_class = let get_class_opt pn = match pn with - | Procname.Java pn_java -> - Some (Procname.java_get_class_name pn_java) + | Typ.Procname.Java pn_java -> + Some (Typ.Procname.java_get_class_name pn_java) | _ -> None in equal_class_opt (get_class_opt init_pn) (get_class_opt callee_pn) in @@ -226,15 +226,15 @@ struct let initializers_base_case = initializers_current_class in let res = ref [] in - let seen = ref Procname.Set.empty in + let seen = ref Typ.Procname.Set.empty in let mark_seen (initializers : init list) : unit = - List.iter ~f:(fun (pn, _) -> seen := Procname.Set.add pn !seen) initializers; + List.iter ~f:(fun (pn, _) -> seen := Typ.Procname.Set.add pn !seen) initializers; res := !res @ initializers in let rec fixpoint initializers_old = let initializers_new = get_private_called initializers_old in let initializers_new' = - List.filter ~f:(fun (pn, _) -> not (Procname.Set.mem pn !seen)) initializers_new in + List.filter ~f:(fun (pn, _) -> not (Typ.Procname.Set.mem pn !seen)) initializers_new in mark_seen initializers_new'; if initializers_new' <> [] then fixpoint initializers_new' in @@ -267,8 +267,8 @@ struct List.rev !res let get_class pn = match pn with - | Procname.Java pn_java -> - Some (Procname.java_get_class_name pn_java) + | Typ.Procname.Java pn_java -> + Some (Typ.Procname.java_get_class_name pn_java) | _ -> None @@ -295,7 +295,7 @@ struct let constructors_current_class = pname_and_pdescs_with (fun (pname, _) -> - Procname.is_constructor pname && + Typ.Procname.is_constructor pname && equal_class_opt (get_class pname) (get_class curr_pname)) in final_typestates constructors_current_class end @@ -344,7 +344,7 @@ struct let calls_this = ref false in let filter_special_cases () = - if Procname.java_is_access_method proc_name || + if Typ.Procname.java_is_access_method proc_name || (Specs.pdesc_resolve_attributes proc_desc).ProcAttributes.is_bridge_method then None else diff --git a/infer/src/eradicate/eradicateChecks.ml b/infer/src/eradicate/eradicateChecks.ml index 0da57ad9f..0b9d22752 100644 --- a/infer/src/eradicate/eradicateChecks.ml +++ b/infer/src/eradicate/eradicateChecks.ml @@ -45,7 +45,7 @@ let explain_expr tenv node e = (** Classify a procedure. *) let classify_procedure proc_attributes = let pn = proc_attributes.ProcAttributes.proc_name in - let unique_id = Procname.to_unique_id pn in + let unique_id = Typ.Procname.to_unique_id pn in let classification = if Models.is_modelled_nullable pn then "M" (* modelled *) else if Specs.proc_is_library proc_attributes then "L" (* library *) @@ -123,7 +123,7 @@ let check_condition tenv case_zero find_canonical_duplicate curr_pdesc | _ -> false in let do_instr = function | Sil.Call (_, Exp.Const (Const.Cfun pn), [_; (Exp.Sizeof(t, _, _), _)], _, _) when - Procname.equal pn BuiltinDecl.__instanceof && typ_is_throwable t -> + Typ.Procname.equal pn BuiltinDecl.__instanceof && typ_is_throwable t -> throwable_found := true | _ -> () in let do_node n = @@ -199,8 +199,8 @@ let check_field_assignment tenv | Some (_, ia) -> Annotations.ia_is_mutable ia | _ -> false in Config.eradicate_field_not_mutable && - not (Procname.is_constructor curr_pname) && - not (Procname.is_class_initializer curr_pname) && + not (Typ.Procname.is_constructor curr_pname) && + not (Typ.Procname.is_class_initializer curr_pname) && not (field_is_mutable ()) in if should_report_nullable || should_report_absent then begin @@ -237,7 +237,7 @@ let check_constructor_initialization tenv final_constructor_typestates loc: unit = State.set_node start_node; - if Procname.is_constructor curr_pname + if Typ.Procname.is_constructor curr_pname then begin match PatternMatch.get_this_type (Procdesc.get_attributes curr_pdesc) with | Some (Tptr (Tstruct name as ts, _)) -> ( diff --git a/infer/src/eradicate/models.ml b/infer/src/eradicate/models.ml index d46ba7a2a..fc423e38c 100644 --- a/infer/src/eradicate/models.ml +++ b/infer/src/eradicate/models.ml @@ -33,11 +33,11 @@ module Inference = struct DB.read_file_with_lock dir fname <> None let proc_get_ret_dir_fname pname = - let fname = Procname.to_filename pname ^ "_ret" in + let fname = Typ.Procname.to_filename pname ^ "_ret" in (get_dir (), fname) let proc_get_param_dir_fname pname = - let fname = Procname.to_filename pname ^ "_params" in + let fname = Typ.Procname.to_filename pname ^ "_params" in (get_dir (), fname) let update_count_str s_old = @@ -96,7 +96,7 @@ end (* Inference *) let table_has_procedure table proc_name = - let proc_id = Procname.to_unique_id proc_name in + let proc_id = Typ.Procname.to_unique_id proc_name in try ignore (Hashtbl.find table proc_id); true with Not_found -> false @@ -104,7 +104,7 @@ let table_has_procedure table proc_name = let get_modelled_annotated_signature proc_attributes = let proc_name = proc_attributes.ProcAttributes.proc_name in let annotated_signature = AnnotatedSignature.get proc_attributes in - let proc_id = Procname.to_unique_id proc_name in + let proc_id = Typ.Procname.to_unique_id proc_name in let infer_parameters ann_sig = let mark_par = if Inference.enabled then Inference.proc_parameters_marked proc_name @@ -148,7 +148,7 @@ let get_modelled_annotated_signature proc_attributes = (** Return true when the procedure has been modelled for nullable. *) let is_modelled_nullable proc_name = if use_models then - let proc_id = Procname.to_unique_id proc_name in + let proc_id = Typ.Procname.to_unique_id proc_name in try ignore (Hashtbl.find annotated_table_nullable proc_id ); true with Not_found -> false else false @@ -159,7 +159,7 @@ let is_check_not_null proc_name = (** Parameter number for a procedure known to be a checkNotNull *) let get_check_not_null_parameter proc_name = - let proc_id = Procname.to_unique_id proc_name in + let proc_id = Typ.Procname.to_unique_id proc_name in try Hashtbl.find check_not_null_parameter_table proc_id with Not_found -> 0 diff --git a/infer/src/eradicate/typeCheck.ml b/infer/src/eradicate/typeCheck.ml index a17595d23..42c2f7f38 100644 --- a/infer/src/eradicate/typeCheck.ml +++ b/infer/src/eradicate/typeCheck.ml @@ -41,7 +41,7 @@ module ComplexExpressions = struct let procname_optional_isPresent = Models.is_optional_isPresent - let procname_instanceof = Procname.equal BuiltinDecl.__instanceof + let procname_instanceof = Typ.Procname.equal BuiltinDecl.__instanceof let procname_is_false_on_null pn = match Specs.proc_resolve_attributes pn with @@ -97,7 +97,7 @@ module ComplexExpressions = struct | DExp.Dbinop (op, de1, de2) -> "(" ^ dexp_to_string de1 ^ (Binop.str Pp.text op) ^ dexp_to_string de2 ^ ")" | DExp.Dconst (Const.Cfun pn) -> - Procname.to_unique_id pn + Typ.Procname.to_unique_id pn | DExp.Dconst c -> F.asprintf "%a" (Const.pp Pp.text) c | DExp.Dderef de -> @@ -142,7 +142,7 @@ module ComplexExpressions = struct end (* ComplexExpressions *) type check_return_type = - Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit + Typ.Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit type find_canonical_duplicate = Procdesc.Node.t -> Procdesc.Node.t @@ -398,10 +398,10 @@ let typecheck_instr let constructor_check_calls_this calls_this pn = match curr_pname, pn with - | Procname.Java curr_pname_java, Procname.Java pn_java -> + | Typ.Procname.Java curr_pname_java, Typ.Procname.Java pn_java -> if String.equal - (Procname.java_get_class_name curr_pname_java) - (Procname.java_get_class_name pn_java) + (Typ.Procname.java_get_class_name curr_pname_java) + (Typ.Procname.java_get_class_name pn_java) then calls_this := true | _ -> () in @@ -409,7 +409,7 @@ let typecheck_instr (* Drops hidden and synthetic parameters which we do not check in a call. *) let drop_unchecked_params calls_this proc_attributes params = let pname = proc_attributes.ProcAttributes.proc_name in - if Procname.is_constructor pname then + if Typ.Procname.is_constructor pname then match PatternMatch.get_this_type proc_attributes with | Some _ -> begin @@ -438,7 +438,7 @@ let typecheck_instr (* Drop parameters from the signature which we do not check in a call. *) let drop_unchecked_signature_params proc_attributes annotated_signature = - if Procname.is_constructor (proc_attributes.ProcAttributes.proc_name) && + if Typ.Procname.is_constructor (proc_attributes.ProcAttributes.proc_name) && proc_attributes.ProcAttributes.is_synthetic_method then List.take annotated_signature.AnnotatedSignature.params @@ -525,14 +525,14 @@ let typecheck_instr check_field_assign (); typestate2 | Sil.Call (Some (id, _), Exp.Const (Const.Cfun pn), [(_, typ)], loc, _) - when Procname.equal pn BuiltinDecl.__new || - Procname.equal pn BuiltinDecl.__new_array -> + when Typ.Procname.equal pn BuiltinDecl.__new || + Typ.Procname.equal pn BuiltinDecl.__new_array -> TypeState.add_id id (typ, TypeAnnotation.const AnnotatedSignature.Nullable false TypeOrigin.New, [loc]) typestate (* new never returns null *) | Sil.Call (Some (id, _), Exp.Const (Const.Cfun pn), (e, typ):: _, loc, _) - when Procname.equal pn BuiltinDecl.__cast -> + when Typ.Procname.equal pn BuiltinDecl.__cast -> typecheck_expr_for_errors typestate e loc; let e', typestate' = convert_complex_exp_to_pvar node false e typestate loc in @@ -541,7 +541,7 @@ let typecheck_instr (typecheck_expr_simple typestate' e' typ TypeOrigin.ONone loc) typestate' | Sil.Call (Some (id, _), Exp.Const (Const.Cfun pn), [(array_exp, t)], loc, _) - when Procname.equal pn BuiltinDecl.__get_array_length -> + when Typ.Procname.equal pn BuiltinDecl.__get_array_length -> let (_, ta, _) = typecheck_expr find_canonical_duplicate calls_this @@ -576,7 +576,7 @@ let typecheck_instr typestate (* skip othe builtins *) | Sil.Call (ret_id, - Exp.Const (Const.Cfun ((Procname.Java callee_pname_java) as callee_pname)), + Exp.Const (Const.Cfun ((Typ.Procname.Java callee_pname_java) as callee_pname)), etl_, loc, cflags) @@ -592,7 +592,7 @@ let typecheck_instr ~f:(fun i (_, typ) -> let arg = if Int.equal i 0 && - not (Procname.java_is_static callee_pname) + not (Typ.Procname.java_is_static callee_pname) then "this" else Printf.sprintf "arg%d" i in (Mangled.from_string arg, typ)) @@ -619,7 +619,7 @@ let typecheck_instr drop_unchecked_signature_params callee_attributes annotated_signature in let is_anonymous_inner_class_constructor = - Procname.java_is_anonymous_inner_class_constructor callee_pname in + Typ.Procname.java_is_anonymous_inner_class_constructor callee_pname in let do_return loc' typestate' = match ret_id with @@ -763,9 +763,9 @@ let typecheck_instr let pname_get_from_pname_put pname_put = let object_t = (Some "java.lang", "Object") in let parameters = [object_t] in - Procname.java_replace_parameters - (Procname.java_replace_return_type - (Procname.java_replace_method pname_put "get") + Typ.Procname.java_replace_parameters + (Typ.Procname.java_replace_return_type + (Typ.Procname.java_replace_method pname_put "get") object_t) parameters in match call_params with @@ -774,9 +774,9 @@ let typecheck_instr ((_, exp_value), typ_value) :: _ -> (* Convert the dexp for k to the dexp for m.get(k) *) let convert_dexp_key_to_dexp_get dopt = match dopt, callee_pname with - | Some dexp_key, Procname.Java callee_pname_java -> + | Some dexp_key, Typ.Procname.Java callee_pname_java -> let pname_get = - Procname.Java (pname_get_from_pname_put callee_pname_java) in + Typ.Procname.Java (pname_get_from_pname_put callee_pname_java) in let dexp_get = DExp.Dconst (Const.Cfun pname_get) in let dexp_map = DExp.Dpvar pv_map in let args = [dexp_map; dexp_key] in @@ -803,7 +803,7 @@ let typecheck_instr begin if Config.eradicate_debug then begin - let unique_id = Procname.to_unique_id callee_pname in + let unique_id = Typ.Procname.to_unique_id callee_pname in let classification = EradicateChecks.classify_procedure callee_attributes in L.stdout " %s unique id: %s@." classification unique_id @@ -841,8 +841,8 @@ let typecheck_instr TypeState.set_extension typestate1 extension' else typestate1 in let has_method pn name = match pn with - | Procname.Java pn_java -> - String.equal (Procname.java_get_method pn_java) name + | Typ.Procname.Java pn_java -> + String.equal (Typ.Procname.java_get_method pn_java) name | _ -> false in if Models.is_check_not_null callee_pname then @@ -852,7 +852,7 @@ let typecheck_instr typestate2 else if has_method callee_pname "checkNotNull" - && Procname.java_is_vararg callee_pname + && Typ.Procname.java_is_vararg callee_pname then let last_parameter = List.length call_params in do_preconditions_check_not_null @@ -911,13 +911,13 @@ let typecheck_instr let map_dexp = function | Some (DExp.Dretcall - (DExp.Dconst (Const.Cfun (Procname.Java pname_java)), args, loc, call_flags)) -> + (DExp.Dconst (Const.Cfun (Typ.Procname.Java pname_java)), args, loc, call_flags)) -> let pname_java' = let object_t = (Some "java.lang", "Object") in - Procname.java_replace_return_type - (Procname.java_replace_method pname_java "get") + Typ.Procname.java_replace_return_type + (Typ.Procname.java_replace_method pname_java "get") object_t in - let fun_dexp = DExp.Dconst (Const.Cfun (Procname.Java pname_java')) in + let fun_dexp = DExp.Dconst (Const.Cfun (Typ.Procname.Java pname_java')) in Some (DExp.Dretcall (fun_dexp, args, loc, call_flags)) | _ -> None in begin diff --git a/infer/src/eradicate/typeCheck.mli b/infer/src/eradicate/typeCheck.mli index 550eeadfb..5407460a0 100644 --- a/infer/src/eradicate/typeCheck.mli +++ b/infer/src/eradicate/typeCheck.mli @@ -13,7 +13,7 @@ open! IStd (** Module type for the type checking functions. *) type check_return_type = - Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit + Typ.Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit type find_canonical_duplicate = Procdesc.Node.t -> Procdesc.Node.t @@ -29,6 +29,6 @@ type checks = val typecheck_node : Tenv.t -> 'a TypeState.ext -> bool ref -> checks -> Idenv.t -> - get_proc_desc -> Procname.t -> Procdesc.t -> + get_proc_desc -> Typ.Procname.t -> Procdesc.t -> find_canonical_duplicate -> AnnotatedSignature.t -> 'a TypeState.t -> Procdesc.Node.t -> Printer.LineReader.t -> 'a TypeState.t list * 'a TypeState.t list diff --git a/infer/src/eradicate/typeErr.ml b/infer/src/eradicate/typeErr.ml index f933ef24b..3fc776f5f 100644 --- a/infer/src/eradicate/typeErr.ml +++ b/infer/src/eradicate/typeErr.ml @@ -59,7 +59,7 @@ type parameter_not_nullable = AnnotatedSignature.annotation * string * (* description *) int * (* parameter number *) - Procname.t * + Typ.Procname.t * Location.t * (* callee location *) origin_descr [@@deriving compare] @@ -67,18 +67,18 @@ type parameter_not_nullable = (** Instance of an error *) type err_instance = | Condition_redundant of (bool * (string option) * bool) - | Inconsistent_subclass_return_annotation of Procname.t * Procname.t - | Inconsistent_subclass_parameter_annotation of string * int * Procname.t * Procname.t - | Field_not_initialized of Ident.fieldname * Procname.t + | Inconsistent_subclass_return_annotation of Typ.Procname.t * Typ.Procname.t + | Inconsistent_subclass_parameter_annotation of string * int * Typ.Procname.t * Typ.Procname.t + | Field_not_initialized of Ident.fieldname * Typ.Procname.t | Field_not_mutable of Ident.fieldname * origin_descr | Field_annotation_inconsistent of AnnotatedSignature.annotation * Ident.fieldname * origin_descr - | Field_over_annotated of Ident.fieldname * Procname.t + | Field_over_annotated of Ident.fieldname * Typ.Procname.t | Null_field_access of string option * Ident.fieldname * origin_descr * bool | Call_receiver_annotation_inconsistent - of AnnotatedSignature.annotation * string option * Procname.t * origin_descr + of AnnotatedSignature.annotation * string option * Typ.Procname.t * origin_descr | Parameter_annotation_inconsistent of parameter_not_nullable - | Return_annotation_inconsistent of AnnotatedSignature.annotation * Procname.t * origin_descr - | Return_over_annotated of Procname.t + | Return_annotation_inconsistent of AnnotatedSignature.annotation * Typ.Procname.t * origin_descr + | Return_over_annotated of Typ.Procname.t [@@deriving compare] module H = Hashtbl.Make(struct @@ -93,28 +93,28 @@ module H = Hashtbl.Make(struct | Condition_redundant (b, so, nn) -> Hashtbl.hash (1, b, string_opt_hash so, nn) | Field_not_initialized (fn, pn) -> - Hashtbl.hash (2, string_hash ((Ident.fieldname_to_string fn) ^ (Procname.to_string pn))) + Hashtbl.hash (2, string_hash ((Ident.fieldname_to_string fn) ^ (Typ.Procname.to_string pn))) | Field_not_mutable (fn, _) -> Hashtbl.hash (3, string_hash (Ident.fieldname_to_string fn)) | Field_annotation_inconsistent (ann, fn, _) -> Hashtbl.hash (4, ann, string_hash (Ident.fieldname_to_string fn)) | Field_over_annotated (fn, pn) -> - Hashtbl.hash (5, string_hash ((Ident.fieldname_to_string fn) ^ (Procname.to_string pn))) + Hashtbl.hash (5, string_hash ((Ident.fieldname_to_string fn) ^ (Typ.Procname.to_string pn))) | Null_field_access (so, fn, _, _) -> Hashtbl.hash (6, string_opt_hash so, string_hash (Ident.fieldname_to_string fn)) | Call_receiver_annotation_inconsistent (ann, so, pn, _) -> - Hashtbl.hash (7, ann, string_opt_hash so, Procname.hash_pname pn) + Hashtbl.hash (7, ann, string_opt_hash so, Typ.Procname.hash_pname pn) | Parameter_annotation_inconsistent (ann, s, n, pn, _, _) -> - Hashtbl.hash (8, ann, string_hash s, n, Procname.hash_pname pn) + Hashtbl.hash (8, ann, string_hash s, n, Typ.Procname.hash_pname pn) | Return_annotation_inconsistent (ann, pn, _) -> - Hashtbl.hash (9, ann, Procname.hash_pname pn) + Hashtbl.hash (9, ann, Typ.Procname.hash_pname pn) | Return_over_annotated pn -> - Hashtbl.hash (10, Procname.hash_pname pn) + Hashtbl.hash (10, Typ.Procname.hash_pname pn) | Inconsistent_subclass_return_annotation (pn, opn) -> - Hashtbl.hash (11, Procname.hash_pname pn, Procname.hash_pname opn) + Hashtbl.hash (11, Typ.Procname.hash_pname pn, Typ.Procname.hash_pname opn) | Inconsistent_subclass_parameter_annotation (param_name, pos, pn, opn) -> let pn_hash = string_hash param_name in - Hashtbl.hash (12, pn_hash, pos, Procname.hash_pname pn, Procname.hash_pname opn) + Hashtbl.hash (12, pn_hash, pos, Typ.Procname.hash_pname pn, Typ.Procname.hash_pname opn) let hash (err_inst, instr_ref_opt) = let x = match instr_ref_opt with @@ -225,7 +225,7 @@ module Strict = struct end (* Strict *) type st_report_error = - Procname.t -> + Typ.Procname.t -> Procdesc.t -> string -> Location.t -> @@ -244,10 +244,10 @@ let report_error_now tenv let do_print ew_string kind_s s = L.stdout "%a:%d " SourceFile.pp loc.Location.file loc.Location.line; let mname = match pname with - | Procname.Java pname_java -> - Procname.java_get_method pname_java + | Typ.Procname.Java pname_java -> + Typ.Procname.java_get_method pname_java | _ -> - Procname.to_simplified_string pname in + Typ.Procname.to_simplified_string pname in L.stdout "%s %s in %s %s@." ew_string kind_s mname s in let is_err, kind_s, description, advice, field_name, origin_loc = match err_instance with @@ -267,14 +267,14 @@ let report_error_now tenv None | Field_not_initialized (fn, pn) -> let constructor_name = - if Procname.is_constructor pn + if Typ.Procname.is_constructor pn then "the constructor" else match pn with - | Procname.Java pn_java -> - Procname.java_get_method pn_java + | Typ.Procname.Java pn_java -> + Typ.Procname.java_get_method pn_java | _ -> - Procname.to_simplified_string pn in + Typ.Procname.to_simplified_string pn in true, "ERADICATE_FIELD_NOT_INITIALIZED", P.sprintf @@ -316,14 +316,14 @@ let report_error_now tenv origin_loc | Field_over_annotated (fn, pn) -> let constructor_name = - if Procname.is_constructor pn + if Typ.Procname.is_constructor pn then "the constructor" else match pn with - | Procname.Java pn_java -> - Procname.java_get_method pn_java + | Typ.Procname.Java pn_java -> + Typ.Procname.java_get_method pn_java | _ -> - Procname.to_simplified_string pn in + Typ.Procname.to_simplified_string pn in true, "ERADICATE_FIELD_OVER_ANNOTATED", P.sprintf @@ -353,14 +353,14 @@ let report_error_now tenv P.sprintf "The value of `%s` in the call to `%s` could be null. %s" (Option.value s_opt ~default:"") - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) origin_description | AnnotatedSignature.Present -> "ERADICATE_VALUE_NOT_PRESENT", P.sprintf "The value of `%s` in the call to `%s` is not @Present. %s" (Option.value s_opt ~default:"") - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) origin_description in true, kind_s, @@ -374,7 +374,7 @@ let report_error_now tenv "ERADICATE_PARAMETER_NOT_NULLABLE", P.sprintf "`%s` needs a non-null value in parameter %d but argument `%s` can be null. %s" - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) n s origin_desc @@ -382,7 +382,7 @@ let report_error_now tenv "ERADICATE_PARAMETER_VALUE_ABSENT", P.sprintf "`%s` needs a present value in parameter %d but argument `%s` can be absent. %s" - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) n s origin_desc in @@ -398,13 +398,13 @@ let report_error_now tenv "ERADICATE_RETURN_NOT_NULLABLE", P.sprintf "Method `%s` may return null but it is not annotated with `@Nullable`. %s" - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) origin_description | AnnotatedSignature.Present -> "ERADICATE_RETURN_VALUE_NOT_PRESENT", P.sprintf "Method `%s` may return an absent value but it is annotated with `@Present`. %s" - (Procname.to_simplified_string pn) + (Typ.Procname.to_simplified_string pn) origin_description in true, kind_s, @@ -417,7 +417,7 @@ let report_error_now tenv "ERADICATE_RETURN_OVER_ANNOTATED", P.sprintf "Method `%s` is annotated with `@Nullable` but never returns null." - (Procname.to_simplified_string pn), + (Typ.Procname.to_simplified_string pn), None, None, None @@ -426,8 +426,8 @@ let report_error_now tenv "ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION", P.sprintf "Method `%s` is annotated with `@Nullable` but overrides unannotated method `%s`." - (Procname.to_simplified_string ~withclass: true pn) - (Procname.to_simplified_string ~withclass: true opn), + (Typ.Procname.to_simplified_string ~withclass: true pn) + (Typ.Procname.to_simplified_string ~withclass: true opn), None, None, None @@ -443,8 +443,8 @@ let report_error_now tenv "%s parameter `%s` of method `%s` is not `@Nullable` but is declared `@Nullable`\ in the parent class method `%s`." (translate_position pos) param_name - (Procname.to_simplified_string ~withclass: true pn) - (Procname.to_simplified_string ~withclass: true opn), + (Typ.Procname.to_simplified_string ~withclass: true pn) + (Typ.Procname.to_simplified_string ~withclass: true opn), None, None, None in diff --git a/infer/src/eradicate/typeErr.mli b/infer/src/eradicate/typeErr.mli index 8e09389a3..8a8a5f5b5 100644 --- a/infer/src/eradicate/typeErr.mli +++ b/infer/src/eradicate/typeErr.mli @@ -43,31 +43,31 @@ type parameter_not_nullable = AnnotatedSignature.annotation * string * (* description *) int * (* parameter number *) - Procname.t * + Typ.Procname.t * Location.t * (* callee location *) origin_descr (** Instance of an error *) type err_instance = | Condition_redundant of (bool * (string option) * bool) - | Inconsistent_subclass_return_annotation of Procname.t * Procname.t - | Inconsistent_subclass_parameter_annotation of string * int * Procname.t * Procname.t - | Field_not_initialized of Ident.fieldname * Procname.t + | Inconsistent_subclass_return_annotation of Typ.Procname.t * Typ.Procname.t + | Inconsistent_subclass_parameter_annotation of string * int * Typ.Procname.t * Typ.Procname.t + | Field_not_initialized of Ident.fieldname * Typ.Procname.t | Field_not_mutable of Ident.fieldname * origin_descr | Field_annotation_inconsistent of AnnotatedSignature.annotation * Ident.fieldname * origin_descr - | Field_over_annotated of Ident.fieldname * Procname.t + | Field_over_annotated of Ident.fieldname * Typ.Procname.t | Null_field_access of string option * Ident.fieldname * origin_descr * bool | Call_receiver_annotation_inconsistent - of AnnotatedSignature.annotation * string option * Procname.t * origin_descr + of AnnotatedSignature.annotation * string option * Typ.Procname.t * origin_descr | Parameter_annotation_inconsistent of parameter_not_nullable - | Return_annotation_inconsistent of AnnotatedSignature.annotation * Procname.t * origin_descr - | Return_over_annotated of Procname.t + | Return_annotation_inconsistent of AnnotatedSignature.annotation * Typ.Procname.t * origin_descr + | Return_over_annotated of Typ.Procname.t val node_reset_forall : Procdesc.Node.t -> unit type st_report_error = - Procname.t -> + Typ.Procname.t -> Procdesc.t -> string -> Location.t -> diff --git a/infer/src/eradicate/typeOrigin.ml b/infer/src/eradicate/typeOrigin.ml index 15c84fa44..8a248788d 100644 --- a/infer/src/eradicate/typeOrigin.ml +++ b/infer/src/eradicate/typeOrigin.ml @@ -18,7 +18,7 @@ module P = Printf type proc_origin = { - pname : Procname.t; + pname : Typ.Procname.t; loc: Location.t; annotated_signature : AnnotatedSignature.t; is_library : bool; @@ -46,7 +46,7 @@ let rec to_string = function | Proc po -> Printf.sprintf "Fun %s" - (Procname.to_simplified_string po.pname) + (Typ.Procname.to_simplified_string po.pname) | New -> "New" | ONone -> @@ -79,7 +79,7 @@ let get_description tenv origin = let description = Printf.sprintf "call to %s%s%s%s" strict - (Procname.to_simplified_string po.pname) + (Typ.Procname.to_simplified_string po.pname) modelled_in (atline po.loc) in Some (description, Some po.loc, Some po.annotated_signature) diff --git a/infer/src/eradicate/typeOrigin.mli b/infer/src/eradicate/typeOrigin.mli index a29cc3ea2..7a521d4f7 100644 --- a/infer/src/eradicate/typeOrigin.mli +++ b/infer/src/eradicate/typeOrigin.mli @@ -12,7 +12,7 @@ open! IStd (** Case Proc *) type proc_origin = { - pname : Procname.t; + pname : Typ.Procname.t; loc: Location.t; annotated_signature : AnnotatedSignature.t; is_library : bool; diff --git a/infer/src/eradicate/typeState.ml b/infer/src/eradicate/typeState.ml index 24dd62f4a..e86107d89 100644 --- a/infer/src/eradicate/typeState.ml +++ b/infer/src/eradicate/typeState.ml @@ -18,14 +18,14 @@ module P = Printf (** Parameters of a call. *) type parameters = (Exp.t * Typ.t) list -type get_proc_desc = Procname.t -> Procdesc.t option +type get_proc_desc = Typ.Procname.t -> Procdesc.t option (** Extension to a typestate with values of type 'a. *) type 'a ext = { empty : 'a; (** empty extension *) check_instr : - Tenv.t -> get_proc_desc -> Procname.t -> + Tenv.t -> get_proc_desc -> Typ.Procname.t -> Procdesc.t -> 'a -> Sil.instr -> parameters -> 'a; (** check the extension for an instruction *) join : 'a -> 'a -> 'a; (** join two extensions *) diff --git a/infer/src/eradicate/typeState.mli b/infer/src/eradicate/typeState.mli index 8374446dc..1a05d0019 100644 --- a/infer/src/eradicate/typeState.mli +++ b/infer/src/eradicate/typeState.mli @@ -14,14 +14,14 @@ open! IStd (** Parameters of a call. *) type parameters = (Exp.t * Typ.t) list -type get_proc_desc = Procname.t -> Procdesc.t option +type get_proc_desc = Typ.Procname.t -> Procdesc.t option (** Extension to a typestate with values of type 'a. *) type 'a ext = { empty : 'a; (** empty extension *) check_instr : - Tenv.t -> get_proc_desc -> Procname.t -> + Tenv.t -> get_proc_desc -> Typ.Procname.t -> Procdesc.t ->'a -> Sil.instr -> parameters -> 'a; (** check the extension for an instruction *) join : 'a -> 'a -> 'a; (** join two extensions *) diff --git a/infer/src/harness/androidFramework.ml b/infer/src/harness/androidFramework.ml index 736800844..f62d445cc 100644 --- a/infer/src/harness/androidFramework.ml +++ b/infer/src/harness/androidFramework.ml @@ -20,8 +20,8 @@ let on_destroy_view = "onDestroyView" (** return true if [pname] is a special lifecycle cleanup method *) let is_destroy_method pname = match pname with - | Procname.Java pname_java -> - let method_name = Procname.java_get_method pname_java in + | Typ.Procname.Java pname_java -> + let method_name = Typ.Procname.java_get_method pname_java in String.equal method_name on_destroy || String.equal method_name on_destroy_view | _ -> @@ -90,8 +90,8 @@ let get_lifecycle_for_framework_typ_opt tenv lifecycle_typ lifecycle_proc_strs = let lookup_proc lifecycle_proc = List.find_exn ~f:(fun decl_proc -> match decl_proc with - | Procname.Java decl_proc_java -> - String.equal lifecycle_proc (Procname.java_get_method decl_proc_java) + | Typ.Procname.Java decl_proc_java -> + String.equal lifecycle_proc (Typ.Procname.java_get_method decl_proc_java) | _ -> false ) methods in diff --git a/infer/src/harness/androidFramework.mli b/infer/src/harness/androidFramework.mli index 059c8679c..bb6a212dc 100644 --- a/infer/src/harness/androidFramework.mli +++ b/infer/src/harness/androidFramework.mli @@ -29,11 +29,11 @@ val is_view : Tenv.t -> Typename.t -> bool val is_fragment : Tenv.t -> Typename.t -> bool (** return true if [procname] is a special lifecycle cleanup method *) -val is_destroy_method : Procname.t -> bool +val is_destroy_method : Typ.Procname.t -> bool (** given an Android framework type mangled string [lifecycle_typ] (e.g., android.app.Activity) and a list of method names [lifecycle_procs_strs], get the appropriate typ and procnames *) -val get_lifecycle_for_framework_typ_opt : Tenv.t -> Typename.t -> string list -> Procname.t list +val get_lifecycle_for_framework_typ_opt : Tenv.t -> Typename.t -> string list -> Typ.Procname.t list (** return true if [class_name] is the name of a class that belong to the Android framework *) val is_android_lib_class : Typename.t -> bool diff --git a/infer/src/harness/harness.ml b/infer/src/harness/harness.ml index 1e6efc954..b1ea18d3c 100644 --- a/infer/src/harness/harness.ml +++ b/infer/src/harness/harness.ml @@ -51,12 +51,12 @@ let create_harness cfg cg tenv = let harness_procname = let harness_cls_name = Typename.name name in let pname = - Procname.Java - (Procname.java + Typ.Procname.Java + (Typ.Procname.java (Typename.Java.from_string harness_cls_name) None - "InferGeneratedHarness" [] Procname.Static) in + "InferGeneratedHarness" [] Typ.Procname.Static) in match pname with - | Procname.Java harness_procname -> harness_procname + | Typ.Procname.Java harness_procname -> harness_procname | _ -> assert false in Inhabit.inhabit_trace tenv lifecycle_trace harness_procname cg cfg ) tenv diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index e56d7dc8f..200a09344 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -19,7 +19,7 @@ module IdSet = Ident.IdentSet module TypSet = Typ.Set module TypMap = Typ.Map -type lifecycle_trace = (Procname.t * Typ.t option) list +type lifecycle_trace = (Typ.Procname.t * Typ.t option) list (** list of instrs and temporary variables created during inhabitation and a cache of types that * have already been inhabited *) @@ -28,13 +28,13 @@ type env = { instrs : Sil.instr list; (* set of types currently being inhabited. consult to prevent infinite recursion *) cur_inhabiting : TypSet.t; pc : Location.t; - harness_name : Procname.java } + harness_name : Typ.Procname.java } let procdesc_from_name cfg pname = let pdesc_ref = ref None in Cfg.iter_proc_desc cfg (fun cfg_pname pdesc -> - if Procname.equal cfg_pname pname then + if Typ.Procname.equal cfg_pname pname then pdesc_ref := Some pdesc ); !pdesc_ref @@ -102,7 +102,7 @@ let rec inhabit_typ tenv typ cfg env = let is_suitable_constructor p = let try_get_non_receiver_formals p = get_non_receiver_formals (formals_from_name cfg p) in - Procname.is_constructor p + Typ.Procname.is_constructor p && List.for_all ~f:(fun (_, typ) -> not (TypSet.mem typ env.cur_inhabiting) ) (try_get_non_receiver_formals p) in @@ -121,8 +121,8 @@ let rec inhabit_typ tenv typ cfg env = * we can use it as a descriptive local variable name in the harness *) let typ_class_name = match constructor with - | Procname.Java pname_java -> - Procname.java_get_simple_class_name pname_java + | Typ.Procname.Java pname_java -> + Typ.Procname.java_get_simple_class_name pname_java | _ -> create_fresh_local_name () in (env, Mangled.from_string typ_class_name) @@ -131,7 +131,7 @@ let rec inhabit_typ tenv typ cfg env = * both fresh. the only point of this is to add a descriptive local name that makes error * reports from the harness look nicer -- it's not necessary to make symbolic execution work *) let fresh_local_exp = - Exp.Lvar (Pvar.mk typ_class_name (Procname.Java env.harness_name)) in + Exp.Lvar (Pvar.mk typ_class_name (Typ.Procname.Java env.harness_name)) in let write_to_local_instr = Sil.Store (fresh_local_exp, ptr_to_typ, allocated_obj_exp, env.pc) in let env' = env_add_instr write_to_local_instr env in @@ -178,7 +178,7 @@ let inhabit_call_with_args procname procdesc args env = let call_instr = let fun_exp = fun_exp_from_name procname in let flags = - { CallFlags.default with CallFlags.cf_virtual = not (Procname.java_is_static procname); } in + { CallFlags.default with CallFlags.cf_virtual = not (Typ.Procname.java_is_static procname); } in Sil.Call (retval, fun_exp, args, env.pc, flags) in env_add_instr call_instr env @@ -194,7 +194,7 @@ let inhabit_call tenv (procname, receiver) cfg env = | ([], Some _) -> L.err "Expected at least one formal to bind receiver to in method %a@." - Procname.pp procname; + Typ.Procname.pp procname; assert false in let (args, env) = inhabit_args tenv formals cfg env in inhabit_call_with_args procname procdesc args env @@ -206,8 +206,8 @@ let create_dummy_harness_filename harness_name = let dummy_file_dir = Filename.temp_dir_name in let file_str = - Procname.java_get_class_name - harness_name ^ "_" ^ Procname.java_get_method harness_name ^ ".java" in + Typ.Procname.java_get_class_name + harness_name ^ "_" ^ Typ.Procname.java_get_method harness_name ^ ".java" in Filename.concat dummy_file_dir file_str (** write the SIL for the harness to a file *) @@ -222,9 +222,9 @@ let write_harness_to_file harness_instrs harness_file_name = (** add the harness proc to the cg and make sure its callees can be looked up by sym execution *) let add_harness_to_cg harness_name harness_node cg = - Cg.add_defined_node cg (Procname.Java harness_name); + Cg.add_defined_node cg (Typ.Procname.Java harness_name); List.iter - ~f:(fun p -> Cg.add_edge cg (Procname.Java harness_name) p) + ~f:(fun p -> Cg.add_edge cg (Typ.Procname.Java harness_name) p) (Procdesc.Node.get_callees harness_node) (** create and fill the appropriate nodes and add them to the harness cfg. also add the harness @@ -232,7 +232,7 @@ let add_harness_to_cg harness_name harness_node cg = let setup_harness_cfg harness_name env cg cfg = (* each procedure has different scope: start names from id 0 *) Ident.NameGenerator.reset (); - let procname = Procname.Java harness_name in + let procname = Typ.Procname.Java harness_name in let proc_attributes = { (ProcAttributes.default procname Config.Java) with ProcAttributes.is_defined = true; diff --git a/infer/src/harness/inhabit.mli b/infer/src/harness/inhabit.mli index 523e2c569..80bfb0573 100644 --- a/infer/src/harness/inhabit.mli +++ b/infer/src/harness/inhabit.mli @@ -11,9 +11,9 @@ open! IStd (** Generate a procedure that calls a given sequence of methods. Useful for harness/test generation. *) -type lifecycle_trace = (Procname.t * Typ.t option) list +type lifecycle_trace = (Typ.Procname.t * Typ.t option) list (** create a procedure named harness_name that calls each of the methods in trace add it to the cg/cfg *) -val inhabit_trace : Tenv.t -> lifecycle_trace -> Procname.java -> Cg.t -> Cfg.cfg -> unit +val inhabit_trace : Tenv.t -> lifecycle_trace -> Typ.Procname.java -> Cg.t -> Cfg.cfg -> unit diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index 6050f2ba8..2e84a0704 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -70,7 +70,7 @@ let add_models jar_filename = let is_model procname = - String.Set.mem !models_specs_filenames (Procname.to_filename procname) + String.Set.mem !models_specs_filenames (Typ.Procname.to_filename procname) let split_classpath cp = Str.split (Str.regexp JFile.sep) cp diff --git a/infer/src/java/jClasspath.mli b/infer/src/java/jClasspath.mli index 20e66bb63..c6fb70caf 100644 --- a/infer/src/java/jClasspath.mli +++ b/infer/src/java/jClasspath.mli @@ -23,7 +23,7 @@ val models_tenv : Tenv.t ref val add_models : string -> unit (** Check if there is a model for the given procname *) -val is_model : Procname.t -> bool +val is_model : Typ.Procname.t -> bool val split_classpath : string -> string list diff --git a/infer/src/java/jContext.ml b/infer/src/java/jContext.ml index 934cb00f2..7c2927cbd 100644 --- a/infer/src/java/jContext.ml +++ b/infer/src/java/jContext.ml @@ -115,15 +115,15 @@ let is_goto_jump context pc = | _ -> false with Not_found -> false -let exn_node_table = Procname.Hash.create 100 +let exn_node_table = Typ.Procname.Hash.create 100 let reset_exn_node_table () = - Procname.Hash.clear exn_node_table + Typ.Procname.Hash.clear exn_node_table let add_exn_node procname (exn_node : Procdesc.Node.t) = - Procname.Hash.add exn_node_table procname exn_node + Typ.Procname.Hash.add exn_node_table procname exn_node let get_exn_node procdesc = try - Some (Procname.Hash.find exn_node_table (Procdesc.get_proc_name procdesc)) + Some (Typ.Procname.Hash.find exn_node_table (Procdesc.get_proc_name procdesc)) with Not_found -> None diff --git a/infer/src/java/jContext.mli b/infer/src/java/jContext.mli index ac34eb7e7..7aabcf2bf 100644 --- a/infer/src/java/jContext.mli +++ b/infer/src/java/jContext.mli @@ -96,7 +96,7 @@ val reset_pvar_type : t -> unit val reset_exn_node_table : unit -> unit (** adds the exception node for a given method *) -val add_exn_node : Procname.t -> Procdesc.Node.t -> unit +val add_exn_node : Typ.Procname.t -> Procdesc.Node.t -> unit (** returns the exception node of a given method *) val get_exn_node : Procdesc.t -> Procdesc.Node.t option diff --git a/infer/src/java/jFrontend.ml b/infer/src/java/jFrontend.ml index 0a3aa6630..03afbec3c 100644 --- a/infer/src/java/jFrontend.ml +++ b/infer/src/java/jFrontend.ml @@ -87,7 +87,7 @@ let add_cmethod source_file program linereader icfg cm proc_name = match JContext.get_exn_node procdesc with | Some node -> node | None -> - failwithf "No exn node found for %s" (Procname.to_string proc_name) in + failwithf "No exn node found for %s" (Typ.Procname.to_string proc_name) in let instrs = JBir.code jbir_code in let context = JContext.create_context icfg procdesc jbir_code cn source_file program in @@ -138,7 +138,7 @@ let create_icfg source_file linereader program icfg cn node = let proc_name = JTransType.translate_method_name m in if JClasspath.is_model proc_name then (* do not translate the method if there is a model for it *) - L.out_debug "Skipping method with a model: %s@." (Procname.to_string proc_name) + L.out_debug "Skipping method with a model: %s@." (Typ.Procname.to_string proc_name) else try (* each procedure has different scope: start names from id 0 *) @@ -156,7 +156,7 @@ let create_icfg source_file linereader program icfg cn node = with JBasics.Class_structure_error _ -> L.do_err "create_icfg raised JBasics.Class_structure_error on %a@." - Procname.pp proc_name in + Typ.Procname.pp proc_name in Javalib.m_iter translate node diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index 6cf071f05..9b81947d5 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -117,7 +117,7 @@ let do_all_files classpath sources classes = ~f:(fun pattern -> Str.string_match (Str.regexp pattern) path 0) Config.skip_analysis_in_path in is_path_matching (SourceFile.to_rel_path source_file) - || Inferconfig.skip_translation_matcher source_file Procname.empty_block in + || Inferconfig.skip_translation_matcher source_file Typ.Procname.empty_block in let translate_source_file basename (package_opt, _) source_file = init_global_state source_file; if not (skip source_file) then diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 9378288ee..540d25509 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -33,14 +33,14 @@ let init_loc_map : Location.t JBasics.ClassMap.t ref = ref JBasics.ClassMap.empt let fix_method_definition_line linereader proc_name loc = let proc_name_java = match proc_name with - | Procname.Java p -> p + | Typ.Procname.Java p -> p | _ -> assert false in let method_name = - if Procname.is_constructor proc_name then + if Typ.Procname.is_constructor proc_name then let inner_class_name cname = match String.rsplit2 cname ~on:'$' with Some (_, icn) -> icn | None -> cname in - inner_class_name (Procname.java_get_simple_class_name proc_name_java) - else Procname.java_get_method proc_name_java in + inner_class_name (Typ.Procname.java_get_simple_class_name proc_name_java) + else Typ.Procname.java_get_method proc_name_java in let regex = Str.regexp (Str.quote method_name) in let method_is_defined_here linenum = match Printer.LineReader.from_file_linenum_original linereader loc.Location.file linenum with @@ -131,8 +131,8 @@ let formals_from_signature program tenv cn ms kind = let arg_type = JTransType.value_type program tenv vt in (arg_name, arg_type):: l in let init_arg_list = match kind with - | Procname.Static -> [] - | Procname.Non_Static -> [(JConfig.this, JTransType.get_class_type program tenv cn)] in + | Typ.Procname.Static -> [] + | Typ.Procname.Non_Static -> [(JConfig.this, JTransType.get_class_type program tenv cn)] in 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 ... *) @@ -380,7 +380,7 @@ let create_cm_procdesc source_file program linereader icfg cm proc_name = with JBir.Subroutine -> L.do_err "create_procdesc raised JBir.Subroutine on %a@." - Procname.pp proc_name; + Typ.Procname.pp proc_name; None let builtin_new = @@ -562,7 +562,7 @@ let method_invocation ~init expr_list in let callee_procname = - let proc = Procname.from_string_c_fun (JBasics.ms_name ms) in + let proc = Typ.Procname.from_string_c_fun (JBasics.ms_name ms) in if JBasics.cn_equal cn' (JBasics.make_cn JConfig.infer_builtins_cl) && BuiltinDecl.is_declared proc then proc @@ -593,7 +593,7 @@ let method_invocation (* add a file attribute when calling the constructor of a subtype of Closeable *) | (_, typ) as exp :: _ - when Procname.is_constructor callee_procname && JTransType.is_closeable program tenv typ -> + when Typ.Procname.is_constructor callee_procname && JTransType.is_closeable program tenv typ -> let set_file_attr = let set_builtin = Exp.Const (Const.Cfun BuiltinDecl.__set_file_attribute) in Sil.Call (None, set_builtin, [exp], loc, CallFlags.default) in @@ -601,7 +601,7 @@ let method_invocation call_instrs @ [set_file_attr] (* remove file attribute when calling the close method of a subtype of Closeable *) - | exp :: [] when Procname.java_is_close callee_procname -> + | exp :: [] when Typ.Procname.java_is_close callee_procname -> let set_mem_attr = let set_builtin = Exp.Const (Const.Cfun BuiltinDecl.__set_mem_attribute) in Sil.Call (None, set_builtin, [exp], loc, CallFlags.default) in @@ -825,11 +825,11 @@ let rec instruction (context : JContext.t) pc instr : translation = let constr_procname, call_instrs = let ret_opt = Some (Exp.Var ret_id, class_type) in method_invocation - context loc pc None cn constr_ms ret_opt constr_arg_list I_Special Procname.Non_Static in + context loc pc None cn constr_ms ret_opt constr_arg_list I_Special Typ.Procname.Non_Static in let pvar = JContext.set_pvar context var class_type in let set_instr = Sil.Store (Exp.Lvar pvar, class_type, Exp.Var ret_id, loc) in let instrs = (new_instr :: call_instrs) @ [set_instr] in - let node_kind = Procdesc.Node.Stmt_node ("Call "^(Procname.to_string constr_procname)) in + let node_kind = Procdesc.Node.Stmt_node ("Call "^(Typ.Procname.to_string constr_procname)) in let node = create_node node_kind instrs in let caller_procname = (Procdesc.get_proc_name context.procdesc) in Cg.add_edge cg caller_procname constr_procname; @@ -859,8 +859,8 @@ let rec instruction (context : JContext.t) pc instr : translation = Some (sil_arg_expr, arg_typ), [], instrs | _ -> None, args, [] in let callee_procname, call_instrs = - method_invocation context loc pc var_opt cn ms sil_obj_opt args I_Static Procname.Static in - let node_kind = Procdesc.Node.Stmt_node ("Call "^(Procname.to_string callee_procname)) in + method_invocation context loc pc var_opt cn ms sil_obj_opt args I_Static Typ.Procname.Static in + let node_kind = Procdesc.Node.Stmt_node ("Call "^(Typ.Procname.to_string callee_procname)) in let call_node = create_node node_kind (instrs @ call_instrs) in let caller_procname = (Procdesc.get_proc_name context.procdesc) in Cg.add_edge cg caller_procname callee_procname; @@ -872,8 +872,8 @@ let rec instruction (context : JContext.t) pc instr : translation = let callee_procname, call_instrs = let ret_opt = Some (sil_obj_expr, sil_obj_type) in method_invocation - context loc pc var_opt cn ms ret_opt args invoke_kind Procname.Non_Static in - let node_kind = Procdesc.Node.Stmt_node ("Call "^(Procname.to_string callee_procname)) in + context loc pc var_opt cn ms ret_opt args invoke_kind Typ.Procname.Non_Static in + let node_kind = Procdesc.Node.Stmt_node ("Call "^(Typ.Procname.to_string callee_procname)) in let call_node = create_node node_kind (instrs @ call_instrs) in Cg.add_edge cg caller_procname callee_procname; call_node in @@ -899,8 +899,8 @@ let rec instruction (context : JContext.t) pc instr : translation = | JBir.InvokeNonVirtual (var_opt, obj, cn, ms, args) -> let (instrs, sil_obj_expr, sil_obj_type) = expression context pc obj in let callee_procname, call_instrs = - method_invocation context loc pc var_opt cn ms (Some (sil_obj_expr, sil_obj_type)) args I_Special Procname.Non_Static in - let node_kind = Procdesc.Node.Stmt_node ("Call "^(Procname.to_string callee_procname)) in + method_invocation context loc pc var_opt cn ms (Some (sil_obj_expr, sil_obj_type)) args I_Special Typ.Procname.Non_Static in + let node_kind = Procdesc.Node.Stmt_node ("Call "^(Typ.Procname.to_string callee_procname)) in let call_node = create_node node_kind (instrs @ call_instrs) in let procdesc = context.procdesc in let caller_procname = (Procdesc.get_proc_name procdesc) in @@ -938,7 +938,7 @@ let rec instruction (context : JContext.t) pc instr : translation = let constr_ms = JBasics.make_ms JConfig.constructor_name [] None in let _, call_instrs = let ret_opt = Some (Exp.Var ret_id, class_type) in - method_invocation context loc pc None npe_cn constr_ms ret_opt [] I_Special Procname.Static in + method_invocation context loc pc None npe_cn constr_ms ret_opt [] I_Special Typ.Procname.Static in let sil_exn = Exp.Exn (Exp.Var ret_id) in let set_instr = Sil.Store (Exp.Lvar ret_var, ret_type, sil_exn, loc) in let npe_instrs = instrs @ [sil_prune_null] @ (new_instr :: call_instrs) @ [set_instr] in @@ -993,7 +993,7 @@ let rec instruction (context : JContext.t) pc instr : translation = let _, call_instrs = method_invocation context loc pc None out_of_bound_cn constr_ms - (Some (Exp.Var ret_id, class_type)) [] I_Special Procname.Static in + (Some (Exp.Var ret_id, class_type)) [] I_Special Typ.Procname.Static in let sil_exn = Exp.Exn (Exp.Var ret_id) in let set_instr = Sil.Store (Exp.Lvar ret_var, ret_type, sil_exn, loc) in let out_of_bound_instrs = @@ -1032,7 +1032,7 @@ let rec instruction (context : JContext.t) pc instr : translation = let constr_ms = JBasics.make_ms JConfig.constructor_name [] None in let _, call_instrs = method_invocation context loc pc None cce_cn constr_ms - (Some (Exp.Var ret_id, class_type)) [] I_Special Procname.Static in + (Some (Exp.Var ret_id, class_type)) [] I_Special Typ.Procname.Static in let sil_exn = Exp.Exn (Exp.Var ret_id) in let set_instr = Sil.Store (Exp.Lvar ret_var, ret_type, sil_exn, loc) in let cce_instrs = diff --git a/infer/src/java/jTrans.mli b/infer/src/java/jTrans.mli index 9f0bd008f..4bb08a5ab 100644 --- a/infer/src/java/jTrans.mli +++ b/infer/src/java/jTrans.mli @@ -24,14 +24,14 @@ val is_java_native : JCode.jcode Javalib.concrete_method -> bool (** Create the procedure description for an abstract method *) val create_am_procdesc : - JClasspath.program -> JContext.icfg -> Javalib.abstract_method -> Procname.t -> Procdesc.t + JClasspath.program -> JContext.icfg -> Javalib.abstract_method -> Typ.Procname.t -> Procdesc.t (** Create the procedure description for a concrete method *) val create_native_procdesc : JClasspath.program -> JContext.icfg -> JCode.jcode Javalib.concrete_method -> - Procname.t -> + Typ.Procname.t -> Procdesc.t (** [create_procdesc source_file program linereader icfg cm proc_name] creates @@ -42,7 +42,7 @@ val create_cm_procdesc : Printer.LineReader.t -> JContext.icfg -> JCode.jcode Javalib.concrete_method -> - Procname.t -> + Typ.Procname.t -> (Procdesc.t * Javalib_pack.JCode.jcode * JBir.t) option (** translates an instruction into a statement node or prune nodes in the cfg *) diff --git a/infer/src/java/jTransType.ml b/infer/src/java/jTransType.ml index 6bcc80359..19b6df8b6 100644 --- a/infer/src/java/jTransType.ml +++ b/infer/src/java/jTransType.ml @@ -188,15 +188,15 @@ let method_signature_names ms = let get_method_kind m = if Javalib.is_static_method m - then Procname.Static - else Procname.Non_Static + then Typ.Procname.Static + else Typ.Procname.Non_Static let get_method_procname cn ms method_kind = let return_type_name, method_name, args_type_name = method_signature_names ms in let class_name = Typename.Java.from_string (JBasics.cn_name cn) in let proc_name_java = - Procname.java class_name return_type_name method_name args_type_name method_kind in - Procname.Java proc_name_java + Typ.Procname.java class_name return_type_name method_name args_type_name method_kind in + Typ.Procname.Java proc_name_java (* create a mangled procname from an abstract or concrete method *) let translate_method_name m = diff --git a/infer/src/java/jTransType.mli b/infer/src/java/jTransType.mli index 86946ab71..33adf5b6c 100644 --- a/infer/src/java/jTransType.mli +++ b/infer/src/java/jTransType.mli @@ -22,14 +22,14 @@ val typename_of_classname : JBasics.class_name -> Typename.t (** returns a name for a field based on a class name and a field name *) val create_fieldname : JBasics.class_name -> JBasics.field_signature -> Ident.fieldname -val get_method_kind : JCode.jcode Javalib.jmethod -> Procname.method_kind +val get_method_kind : JCode.jcode Javalib.jmethod -> Typ.Procname.method_kind (** returns a procedure name based on the class name and the method's signature. *) val get_method_procname : - JBasics.class_name -> JBasics.method_signature -> Procname.method_kind -> Procname.t + JBasics.class_name -> JBasics.method_signature -> Typ.Procname.method_kind -> Typ.Procname.t (** translate the SIL procedure name of the Java method *) -val translate_method_name : JCode.jcode Javalib.jmethod -> Procname.t +val translate_method_name : JCode.jcode Javalib.jmethod -> Typ.Procname.t (** [get_class_struct_typ program tenv cn] returns the struct_typ representation of the class *) val get_class_struct_typ: JClasspath.program -> Tenv.t -> JBasics.class_name -> Typ.Struct.t @@ -90,9 +90,9 @@ val string_of_type : JBasics.value_type -> string (** returns a string representation of an object Java type *) val object_type_to_string : JBasics.object_type -> string -val vt_to_java_type : JBasics.value_type -> Procname.java_type +val vt_to_java_type : JBasics.value_type -> Typ.Procname.java_type -val cn_to_java_type : JBasics.class_name -> Procname.java_type +val cn_to_java_type : JBasics.class_name -> Typ.Procname.java_type (** Add the types of the models to the type environment passed as parameter *) val add_models_types : Tenv.t -> unit diff --git a/infer/src/opensource/FbThreadSafety.mli b/infer/src/opensource/FbThreadSafety.mli index a475abecc..6497c5a61 100644 --- a/infer/src/opensource/FbThreadSafety.mli +++ b/infer/src/opensource/FbThreadSafety.mli @@ -9,8 +9,8 @@ open! IStd -val is_custom_init : Tenv.t -> Procname.t -> bool +val is_custom_init : Tenv.t -> Typ.Procname.t -> bool -val is_logging_method : Procname.t -> bool +val is_logging_method : Typ.Procname.t -> bool -val is_graphql_constructor : Procname.t -> bool +val is_graphql_constructor : Typ.Procname.t -> bool diff --git a/infer/src/quandary/ClangTrace.ml b/infer/src/quandary/ClangTrace.ml index 28af117ab..a46a77c44 100644 --- a/infer/src/quandary/ClangTrace.ml +++ b/infer/src/quandary/ClangTrace.ml @@ -23,25 +23,25 @@ module Kind = struct let unknown = Unknown let get pname _ = match pname with - | (Procname.ObjC_Cpp cpp_pname) as pname -> + | (Typ.Procname.ObjC_Cpp cpp_pname) as pname -> begin - match Procname.objc_cpp_get_class_name cpp_pname, Procname.get_method pname with + match Typ.Procname.objc_cpp_get_class_name cpp_pname, Typ.Procname.get_method pname with | "InferTaint", "source" -> Some Other | _ -> None end - | (Procname.C _) as pname -> + | (Typ.Procname.C _) as pname -> begin - match Procname.to_string pname with + match Typ.Procname.to_string pname with | "getenv" -> Some EnvironmentVariable | "__infer_taint_source" -> Some Other | _ -> None end - | Procname.Block _ -> + | Typ.Procname.Block _ -> None | pname when BuiltinDecl.is_declared pname -> None | pname -> - failwithf "Non-C++ procname %a in C++ analysis@." Procname.pp pname + failwithf "Non-C++ procname %a in C++ analysis@." Typ.Procname.pp pname let get_tainted_formals pdesc _ = Source.all_formals_untainted pdesc @@ -67,15 +67,15 @@ module SinkKind = struct ~f:(fun actual_num _ -> kind, actual_num, report_reachable) actuals in match pname with - | (Procname.ObjC_Cpp cpp_pname) as pname -> + | (Typ.Procname.ObjC_Cpp cpp_pname) as pname -> begin - match Procname.objc_cpp_get_class_name cpp_pname, Procname.get_method pname with + match Typ.Procname.objc_cpp_get_class_name cpp_pname, Typ.Procname.get_method pname with | "InferTaint", "sink:" -> taint_all actuals Other ~report_reachable:true | _ -> [] end - | Procname.C _ -> + | Typ.Procname.C _ -> begin - match Procname.to_string pname with + match Typ.Procname.to_string pname with | "execl" | "execlp" | "execle" | "execv" | "execvp" -> taint_all actuals ShellExec ~report_reachable:false | "__infer_taint_sink" -> @@ -83,12 +83,12 @@ module SinkKind = struct | _ -> [] end - | Procname.Block _ -> + | Typ.Procname.Block _ -> [] | pname when BuiltinDecl.is_declared pname -> [] | pname -> - failwithf "Non-C++ procname %a in C++ analysis@." Procname.pp pname + failwithf "Non-C++ procname %a in C++ analysis@." Typ.Procname.pp pname let pp fmt = function | ShellExec -> F.fprintf fmt "ShellExec" diff --git a/infer/src/quandary/JavaTaintAnalysis.ml b/infer/src/quandary/JavaTaintAnalysis.ml index 2aaa937b7..6259e9059 100644 --- a/infer/src/quandary/JavaTaintAnalysis.ml +++ b/infer/src/quandary/JavaTaintAnalysis.ml @@ -33,13 +33,13 @@ include | _ -> false in match pname with - | (Procname.Java java_pname) as pname -> - let is_static = Procname.java_is_static pname in + | (Typ.Procname.Java java_pname) as pname -> + let is_static = Typ.Procname.java_is_static pname in begin - match Procname.java_get_class_name java_pname, - Procname.java_get_method java_pname, + match Typ.Procname.java_get_class_name java_pname, + Typ.Procname.java_get_method java_pname, ret_typ_opt with - | _ when Procname.is_constructor pname -> + | _ when Typ.Procname.is_constructor pname -> [TaintSpec.Propagate_to_receiver] | _, _, (Some Typ.Tvoid | None) when not is_static -> (* for instance methods with no return value, propagate the taint to the receiver *) @@ -63,5 +63,5 @@ include | pname when BuiltinDecl.is_declared pname -> [] | pname -> - failwithf "Non-Java procname %a in Java analysis@." Procname.pp pname + failwithf "Non-Java procname %a in Java analysis@." Typ.Procname.pp pname end) diff --git a/infer/src/quandary/JavaTrace.ml b/infer/src/quandary/JavaTrace.ml index 04fac8a92..e315b9e13 100644 --- a/infer/src/quandary/JavaTrace.ml +++ b/infer/src/quandary/JavaTrace.ml @@ -30,9 +30,9 @@ module SourceKind = struct let external_sources = QuandaryConfig.Source.of_json Config.quandary_sources let get pname tenv = match pname with - | Procname.Java pname -> + | Typ.Procname.Java pname -> begin - match Procname.java_get_class_name pname, Procname.java_get_method pname with + match Typ.Procname.java_get_class_name pname, Typ.Procname.java_get_method pname with | "android.location.Location", ("getAltitude" | "getBearing" | "getLatitude" | "getLongitude" | "getSpeed") -> Some PrivateData @@ -76,7 +76,7 @@ module SourceKind = struct end end | pname when BuiltinDecl.is_declared pname -> None - | pname -> failwithf "Non-Java procname %a in Java analysis@." Procname.pp pname + | pname -> failwithf "Non-Java procname %a in Java analysis@." Typ.Procname.pp pname let get_tainted_formals pdesc tenv = let make_untainted (name, typ) = @@ -97,9 +97,9 @@ module SourceKind = struct let formals = Procdesc.get_formals pdesc in match Procdesc.get_proc_name pdesc with - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with | "codetoanalyze.java.quandary.TaintedFormals", "taintedContextBad" -> taint_formals_with_types ["java.lang.Integer"; "java.lang.String"] Other formals | class_name, method_name -> @@ -122,7 +122,7 @@ module SourceKind = struct | procname -> failwithf "Non-Java procedure %a where only Java procedures are expected" - Procname.pp procname + Typ.Procname.pp procname let pp fmt = function | Intent -> F.fprintf fmt "Intent" @@ -154,7 +154,7 @@ module SinkKind = struct if [taint_this] is true. *) let taint_all ?(taint_this=false) kind ~report_reachable = let actuals_to_taint, offset = - if Procname.java_is_static pname || taint_this + if Typ.Procname.java_is_static pname || taint_this then actuals, 0 else List.tl_exn actuals, 1 in List.mapi @@ -162,12 +162,12 @@ module SinkKind = struct actuals_to_taint in (* taint the nth non-"this" parameter (0-indexed) *) let taint_nth n kind ~report_reachable = - let first_index = if Procname.java_is_static pname then n else n + 1 in + let first_index = if Typ.Procname.java_is_static pname then n else n + 1 in [kind, first_index, report_reachable] in match pname with - | Procname.Java java_pname -> + | Typ.Procname.Java java_pname -> begin - match Procname.java_get_class_name java_pname, Procname.java_get_method java_pname with + match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with | "android.util.Log", ("e" | "println" | "w" | "wtf") -> taint_all Logging ~report_reachable:true | "com.facebook.infer.builtins.InferTaint", "inferSensitiveSink" -> @@ -247,7 +247,7 @@ module SinkKind = struct end | pname when BuiltinDecl.is_declared pname -> [] - | pname -> failwithf "Non-Java procname %a in Java analysis@." Procname.pp pname + | pname -> failwithf "Non-Java procname %a in Java analysis@." Typ.Procname.pp pname let pp fmt = function | Intent -> F.fprintf fmt "Intent" diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index bdb0e43e8..9c0123a85 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -328,7 +328,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct failwithf "Assignment to unexpected lhs expression %a in proc %a at loc %a" Exp.pp lhs_exp - Procname.pp (Procdesc.get_proc_name (proc_data.pdesc)) + Typ.Procname.pp (Procdesc.get_proc_name (proc_data.pdesc)) Location.pp loc in let astate' = analyze_assignment @@ -350,7 +350,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct end | Sil.Call (Some (ret_id, _), Const (Cfun callee_pname), args, loc, _) when BuiltinDecl.is_declared callee_pname -> - if Procname.equal callee_pname BuiltinDecl.__cast + if Typ.Procname.equal callee_pname BuiltinDecl.__cast then match args with | (cast_target, cast_typ) :: _ -> @@ -359,7 +359,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct failwithf "Unexpected cast %a in procedure %a at line %a" (Sil.pp_instr Pp.text) instr - Procname.pp (Procdesc.get_proc_name (proc_data.pdesc)) + Typ.Procname.pp (Procdesc.get_proc_name (proc_data.pdesc)) Location.pp loc else astate @@ -425,7 +425,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct | Some _, None -> L.err "Warning: %a is marked as a source, but has no return value" - Procname.pp callee_pname; + Typ.Procname.pp callee_pname; astate_with_sink | None, _ -> astate_with_sink in @@ -454,7 +454,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct called_pname :: call_flags.cf_targets else begin - L.out "Skipping highly polymorphic call site for %a@." Procname.pp called_pname; + L.out "Skipping highly polymorphic call site for %a@." Typ.Procname.pp called_pname; [called_pname] end in (* for each possible target of the call, apply the summary. join all results together *) diff --git a/infer/src/quandary/TaintSpec.ml b/infer/src/quandary/TaintSpec.ml index 36c987825..30ff6be9c 100644 --- a/infer/src/quandary/TaintSpec.ml +++ b/infer/src/quandary/TaintSpec.ml @@ -23,7 +23,7 @@ module type S = sig (** return a summary for handling an unknown call at the given site with the given return type and actuals *) val handle_unknown_call : - Procname.t -> Typ.t option -> (Exp.t * Typ.t) list -> Tenv.t -> handle_unknown list + Typ.Procname.t -> Typ.t option -> (Exp.t * Typ.t) list -> Tenv.t -> handle_unknown list val to_summary_access_tree : AccessTree.t -> QuandarySummary.AccessTree.t diff --git a/infer/src/unit/BoundedCallTreeTests.ml b/infer/src/unit/BoundedCallTreeTests.ml index 5f550c215..a89b30e24 100644 --- a/infer/src/unit/BoundedCallTreeTests.ml +++ b/infer/src/unit/BoundedCallTreeTests.ml @@ -22,8 +22,8 @@ let tests = let open OUnit2 in let open AnalyzerTester.StructuredSil in let initial = BoundedCallTree.Domain.empty in - let f_proc_name = Procname.from_string_c_fun "f" in - let g_proc_name = Procname.from_string_c_fun "g" in + let f_proc_name = Typ.Procname.from_string_c_fun "f" in + let g_proc_name = Typ.Procname.from_string_c_fun "g" in let g_args = [((Exp.Const (Const.Cint (IntLit.one))), (Typ.Tint IInt))] in let g_ret_id = Some (ident_of_str "r", Typ.Tint IInt) in let class_name = "com.example.SomeClass" in @@ -39,9 +39,9 @@ let tests = [Stacktrace.make_frame class_name "bar" file_name (Some 20)] in let multi_trace_extras = { BoundedCallTree.get_proc_desc = mock_get_proc_desc; stacktraces = [multi_trace_1; multi_trace_2]; } in - let caller_foo_name = Procname.from_string_c_fun "foo" in - let caller_bar_name = Procname.from_string_c_fun "bar" in - let caller_baz_name = Procname.from_string_c_fun "baz" in + let caller_foo_name = Typ.Procname.from_string_c_fun "foo" in + let caller_bar_name = Typ.Procname.from_string_c_fun "bar" in + let caller_baz_name = Typ.Procname.from_string_c_fun "baz" in let test_list_from_foo = [ "on_call_add_proc_name", [ diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index fdc85b0b6..3baff2462 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -19,7 +19,7 @@ module MockTrace = Trace.Make(struct let unknown = CallSite.dummy let get pname _ = - if String.is_prefix ~prefix:"SOURCE" (Procname.to_string pname) + if String.is_prefix ~prefix:"SOURCE" (Typ.Procname.to_string pname) then Some (CallSite.make pname Location.dummy) else None @@ -31,7 +31,7 @@ module MockTrace = Trace.Make(struct include MockTraceElem let get pname _ _ = - if String.is_prefix ~prefix:"SINK" (Procname.to_string pname) + if String.is_prefix ~prefix:"SINK" (Typ.Procname.to_string pname) then [CallSite.make pname Location.dummy, 0, false] else [] end) @@ -56,7 +56,7 @@ let tests = (* less verbose form of pretty-printing to make writing tests easy *) let pp_sparse fmt astate = let pp_call_site fmt call_site = - F.fprintf fmt "%a" Procname.pp (CallSite.pname call_site) in + F.fprintf fmt "%a" Typ.Procname.pp (CallSite.pname call_site) in let pp_sources fmt sources = if MockTrace.Sources.is_empty sources then F.fprintf fmt "?" @@ -92,13 +92,13 @@ let tests = [] 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 + let procname = Typ.Procname.from_string_c_fun "SOURCE" in make_call ~procname (Some (ident_of_str ret_str, dummy_typ)) [] in let assign_to_non_source ret_str = - let procname = Procname.from_string_c_fun "NON-SOURCE" in + let procname = Typ.Procname.from_string_c_fun "NON-SOURCE" in make_call ~procname (Some (ident_of_str ret_str, dummy_typ)) [] in let call_sink_with_exp exp = - let procname = Procname.from_string_c_fun "SINK" in + let procname = Typ.Procname.from_string_c_fun "SINK" in make_call ~procname None [(exp, dummy_typ)] in let call_sink actual_str = call_sink_with_exp (Exp.Var (ident_of_str actual_str)) in diff --git a/infer/src/unit/accessPathTestUtils.ml b/infer/src/unit/accessPathTestUtils.ml index b97216e84..978bfada7 100644 --- a/infer/src/unit/accessPathTestUtils.ml +++ b/infer/src/unit/accessPathTestUtils.ml @@ -10,7 +10,7 @@ open! IStd let make_var var_str = - Pvar.mk (Mangled.from_string var_str) Procname.empty_block + Pvar.mk (Mangled.from_string var_str) Typ.Procname.empty_block let make_base ?(typ=Typ.Tvoid) base_str = AccessPath.base_of_pvar (make_var base_str) typ diff --git a/infer/src/unit/analyzerTester.ml b/infer/src/unit/analyzerTester.ml index d72752df4..42ba56017 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -61,7 +61,7 @@ module StructuredSil = struct let dummy_typ = Typ.Tvoid let dummy_loc = Location.dummy - let dummy_procname = Procname.empty_block + let dummy_procname = Typ.Procname.empty_block let label_counter = ref 0 @@ -276,7 +276,7 @@ module Make (CFG : ProcCfg.S with type node = Procdesc.Node.t) (T : TransferFunc |> F.flush_str_formatter in OUnit2.assert_failure assert_fail_message - let create_tests ?(test_pname=Procname.empty_block) ~initial ?pp_opt extras tests = + let create_tests ?(test_pname=Typ.Procname.empty_block) ~initial ?pp_opt extras tests = let open OUnit2 in List.map ~f:(fun (name, test_program) -> name>::create_test test_program extras ~initial pp_opt test_pname) tests diff --git a/infer/src/unit/procCfgTests.ml b/infer/src/unit/procCfgTests.ml index 6d72d526b..46dfd3142 100644 --- a/infer/src/unit/procCfgTests.ml +++ b/infer/src/unit/procCfgTests.ml @@ -18,7 +18,7 @@ module BackwardInstrCfg = ProcCfg.Backward (InstrCfg) let tests = let cfg = Cfg.create_cfg () in let test_pdesc = - Cfg.create_proc_desc cfg (ProcAttributes.default Procname.empty_block !Config.curr_language) in + Cfg.create_proc_desc cfg (ProcAttributes.default Typ.Procname.empty_block !Config.curr_language) in let dummy_instr1 = Sil.Remove_temps ([], Location.dummy) in let dummy_instr2 = Sil.Abstract Location.dummy in let dummy_instr3 = Sil.Remove_temps ([Ident.create_fresh Ident.knormal], Location.dummy) in