diff --git a/infer/src/IR/Attributes.ml b/infer/src/IR/Attributes.ml index af752cf77..500fd59a0 100644 --- a/infer/src/IR/Attributes.ml +++ b/infer/src/IR/Attributes.ml @@ -33,10 +33,10 @@ let proc_kind_of_attr (proc_attributes : ProcAttributes.t) = let replace pname pname_blob akind source_file attributes proc_desc callees = - let pname_str = Typ.Procname.to_string pname in + let pname_str = Procname.to_string pname in let akind_int64 = int64_of_attributes_kind akind in let proc_desc_blob = Procdesc.SQLite.serialize proc_desc in - let callees_blob = Typ.Procname.SQLiteList.serialize callees in + let callees_blob = Procname.SQLiteList.serialize callees in DBWriter.replace_attributes ~pname_str ~pname:pname_blob ~akind:akind_int64 ~source_file ~attributes ~proc_desc:proc_desc_blob ~callees:callees_blob @@ -82,11 +82,11 @@ let find ~defined pname_blob = |> Option.map ~f:ProcAttributes.SQLite.deserialize ) -let load pname = Typ.Procname.SQLite.serialize pname |> find ~defined:false +let load pname = Procname.SQLite.serialize pname |> find ~defined:false let store ~proc_desc (attr : ProcAttributes.t) = let pkind = proc_kind_of_attr attr in - let key = Typ.Procname.SQLite.serialize attr.proc_name in + let key = Procname.SQLite.serialize attr.proc_name in if should_try_to_update key pkind then replace attr.proc_name key pkind (SourceFile.SQLite.serialize attr.loc.Location.file) @@ -95,7 +95,7 @@ let store ~proc_desc (attr : ProcAttributes.t) = (Option.map proc_desc ~f:Procdesc.get_static_callees |> Option.value ~default:[]) -let load_defined pname = Typ.Procname.SQLite.serialize pname |> find ~defined:true +let load_defined pname = Procname.SQLite.serialize pname |> find ~defined:true let find_file_capturing_procedure pname = Option.map (load pname) ~f:(fun proc_attributes -> diff --git a/infer/src/IR/Attributes.mli b/infer/src/IR/Attributes.mli index a3703125d..232f5c528 100644 --- a/infer/src/IR/Attributes.mli +++ b/infer/src/IR/Attributes.mli @@ -16,13 +16,13 @@ val deserialize_attributes_kind : Sqlite3.Data.t -> attributes_kind val store : proc_desc:Procdesc.t option -> ProcAttributes.t -> unit (** Save .attr file for the procedure into the attributes database. *) -val load : Typ.Procname.t -> ProcAttributes.t option +val load : Procname.t -> ProcAttributes.t option (** Load the attributes for the procedure from the attributes database. *) -val load_defined : Typ.Procname.t -> ProcAttributes.t option +val load_defined : Procname.t -> ProcAttributes.t option (** Load attributes for the procedure but only if is_defined is true *) -val find_file_capturing_procedure : Typ.Procname.t -> (SourceFile.t * [`Include | `Source]) option +val find_file_capturing_procedure : Procname.t -> (SourceFile.t * [`Include | `Source]) option (** 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. *) diff --git a/infer/src/IR/BuiltinDecl.ml b/infer/src/IR/BuiltinDecl.ml index 6ca0c835a..efa06211d 100644 --- a/infer/src/IR/BuiltinDecl.ml +++ b/infer/src/IR/BuiltinDecl.ml @@ -7,28 +7,28 @@ open! IStd -type t = Typ.Procname.t +type t = Procname.t -let builtin_decls = ref Typ.Procname.Set.empty +let builtin_decls = ref Procname.Set.empty -let register pname = builtin_decls := Typ.Procname.Set.add pname !builtin_decls +let register pname = builtin_decls := Procname.Set.add pname !builtin_decls let create_procname name = - let pname = Typ.Procname.from_string_c_fun name in + let pname = Procname.from_string_c_fun name in register pname ; pname let create_objc_class_method class_name method_name parameters = - let method_kind = Typ.Procname.ObjC_Cpp.ObjCClassMethod in + let method_kind = Procname.ObjC_Cpp.ObjCClassMethod in let tname = Typ.Name.Objc.from_string class_name in let pname = - Typ.Procname.ObjC_Cpp - (Typ.Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate parameters) + Procname.ObjC_Cpp + (Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate parameters) in register pname ; pname -let is_declared pname = Typ.Procname.Set.mem pname !builtin_decls +let is_declared pname = Procname.Set.mem pname !builtin_decls let __array_access = create_procname "__array_access" diff --git a/infer/src/IR/BuiltinDecl.mli b/infer/src/IR/BuiltinDecl.mli index 5a7282f9b..ab78793e0 100644 --- a/infer/src/IR/BuiltinDecl.mli +++ b/infer/src/IR/BuiltinDecl.mli @@ -9,6 +9,6 @@ open! IStd (** Procnames for the builtin functions supported *) -include BUILTINS.S with type t = Typ.Procname.t +include BUILTINS.S with type t = Procname.t -val is_declared : Typ.Procname.t -> bool +val is_declared : Procname.t -> bool diff --git a/infer/src/IR/CallSite.ml b/infer/src/IR/CallSite.ml index 2760c8edd..1b8020738 100644 --- a/infer/src/IR/CallSite.ml +++ b/infer/src/IR/CallSite.ml @@ -8,7 +8,7 @@ open! IStd module F = Format -type t = {pname: Typ.Procname.t; loc: Location.t} [@@deriving compare] +type t = {pname: Procname.t; loc: Location.t} [@@deriving compare] let equal = [%compare.equal: t] @@ -18,9 +18,9 @@ let loc t = t.loc let make pname loc = {pname; loc} -let dummy = make Typ.Procname.empty_block Location.dummy +let dummy = make Procname.empty_block Location.dummy -let pp fmt t = F.fprintf fmt "%a at %a" Typ.Procname.pp t.pname Location.pp t.loc +let pp fmt t = F.fprintf fmt "%a at %a" 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 a3eebcf02..233cd7f88 100644 --- a/infer/src/IR/CallSite.mli +++ b/infer/src/IR/CallSite.mli @@ -12,11 +12,11 @@ type t [@@deriving compare] val equal : t -> t -> bool -val pname : t -> Typ.Procname.t +val pname : t -> Procname.t val loc : t -> Location.t -val make : Typ.Procname.t -> Location.t -> t +val make : Procname.t -> Location.t -> t val dummy : t diff --git a/infer/src/IR/Cfg.ml b/infer/src/IR/Cfg.ml index 5ae9e83c7..a42d6e4ba 100644 --- a/infer/src/IR/Cfg.ml +++ b/infer/src/IR/Cfg.ml @@ -11,15 +11,15 @@ module L = Logging module F = Format (** data type for the control flow graph *) -type t = Procdesc.t Typ.Procname.Hash.t +type t = Procdesc.t Procname.Hash.t -let create () = Typ.Procname.Hash.create 16 +let create () = Procname.Hash.create 16 let iter_over_sorted_procs cfg ~f = let compare_proc_desc_by_proc_name pdesc1 pdesc2 = - Typ.Procname.compare (Procdesc.get_proc_name pdesc1) (Procdesc.get_proc_name pdesc2) + Procname.compare (Procdesc.get_proc_name pdesc1) (Procdesc.get_proc_name pdesc2) in - Typ.Procname.Hash.fold (fun _ pdesc acc -> pdesc :: acc) cfg [] + Procname.Hash.fold (fun _ pdesc acc -> pdesc :: acc) cfg [] |> List.sort ~compare:compare_proc_desc_by_proc_name |> List.iter ~f @@ -27,16 +27,16 @@ let iter_over_sorted_procs cfg ~f = let get_all_defined_proc_names cfg = let procs = ref [] in let f pname pdesc = if Procdesc.is_defined pdesc then procs := pname :: !procs in - Typ.Procname.Hash.iter f cfg ; !procs + Procname.Hash.iter f cfg ; !procs (** Create a new procdesc *) let create_proc_desc cfg (proc_attributes : ProcAttributes.t) = let pdesc = Procdesc.from_proc_attributes proc_attributes in let pname = proc_attributes.proc_name in - if Typ.Procname.Hash.mem cfg pname then + if Procname.Hash.mem cfg pname then L.die InternalError "Creating two procdescs for the same procname." ; - Typ.Procname.Hash.add cfg pname pdesc ; + Procname.Hash.add cfg pname pdesc ; pdesc @@ -53,7 +53,7 @@ let store source_file cfg = Procdesc.set_attributes proc_desc attributes' ; Attributes.store ~proc_desc:(Some proc_desc) attributes' in - Typ.Procname.Hash.iter save_proc cfg + Procname.Hash.iter save_proc cfg (** Inline a synthetic (access or bridge) method. *) @@ -121,11 +121,10 @@ let inline_synthetic_method ((ret_id, _) as ret) etl pdesc loc_call : Sil.instr let proc_inline_synthetic_methods cfg pdesc : unit = let instr_inline_synthetic_method _node instr = match instr with - | Sil.Call (ret_id_typ, Exp.Const (Const.Cfun (Typ.Procname.Java java_pn as pn)), etl, loc, _) - -> ( - match Typ.Procname.Hash.find cfg pn with + | Sil.Call (ret_id_typ, Exp.Const (Const.Cfun (Procname.Java java_pn as pn)), etl, loc, _) -> ( + match Procname.Hash.find cfg pn with | pd -> - let is_access = Typ.Procname.Java.is_access_method java_pn in + let is_access = Procname.Java.is_access_method java_pn in let attributes = Procdesc.get_attributes pd in let is_synthetic = attributes.is_synthetic_method in let is_bridge = attributes.is_bridge_method in @@ -142,8 +141,8 @@ let proc_inline_synthetic_methods cfg pdesc : unit = let inline_java_synthetic_methods cfg = - let f pname pdesc = if Typ.Procname.is_java pname then proc_inline_synthetic_methods cfg pdesc in - Typ.Procname.Hash.iter f cfg + let f pname pdesc = if Procname.is_java pname then proc_inline_synthetic_methods cfg pdesc in + Procname.Hash.iter f cfg let pp_proc_signatures fmt cfg = diff --git a/infer/src/IR/Cfg.mli b/infer/src/IR/Cfg.mli index 7112dfead..8aa99e88e 100644 --- a/infer/src/IR/Cfg.mli +++ b/infer/src/IR/Cfg.mli @@ -11,9 +11,9 @@ open! IStd (** Control Flow Graph for Interprocedural Analysis *) (** A control-flow graph is a collection of all the CFGs for the procedure names in a file *) -type t = Procdesc.t Typ.Procname.Hash.t +type t = Procdesc.t Procname.Hash.t -val get_all_defined_proc_names : t -> Typ.Procname.t list +val get_all_defined_proc_names : t -> Procname.t list (** get all the procedure names that are defined in the current file *) val store : SourceFile.t -> t -> unit diff --git a/infer/src/IR/Const.ml b/infer/src/IR/Const.ml index 68623ba85..51d94edbe 100644 --- a/infer/src/IR/Const.ml +++ b/infer/src/IR/Const.ml @@ -13,7 +13,7 @@ module F = Format type t = | Cint of IntLit.t (** integer constants *) - | Cfun of Typ.Procname.t (** function names *) + | Cfun of Procname.t (** function names *) | Cstr of string (** string constants *) | Cfloat of float (** float constants *) | Cclass of Ident.name (** class constant *) @@ -43,9 +43,9 @@ let pp pe f = function | Cfun fn -> ( match pe.Pp.kind with | HTML -> - F.fprintf f "_fun_%s" (Escape.escape_xml (F.asprintf "%a" Typ.Procname.pp fn)) + F.fprintf f "_fun_%s" (Escape.escape_xml (F.asprintf "%a" Procname.pp fn)) | _ -> - F.fprintf f "_fun_%a" Typ.Procname.pp fn ) + F.fprintf f "_fun_%a" Procname.pp fn ) | Cstr s -> F.fprintf f "\"%s\"" (String.escaped s) | Cfloat v -> diff --git a/infer/src/IR/Const.mli b/infer/src/IR/Const.mli index b40a15d65..0f182ab93 100644 --- a/infer/src/IR/Const.mli +++ b/infer/src/IR/Const.mli @@ -14,7 +14,7 @@ module F = Format (** Constants *) type t = | Cint of IntLit.t (** integer constants *) - | Cfun of Typ.Procname.t (** function names *) + | Cfun of Procname.t (** function names *) | Cstr of string (** string constants *) | Cfloat of float (** float constants *) | Cclass of Ident.name (** class constant *) diff --git a/infer/src/IR/DecompiledExp.ml b/infer/src/IR/DecompiledExp.ml index 54cc13828..b7a809d11 100644 --- a/infer/src/IR/DecompiledExp.ml +++ b/infer/src/IR/DecompiledExp.ml @@ -38,7 +38,7 @@ let split_var_clang var_name = let builtin_functions_to_string pn = - if Typ.Procname.equal pn BuiltinDecl.__objc_alloc_no_fail then Some "alloc" else None + if Procname.equal pn BuiltinDecl.__objc_alloc_no_fail then Some "alloc" else None let rec pp fmt = function @@ -51,10 +51,10 @@ let rec pp fmt = function | Some str -> F.pp_print_string fmt str | None -> ( - let procname_str = Typ.Procname.to_simplified_string pn in + let procname_str = Procname.to_simplified_string pn in match pn with - | Typ.Procname.ObjC_Cpp {kind= ObjCInstanceMethod} - | Typ.Procname.ObjC_Cpp {kind= ObjCClassMethod} -> ( + | Procname.ObjC_Cpp {kind= ObjCInstanceMethod} | Procname.ObjC_Cpp {kind= ObjCClassMethod} + -> ( match String.lsplit2 ~on:':' procname_str with | Some (base_name, _) -> F.pp_print_string fmt base_name @@ -75,10 +75,10 @@ let rec pp fmt = function | Dconst (Cfun pname) -> let s = match pname with - | Typ.Procname.Java pname_java -> - Typ.Procname.Java.get_method pname_java + | Procname.Java pname_java -> + Procname.Java.get_method pname_java | _ -> - Typ.Procname.to_string pname + Procname.to_string pname in F.pp_print_string fmt s | de -> diff --git a/infer/src/IR/DotCfg.ml b/infer/src/IR/DotCfg.ml index b2aee3f19..fa7019973 100644 --- a/infer/src/IR/DotCfg.ml +++ b/infer/src/IR/DotCfg.ml @@ -11,7 +11,7 @@ module F = Format let pp_cfgnodename pname fmt (n : Procdesc.Node.t) = F.fprintf fmt "\"%s_%d\"" - (Escape.escape_dotty (Typ.Procname.to_filename pname)) + (Escape.escape_dotty (Procname.to_filename pname)) (Procdesc.Node.get_id n :> int) @@ -32,7 +32,7 @@ let pp_cfgnodelabel pdesc fmt (n : Procdesc.Node.t) = match Procdesc.Node.get_kind n with | Start_node -> let pname = Procdesc.Node.get_proc_name n in - let pname_string = Escape.escape_dotty (Typ.Procname.to_string pname) in + let pname_string = Escape.escape_dotty (Procname.to_string pname) in let attributes = Procdesc.get_attributes pdesc in Format.fprintf fmt "Start %s\\nFormals: %a\\nLocals: %a" pname_string pp_etlist (Procdesc.get_formals pdesc) pp_local_list (Procdesc.get_locals pdesc) ; @@ -43,7 +43,7 @@ let pp_cfgnodelabel pdesc fmt (n : Procdesc.Node.t) = Format.fprintf fmt "\\nAnnotation: %a" (Annot.Method.pp pname_string) method_annotation | Exit_node -> let pname = Procdesc.Node.get_proc_name n in - Format.fprintf fmt "Exit %s" (Escape.escape_dotty (Typ.Procname.to_string pname)) + Format.fprintf fmt "Exit %s" (Escape.escape_dotty (Procname.to_string pname)) | Join_node -> Format.pp_print_char fmt '+' | Prune_node (is_true_branch, if_kind, _) -> @@ -135,7 +135,7 @@ let emit_proc_desc source proc_desc = let filename = let db_name = DB.Results_dir.path_to_filename (DB.Results_dir.Abs_source_dir source) - [Typ.Procname.to_filename (Procdesc.get_proc_name proc_desc)] + [Procname.to_filename (Procdesc.get_proc_name proc_desc)] in DB.filename_to_string db_name ^ ".dot" in diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index aed1d8951..7e974eb48 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -13,8 +13,8 @@ module F = Format type node_tag = | Condition of bool | Exception of Typ.name - | Procedure_start of Typ.Procname.t - | Procedure_end of Typ.Procname.t + | Procedure_start of Procname.t + | Procedure_end of Procname.t (** Element of a loc trace *) type loc_trace_elem = @@ -261,7 +261,7 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ in ( if exn_developer then let issue = - let lang = Typ.Procname.get_language procname in + let lang = Procname.get_language procname in let clang_method_kind = match lang with | Language.Clang -> @@ -275,7 +275,7 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ ; clang_method_kind ; exception_triggered_location= error.ocaml_pos ; lang= Language.to_explicit_string lang - ; procedure_name= Typ.Procname.to_string procname + ; procedure_name= Procname.to_string procname ; source_location= loc } in EventLogger.log issue ) ; diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 5dab14942..bef0024d4 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -12,8 +12,8 @@ open! IStd type node_tag = | Condition of bool | Exception of Typ.name - | Procedure_start of Typ.Procname.t - | Procedure_end of Typ.Procname.t + | Procedure_start of Procname.t + | Procedure_end of Procname.t (** Element of a loc trace *) type loc_trace_elem = private @@ -109,7 +109,7 @@ val update : t -> t -> unit (** Update an old error log with a new one *) val log_issue : - Typ.Procname.t + Procname.t -> clang_method_kind:ClangMethodKind.t option -> Exceptions.severity -> t diff --git a/infer/src/IR/Exp.ml b/infer/src/IR/Exp.ml index 1cb1f2bc0..2780e80c5 100644 --- a/infer/src/IR/Exp.ml +++ b/infer/src/IR/Exp.ml @@ -18,7 +18,7 @@ type ident_ = Ident.t let compare_ident_ x y = Ident.compare y x -type closure = {name: Typ.Procname.t; captured_vars: (t * Pvar.t * Typ.t) list} +type closure = {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t) list} (** This records information about a [sizeof(typ)] expression. @@ -319,12 +319,7 @@ let pp_texp_full pe f = function (** Dump a type expression with all the details. *) let d_texp_full (te : t) = L.d_pp_with_pe pp_texp_full te -let is_objc_block_closure = function - | Closure {name} -> - Typ.Procname.is_objc_block name - | _ -> - false - +let is_objc_block_closure = function Closure {name} -> Procname.is_objc_block name | _ -> false let rec gen_free_vars = let open Sequence.Generator in @@ -416,11 +411,7 @@ let rec get_java_class_initializer tenv = function match Struct.get_field_type_and_annotation ~lookup:(Tenv.lookup tenv) fn typ with | Some (field_typ, annot) when Annot.Item.is_final annot -> let java_class = Typ.JavaClass (Pvar.get_name pvar) in - Some - ( Typ.Procname.Java (Typ.Procname.Java.get_class_initializer java_class) - , pvar - , fn - , field_typ ) + Some (Procname.Java (Procname.Java.get_class_initializer java_class), pvar, fn, field_typ) | _ -> None ) | Cast (_, e) | Lfield (e, _, _) -> diff --git a/infer/src/IR/Exp.mli b/infer/src/IR/Exp.mli index a673aeae9..43901103c 100644 --- a/infer/src/IR/Exp.mli +++ b/infer/src/IR/Exp.mli @@ -13,7 +13,7 @@ open! IStd module F = Format -type closure = {name: Typ.Procname.t; captured_vars: (t * Pvar.t * Typ.t) list} +type closure = {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t) list} (** This records information about a [sizeof(typ)] expression. @@ -170,6 +170,5 @@ val ignore_cast : t -> t val ignore_integer_cast : t -> t -val get_java_class_initializer : - Tenv.t -> t -> (Typ.Procname.t * Pvar.t * Fieldname.t * Typ.t) option +val get_java_class_initializer : Tenv.t -> t -> (Procname.t * Pvar.t * Fieldname.t * Typ.t) option (** Returns the class initializer of the given expression in Java *) diff --git a/infer/src/IR/Filtering.ml b/infer/src/IR/Filtering.ml index 3b9ab4013..e0c44e556 100644 --- a/infer/src/IR/Filtering.ml +++ b/infer/src/IR/Filtering.ml @@ -8,7 +8,7 @@ open! IStd type source_files_filter = SourceFile.t -> bool -type procedures_filter = SourceFile.t -> Typ.Procname.t -> bool +type procedures_filter = SourceFile.t -> Procname.t -> bool let filter_of_regexp_opt ~to_string r = match r with @@ -44,7 +44,7 @@ let mk_procedure_name_filter ~filter = let source_file_filter = filter_of_regexp_opt ~to_string:SourceFile.to_string source_file_regexp in - let proc_name_filter = filter_of_regexp_opt ~to_string:Typ.Procname.to_string proc_name_regexp in + let proc_name_filter = filter_of_regexp_opt ~to_string:Procname.to_string proc_name_regexp in source_file_filter &&& proc_name_filter diff --git a/infer/src/IR/Filtering.mli b/infer/src/IR/Filtering.mli index 1968640d0..871e4d41e 100644 --- a/infer/src/IR/Filtering.mli +++ b/infer/src/IR/Filtering.mli @@ -9,7 +9,7 @@ open! IStd type source_files_filter = SourceFile.t -> bool -type procedures_filter = SourceFile.t -> Typ.Procname.t -> bool +type procedures_filter = SourceFile.t -> Procname.t -> bool val source_files_filter : source_files_filter Lazy.t (** filter corresponding to `--source-files-filter` *) diff --git a/infer/src/IR/HilExp.ml b/infer/src/IR/HilExp.ml index 9fb0fd58d..45fac332b 100644 --- a/infer/src/IR/HilExp.ml +++ b/infer/src/IR/HilExp.ml @@ -48,7 +48,7 @@ module T : sig | UnaryOperator of Unop.t * t * Typ.t option | BinaryOperator of Binop.t * t * t | Exception of t - | Closure of Typ.Procname.t * (AccessPath.base * t) list + | Closure of Procname.t * (AccessPath.base * t) list | Constant of Const.t | Cast of Typ.t * t | Sizeof of Typ.t * t option @@ -83,7 +83,7 @@ end = struct | UnaryOperator of Unop.t * t * Typ.t option | BinaryOperator of Binop.t * t * t | Exception of t - | Closure of Typ.Procname.t * (AccessPath.base * t) list + | Closure of Procname.t * (AccessPath.base * t) list | Constant of Const.t | Cast of Typ.t * t | Sizeof of Typ.t * t option @@ -181,7 +181,7 @@ and pp fmt = function | _ -> F.fprintf fmt "%a captured as %a" AccessPath.pp_base base pp exp in - F.fprintf fmt "closure(%a, %a)" Typ.Procname.pp pname + F.fprintf fmt "closure(%a, %a)" Procname.pp pname (PrettyPrintable.pp_collection ~pp_item) captured | Constant c -> diff --git a/infer/src/IR/HilExp.mli b/infer/src/IR/HilExp.mli index f2907bd3c..4214fa86a 100644 --- a/infer/src/IR/HilExp.mli +++ b/infer/src/IR/HilExp.mli @@ -27,7 +27,7 @@ type t = (** Unary operator with type of the result if known *) | BinaryOperator of Binop.t * t * t (** Binary operator *) | Exception of t (** Exception *) - | Closure of Typ.Procname.t * (AccessPath.base * t) list (** Name of function + environment *) + | Closure of Procname.t * (AccessPath.base * t) list (** Name of function + environment *) | Constant of Const.t (** Constants *) | Cast of Typ.t * t (** Type cast *) | Sizeof of Typ.t * t option diff --git a/infer/src/IR/HilInstr.ml b/infer/src/IR/HilInstr.ml index 21ac14bb5..5f164574d 100644 --- a/infer/src/IR/HilInstr.ml +++ b/infer/src/IR/HilInstr.ml @@ -9,11 +9,11 @@ open! IStd module F = Format module L = Logging -type call = Direct of Typ.Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare] +type call = Direct of Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare] let pp_call fmt = function | Direct pname -> - Typ.Procname.pp fmt pname + Procname.pp fmt pname | Indirect access_expr -> F.fprintf fmt "*%a" HilExp.AccessExpression.pp access_expr @@ -70,7 +70,7 @@ let of_sil ~include_array_indexes ~f_resolve_id (instr : Sil.instr) = , (target_exp, _) :: (Sizeof {typ= cast_typ}, _) :: _ , loc , _ ) - when Typ.Procname.equal callee_pname BuiltinDecl.__cast -> + when Procname.equal callee_pname BuiltinDecl.__cast -> analyze_id_assignment (Var.of_id ret_id) target_exp cast_typ loc | Store {e1= lhs_exp; typ; e2= rhs_exp; loc} -> let lhs_access_expr = diff --git a/infer/src/IR/HilInstr.mli b/infer/src/IR/HilInstr.mli index f5b81a56e..15c55bdda 100644 --- a/infer/src/IR/HilInstr.mli +++ b/infer/src/IR/HilInstr.mli @@ -9,7 +9,7 @@ open! IStd module F = Format (** type of a procedure call; either direct or via function pointer *) -type call = Direct of Typ.Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare] +type call = Direct of Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare] val pp_call : F.formatter -> call -> unit [@@warning "-32"] diff --git a/infer/src/IR/Io_infer.ml b/infer/src/IR/Io_infer.ml index e05bbe0bb..32ff31a97 100644 --- a/infer/src/IR/Io_infer.ml +++ b/infer/src/IR/Io_infer.ml @@ -109,7 +109,7 @@ h1 { font-size:14pt } (** File name for the node, given the procedure name and node id *) - let node_filename pname id = F.sprintf "%s_node%d" (Typ.Procname.to_filename pname) id + let node_filename pname id = F.sprintf "%s_node%d" (Procname.to_filename pname) id (** Print an html link to the given node. *) let pp_node_link path_to_root pname ~description ~preds ~succs ~exn ~isvisited fmt id = @@ -129,7 +129,7 @@ h1 { font-size:14pt } (** 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 @ [Typ.Procname.to_filename proc_name]) fmt text + pp_link ~path:(path_to_root @ [Procname.to_filename proc_name]) fmt text (** Print an html link to the given line number of the current source file *) diff --git a/infer/src/IR/Io_infer.mli b/infer/src/IR/Io_infer.mli index 39e60f5d5..9fc579868 100644 --- a/infer/src/IR/Io_infer.mli +++ b/infer/src/IR/Io_infer.mli @@ -20,7 +20,7 @@ module Html : sig val modified_during_analysis : SourceFile.t -> DB.Results_dir.path -> bool (** Return true if the html file was modified since the beginning of the analysis *) - val node_filename : Typ.Procname.t -> int -> string + val node_filename : Procname.t -> int -> string (** File name for the node, given the procedure name and node id *) val open_out : SourceFile.t -> DB.Results_dir.path -> Unix.File_descr.t * Format.formatter @@ -41,7 +41,7 @@ module Html : sig val pp_node_link : DB.Results_dir.path - -> Typ.Procname.t + -> Procname.t -> description:string -> preds:int list -> succs:int list @@ -54,12 +54,12 @@ 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_proc_link : DB.Results_dir.path -> Typ.Procname.t -> Format.formatter -> string -> unit + val pp_proc_link : DB.Results_dir.path -> Procname.t -> Format.formatter -> string -> unit (** Print an html link to the given proc *) val pp_session_link : ?with_name:bool - -> ?proc_name:Typ.Procname.t + -> ?proc_name:Procname.t -> SourceFile.t -> string list -> Format.formatter diff --git a/infer/src/IR/IssueLog.ml b/infer/src/IR/IssueLog.ml index 444a4adb9..0932826d9 100644 --- a/infer/src/IR/IssueLog.ml +++ b/infer/src/IR/IssueLog.ml @@ -9,28 +9,28 @@ open! IStd -type t = Errlog.t Typ.Procname.Map.t +type t = Errlog.t Procname.Map.t -let empty = Typ.Procname.Map.empty +let empty = Procname.Map.empty let get_or_add ~proc m = - match Typ.Procname.Map.find_opt proc m with + match Procname.Map.find_opt proc m with | Some errlog -> (m, errlog) | None -> let errlog = Errlog.empty () in - let m = Typ.Procname.Map.add proc errlog m in + let m = Procname.Map.add proc errlog m in (m, errlog) -let issues_serializer : Errlog.t Typ.Procname.Map.t Serialization.serializer = +let issues_serializer : Errlog.t Procname.Map.t Serialization.serializer = Serialization.create_serializer Serialization.Key.issues -let iter ~f m = Typ.Procname.Map.iter f m +let iter ~f m = Procname.Map.iter f m let store ~dir ~file m = - if not (Typ.Procname.Map.is_empty m) then ( + if not (Procname.Map.is_empty m) then ( let abbrev_source_file = DB.source_file_encoding file in let issues_dir = Config.results_dir ^/ dir in Utils.create_dir issues_dir ; @@ -51,7 +51,7 @@ let load dir = let file = DB.filename_from_string (Filename.concat issues_dir issues_file) in load_issues file |> Option.fold ~init ~f:(fun acc map -> - Typ.Procname.Map.merge + Procname.Map.merge (fun _ issues1 issues2 -> match (issues1, issues2) with | Some issues1, Some issues2 -> diff --git a/infer/src/IR/IssueLog.mli b/infer/src/IR/IssueLog.mli index ac772126a..cb1bf9487 100644 --- a/infer/src/IR/IssueLog.mli +++ b/infer/src/IR/IssueLog.mli @@ -12,10 +12,10 @@ type t val empty : t -val iter : f:(Typ.Procname.t -> Errlog.t -> unit) -> t -> unit +val iter : f:(Procname.t -> Errlog.t -> unit) -> t -> unit (** iterate a function on map contents *) -val get_or_add : proc:Typ.Procname.t -> t -> t * Errlog.t +val get_or_add : proc:Procname.t -> t -> t * Errlog.t (** Get the error log for a given procname. If there is none, add an empty one to the map. Return the resulting map together with the errlog. *) diff --git a/infer/src/IR/Localise.ml b/infer/src/IR/Localise.ml index 41168ca8d..8c4aa76b2 100644 --- a/infer/src/IR/Localise.ml +++ b/infer/src/IR/Localise.ml @@ -138,7 +138,7 @@ let line_ tags loc = line_tag_ tags Tags.line loc let at_line tags loc = at_line_tag tags Tags.line loc let call_to proc_name = - let proc_name_str = Typ.Procname.to_simplified_string proc_name in + let proc_name_str = Procname.to_simplified_string proc_name in "call to " ^ MF.monospaced_to_string proc_name_str @@ -203,14 +203,14 @@ let deref_str_nullable proc_name_opt nullable_obj_str = (** dereference strings for nonterminal nil arguments in c/objc variadic methods *) let deref_str_nil_argument_in_variadic_method pn total_args arg_number = let function_method, nil_null = - if Typ.Procname.is_c_method pn then ("method", "nil") else ("function", "null") + if 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 - (Typ.Procname.to_simplified_string pn) + (Procname.to_simplified_string pn) arg_number (total_args - 1) nil_null function_method in deref_str_null_ None problem_str @@ -219,7 +219,7 @@ let deref_str_nil_argument_in_variadic_method pn total_args arg_number = (** 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 = Typ.Procname.to_simplified_string proc_name in + let proc_name_str = Procname.to_simplified_string proc_name in { tags ; value_pre= Some (pointer_or_object ()) ; value_post= None @@ -345,7 +345,7 @@ let nullable_annotation_name proc_name = match Config.nullable_annotation with | Some name -> name - | None when Typ.Procname.is_java proc_name -> + | None when Procname.is_java proc_name -> "@Nullable" | None (* default Clang annotation name *) -> "_Nullable" @@ -460,11 +460,11 @@ let desc_allocation_mismatch alloc dealloc = let tags = Tags.create () in let using (primitive_pname, called_pname, loc) = let by_call = - if Typ.Procname.equal primitive_pname called_pname then "" - else " by call to " ^ MF.monospaced_to_string (Typ.Procname.to_simplified_string called_pname) + if Procname.equal primitive_pname called_pname then "" + else " by call to " ^ MF.monospaced_to_string (Procname.to_simplified_string called_pname) in "using " - ^ MF.monospaced_to_string (Typ.Procname.to_simplified_string primitive_pname) + ^ MF.monospaced_to_string (Procname.to_simplified_string primitive_pname) ^ by_call ^ " " ^ at_line (Tags.create ()) (* ignore the tag *) loc in @@ -688,13 +688,13 @@ 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 = Typ.Procname.to_string proc_name in + let proc_name_str = Procname.to_string proc_name in Tags.update 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 = Typ.Procname.to_string proc_name in + let proc_name_str = Procname.to_string proc_name in let tags = Tags.create () in Tags.update tags Tags.value proc_name_str ; {no_desc with descriptions= [MF.monospaced_to_string proc_name_str]; tags= !tags} diff --git a/infer/src/IR/Localise.mli b/infer/src/IR/Localise.mli index 814fa86b2..ae019758c 100644 --- a/infer/src/IR/Localise.mli +++ b/infer/src/IR/Localise.mli @@ -63,13 +63,13 @@ val error_desc_get_dotty : error_desc -> string option (** dereference strings used to explain a dereference action in an error message *) type deref_str -val deref_str_null : Typ.Procname.t option -> deref_str +val deref_str_null : Procname.t option -> deref_str (** dereference strings for null dereference *) -val deref_str_nullable : Typ.Procname.t option -> string -> deref_str +val deref_str_nullable : Procname.t option -> string -> deref_str (** dereference strings for null dereference due to Nullable annotation *) -val deref_str_undef : Typ.Procname.t * Location.t -> deref_str +val deref_str_undef : Procname.t * Location.t -> deref_str (** dereference strings for an undefined value coming from the given procedure *) val deref_str_freed : PredSymb.res_action -> deref_str @@ -81,7 +81,7 @@ val deref_str_dangling : PredSymb.dangling_kind option -> deref_str val deref_str_array_bound : IntLit.t option -> IntLit.t option -> deref_str (** dereference strings for an array out of bound access *) -val deref_str_nil_argument_in_variadic_method : Typ.Procname.t -> int -> int -> deref_str +val deref_str_nil_argument_in_variadic_method : Procname.t -> int -> int -> deref_str (** dereference strings for nonterminal nil arguments in c/objc variadic methods *) val deref_str_pointer_size_mismatch : Typ.t -> Typ.t -> deref_str @@ -94,11 +94,11 @@ type access = | Initialized_automatically | Returned_from_call of int -val nullable_annotation_name : Typ.Procname.t -> string +val nullable_annotation_name : Procname.t -> string (** Name of the nullable annotation *) val dereference_string : - Typ.Procname.t -> deref_str -> string -> access option -> Location.t -> error_desc + Procname.t -> deref_str -> string -> access option -> Location.t -> error_desc val parameter_field_not_null_checked_desc : error_desc -> Exp.t -> error_desc @@ -107,22 +107,20 @@ val is_parameter_not_null_checked_desc : error_desc -> bool val is_field_not_null_checked_desc : error_desc -> bool val desc_allocation_mismatch : - Typ.Procname.t * Typ.Procname.t * Location.t - -> Typ.Procname.t * Typ.Procname.t * Location.t - -> error_desc + Procname.t * Procname.t * Location.t -> Procname.t * Procname.t * Location.t -> error_desc val desc_class_cast_exception : - Typ.Procname.t option -> string -> string -> string option -> Location.t -> error_desc + Procname.t option -> string -> string -> string option -> Location.t -> error_desc val desc_condition_always_true_false : IntLit.t -> string option -> Location.t -> error_desc -val desc_deallocate_stack_variable : string -> Typ.Procname.t -> Location.t -> error_desc +val desc_deallocate_stack_variable : string -> Procname.t -> Location.t -> error_desc -val desc_deallocate_static_memory : string -> Typ.Procname.t -> Location.t -> error_desc +val desc_deallocate_static_memory : string -> Procname.t -> Location.t -> error_desc val desc_divide_by_zero : string -> Location.t -> error_desc -val desc_empty_vector_access : Typ.Procname.t option -> string -> Location.t -> error_desc +val desc_empty_vector_access : Procname.t option -> string -> Location.t -> error_desc val is_empty_vector_access_desc : error_desc -> bool @@ -145,7 +143,7 @@ val desc_custom_error : Location.t -> error_desc (** kind of precondition not met *) type pnm_kind = Pnm_bounds | Pnm_dangling -val desc_precondition_not_met : pnm_kind option -> Typ.Procname.t -> Location.t -> error_desc +val desc_precondition_not_met : pnm_kind option -> Procname.t -> Location.t -> error_desc val desc_retain_cycle : string -> Location.t -> string option -> error_desc @@ -153,9 +151,9 @@ val desc_registered_observer_being_deallocated : Pvar.t -> Location.t -> error_d val desc_stack_variable_address_escape : Pvar.t -> string option -> Location.t -> error_desc -val desc_skip_function : Typ.Procname.t -> error_desc +val desc_skip_function : Procname.t -> error_desc -val desc_inherently_dangerous_function : Typ.Procname.t -> error_desc +val desc_inherently_dangerous_function : Procname.t -> error_desc val desc_unary_minus_applied_to_unsigned_expression : string option -> string -> Location.t -> error_desc diff --git a/infer/src/IR/Objc_models.ml b/infer/src/IR/Objc_models.ml index 165233732..5cf779ae2 100644 --- a/infer/src/IR/Objc_models.ml +++ b/infer/src/IR/Objc_models.ml @@ -196,4 +196,4 @@ end let is_core_lib_type typ = Core_foundation_model.is_core_lib_type typ let is_malloc_model return_type pname = - Core_foundation_model.is_core_lib_create return_type (Typ.Procname.to_string pname) + Core_foundation_model.is_core_lib_create return_type (Procname.to_string pname) diff --git a/infer/src/IR/Objc_models.mli b/infer/src/IR/Objc_models.mli index 54b486309..c0c816568 100644 --- a/infer/src/IR/Objc_models.mli +++ b/infer/src/IR/Objc_models.mli @@ -12,4 +12,4 @@ open! IStd val is_core_lib_type : Typ.t -> bool -val is_malloc_model : Typ.t -> Typ.Procname.t -> bool +val is_malloc_model : Typ.t -> Procname.t -> bool diff --git a/infer/src/IR/PredSymb.ml b/infer/src/IR/PredSymb.ml index 4b8109572..d9f0ebc90 100644 --- a/infer/src/IR/PredSymb.ml +++ b/infer/src/IR/PredSymb.ml @@ -52,7 +52,7 @@ type dangling_kind = [@@deriving compare] (** position in a path: proc name, node id *) -type path_pos = Typ.Procname.t * int [@@deriving compare] +type path_pos = Procname.t * int [@@deriving compare] let equal_path_pos = [%compare.equal: path_pos] @@ -60,7 +60,7 @@ let equal_path_pos = [%compare.equal: path_pos] type res_action = { ra_kind: res_act_kind (** kind of action *) ; ra_res: resource (** kind of resource *) - ; ra_pname: Typ.Procname.t (** name of the procedure used to acquire/release the resource *) + ; ra_pname: 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 *) } @@ -94,13 +94,13 @@ type t = | Aresource of res_action (** resource acquire/release *) | Aautorelease | Adangling of dangling_kind (** dangling pointer *) - | Aundef of Typ.Procname.t * annot_item_ * location_ * path_pos_ + | Aundef of Procname.t * annot_item_ * location_ * path_pos_ | Alocked | Aunlocked | Adiv0 of path_pos (** value appeared in second argument of division at given path position *) | Aobjc_null (** attributed exp is null due to a call to a method with given path as null receiver *) - | Aretval of Typ.Procname.t * Annot.Item.t + | Aretval of Procname.t * Annot.Item.t (** value was returned from a call to the given procedure, plus the annots of the return value *) | Aobserver (** denotes an object registered as an observers to a notification center *) | Aunsubscribed_observer @@ -113,25 +113,25 @@ let equal = [%compare.equal: t] (** name of the allocation function for the given memory kind *) let mem_alloc_pname = function | Mmalloc -> - Typ.Procname.from_string_c_fun "malloc" + Procname.from_string_c_fun "malloc" | Mnew -> - Typ.Procname.from_string_c_fun "new" + Procname.from_string_c_fun "new" | Mnew_array -> - Typ.Procname.from_string_c_fun "new[]" + Procname.from_string_c_fun "new[]" | Mobjc -> - Typ.Procname.from_string_c_fun "alloc" + Procname.from_string_c_fun "alloc" (** name of the deallocation function for the given memory kind *) let mem_dealloc_pname = function | Mmalloc -> - Typ.Procname.from_string_c_fun "free" + Procname.from_string_c_fun "free" | Mnew -> - Typ.Procname.from_string_c_fun "delete" + Procname.from_string_c_fun "delete" | Mnew_array -> - Typ.Procname.from_string_c_fun "delete[]" + Procname.from_string_c_fun "delete[]" | Mobjc -> - Typ.Procname.from_string_c_fun "dealloc" + Procname.from_string_c_fun "dealloc" (** Categories of attributes *) @@ -206,9 +206,7 @@ let to_string pe = function let str_vpath = if Config.trace_error then F.asprintf "%a" (DecompiledExp.pp_vpath pe) ra.ra_vpath else "" in - name ^ Binop.str pe Lt - ^ Typ.Procname.to_string ra.ra_pname - ^ ":" + name ^ Binop.str pe Lt ^ Procname.to_string ra.ra_pname ^ ":" ^ string_of_int ra.ra_loc.Location.line ^ Binop.str pe Gt ^ str_vpath | Aautorelease -> @@ -225,7 +223,7 @@ let to_string pe = function in "DANGL" ^ Binop.str pe Lt ^ dks ^ Binop.str pe Gt | Aundef (pn, _, loc, _) -> - "UND" ^ Binop.str pe Lt ^ Typ.Procname.to_string pn ^ Binop.str pe Gt ^ ":" + "UND" ^ Binop.str pe Lt ^ Procname.to_string pn ^ Binop.str pe Gt ^ ":" ^ string_of_int loc.Location.line | Alocked -> "LOCKED" @@ -236,7 +234,7 @@ let to_string pe = function | Aobjc_null -> "OBJC_NULL" | Aretval (pn, _) -> - "RET" ^ Binop.str pe Lt ^ Typ.Procname.to_string pn ^ Binop.str pe Gt + "RET" ^ Binop.str pe Lt ^ Procname.to_string pn ^ Binop.str pe Gt | Aobserver -> "OBSERVER" | Aunsubscribed_observer -> diff --git a/infer/src/IR/PredSymb.mli b/infer/src/IR/PredSymb.mli index fef35e375..8e5d49be1 100644 --- a/infer/src/IR/PredSymb.mli +++ b/infer/src/IR/PredSymb.mli @@ -42,7 +42,7 @@ type dangling_kind = | DAminusone (** pointer is -1 *) (** position in a path: proc name, node id *) -type path_pos = Typ.Procname.t * int [@@deriving compare] +type path_pos = Procname.t * int [@@deriving compare] val equal_path_pos : path_pos -> path_pos -> bool @@ -50,7 +50,7 @@ val equal_path_pos : path_pos -> path_pos -> bool type res_action = { ra_kind: res_act_kind (** kind of action *) ; ra_res: resource (** kind of resource *) - ; ra_pname: Typ.Procname.t (** name of the procedure used to acquire/release the resource *) + ; ra_pname: 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 *) } @@ -66,13 +66,13 @@ type t = | Aresource of res_action (** resource acquire/release *) | Aautorelease | Adangling of dangling_kind (** dangling pointer *) - | Aundef of Typ.Procname.t * Annot.Item.t * Location.t * path_pos + | Aundef of Procname.t * Annot.Item.t * Location.t * path_pos | Alocked | Aunlocked | Adiv0 of path_pos (** value appeared in second argument of division at given path position *) | Aobjc_null (** attributed exp is null due to a call to a method with given path as null receiver *) - | Aretval of Typ.Procname.t * Annot.Item.t + | Aretval of Procname.t * Annot.Item.t (** value was returned from a call to the given procedure, plus the annots of the return value *) | Aobserver (** denotes an object registered as an observers to a notification center *) | Aunsubscribed_observer @@ -82,10 +82,10 @@ type t = val equal : t -> t -> bool -val mem_alloc_pname : mem_kind -> Typ.Procname.t +val mem_alloc_pname : mem_kind -> Procname.t (** name of the allocation function for the given memory kind *) -val mem_dealloc_pname : mem_kind -> Typ.Procname.t +val mem_dealloc_pname : mem_kind -> Procname.t (** name of the deallocation function for the given memory kind *) (** Categories of attributes *) diff --git a/infer/src/IR/ProcAttributes.ml b/infer/src/IR/ProcAttributes.ml index b2abcf5d0..76aaa9536 100644 --- a/infer/src/IR/ProcAttributes.ml +++ b/infer/src/IR/ProcAttributes.ml @@ -60,7 +60,7 @@ type t = ; mutable locals: var_data list (** name, type and attributes of local variables *) ; method_annotation: Annot.Method.t (** annotations for all methods *) ; objc_accessor: objc_accessor_type option (** type of ObjC accessor, if any *) - ; proc_name: Typ.Procname.t (** name of the procedure *) + ; proc_name: Procname.t (** name of the procedure *) ; ret_type: Typ.t (** return type *) ; has_added_return_param: bool (** whether or not a return param was added *) } @@ -126,8 +126,8 @@ let pp f let pp_bool_default ~default title b f () = if not (Bool.equal default b) then F.fprintf f "; %s= %b@," title b in - F.fprintf f "@[{ proc_name= %a@,; translation_unit= %a@," Typ.Procname.pp proc_name - SourceFile.pp translation_unit ; + F.fprintf f "@[{ proc_name= %a@,; translation_unit= %a@," Procname.pp proc_name SourceFile.pp + translation_unit ; if not (PredSymb.equal_access default.access access) then F.fprintf f "; access= %a@," (Pp.of_string ~f:PredSymb.string_of_access) access ; if not ([%compare.equal: (Mangled.t * Typ.t) list] default.captured captured) then @@ -173,7 +173,7 @@ let pp f F.fprintf f "; objc_accessor= %a@," (Pp.option pp_objc_accessor_type) objc_accessor ; (* always print ret type *) F.fprintf f "; ret_type= %a @," (Typ.pp_full Pp.text) ret_type ; - F.fprintf f "; proc_id= %a }@]" Typ.Procname.pp_unique_id proc_name + F.fprintf f "; proc_id= %a }@]" Procname.pp_unique_id proc_name module SQLite = SqliteUtils.MarshalledDataNOTForComparison (struct diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index e17d81c51..60ac16445 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -44,11 +44,11 @@ type t = ; mutable locals: var_data list (** name, type and attributes of local variables *) ; method_annotation: Annot.Method.t (** annotations for all methods *) ; objc_accessor: objc_accessor_type option (** type of ObjC accessor, if any *) - ; proc_name: Typ.Procname.t (** name of the procedure *) + ; proc_name: Procname.t (** name of the procedure *) ; ret_type: Typ.t (** return type *) ; has_added_return_param: bool (** whether or not a return param was added *) } -val default : SourceFile.t -> Typ.Procname.t -> t +val default : SourceFile.t -> Procname.t -> t (** Create a proc_attributes with default values. *) val pp : Format.formatter -> t -> unit diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index e28fb9c06..9fa09cdcb 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -132,7 +132,7 @@ module Node = struct ; kind: nodekind (** kind of node *) ; loc: Location.t (** location in the source code *) ; mutable preds: t list (** predecessor nodes in the cfg *) - ; pname: Typ.Procname.t (** name of the procedure the node belongs to *) + ; pname: Procname.t (** name of the procedure the node belongs to *) ; mutable succs: t list (** successor nodes in the cfg *) } let exn_handler_kind = Stmt_node ExceptionHandler @@ -534,14 +534,14 @@ let fold_instrs pdesc ~init ~f = let get_static_callees pdesc = let callees = - fold_instrs pdesc ~init:Typ.Procname.Set.empty ~f:(fun acc _node instr -> + fold_instrs pdesc ~init:Procname.Set.empty ~f:(fun acc _node instr -> match instr with | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) -> - Typ.Procname.Set.add callee_pn acc + Procname.Set.add callee_pn acc | _ -> acc ) in - Typ.Procname.Set.remove (get_proc_name pdesc) callees |> Typ.Procname.Set.elements + Procname.Set.remove (get_proc_name pdesc) callees |> Procname.Set.elements let find_map_nodes pdesc ~f = List.find_map ~f (get_nodes pdesc) @@ -741,7 +741,7 @@ let pp_signature fmt pdesc = let attributes = get_attributes pdesc in let pname = get_proc_name pdesc in let defined_string = match is_defined pdesc with true -> "defined" | false -> "undefined" in - Format.fprintf fmt "@[%a [%s, Return type: %a, %aFormals: %a, Locals: %a" Typ.Procname.pp pname + Format.fprintf fmt "@[%a [%s, Return type: %a, %aFormals: %a, Locals: %a" Procname.pp pname defined_string (Typ.pp_full Pp.text) (get_ret_type pdesc) pp_objc_accessor attributes.ProcAttributes.objc_accessor pp_variable_list (get_formals pdesc) pp_locals_list (get_locals pdesc) ; @@ -749,7 +749,7 @@ let pp_signature fmt pdesc = Format.fprintf fmt ", Captured: %a" pp_variable_list (get_captured pdesc) ; let method_annotation = attributes.ProcAttributes.method_annotation in ( if not (Annot.Method.is_empty method_annotation) then - let pname_string = Typ.Procname.to_string pname in + let pname_string = Procname.to_string pname in Format.fprintf fmt ", Annotation: %a" (Annot.Method.pp pname_string) method_annotation ) ; Format.fprintf fmt "]@]@;" @@ -769,9 +769,9 @@ let is_captured_pvar procdesc pvar = let pvar_matches (name, _) = Mangled.equal name pvar_name in let is_captured_var_cpp_lambda = match procname with - | Typ.Procname.ObjC_Cpp cpp_pname -> + | Procname.ObjC_Cpp cpp_pname -> (* var is captured if the procedure is a lambda and the var is not in the locals or formals *) - Typ.Procname.ObjC_Cpp.is_cpp_lambda cpp_pname + Procname.ObjC_Cpp.is_cpp_lambda cpp_pname && not ( List.exists ~f:pvar_local_matches (get_locals procdesc) || List.exists ~f:pvar_matches (get_formals procdesc) ) @@ -780,7 +780,7 @@ let is_captured_pvar procdesc pvar = in let is_captured_var_objc_block = (* var is captured if the procedure is a objc block and the var is in the captured *) - Typ.Procname.is_objc_block procname && List.exists ~f:pvar_matches (get_captured procdesc) + Procname.is_objc_block procname && List.exists ~f:pvar_matches (get_captured procdesc) in is_captured_var_cpp_lambda || is_captured_var_objc_block @@ -871,8 +871,7 @@ let load_statement = let load pname = ResultsDatabase.with_registered_statement load_statement ~f:(fun db stmt -> - Typ.Procname.SQLite.serialize pname - |> Sqlite3.bind stmt 1 + Procname.SQLite.serialize pname |> Sqlite3.bind stmt 1 |> SqliteUtils.check_result_code db ~log:"load bind proc name" ; SqliteUtils.result_single_column_option ~finalize:false ~log:"Procdesc.load" db stmt |> Option.bind ~f:SQLite.deserialize ) diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index a8c228d89..2c9eba745 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -117,7 +117,7 @@ module Node : sig val d_instrs : highlight:Sil.instr option -> t -> unit (** Dump instructions for the node, highlighting the given subinstruction if present *) - val dummy : Typ.Procname.t -> t + val dummy : Procname.t -> t (** Create a dummy node *) val equal : t -> t -> bool @@ -156,7 +156,7 @@ module Node : sig val get_siblings : t -> t Sequence.t (** Get siblings of the current node *) - val get_proc_name : t -> Typ.Procname.t + val get_proc_name : t -> Procname.t (** Get the name of the procedure the node belongs to *) val get_succs : t -> t list @@ -245,7 +245,7 @@ val get_nodes : t -> Node.t list val get_nodes_num : t -> int -val get_proc_name : t -> Typ.Procname.t +val get_proc_name : t -> Procname.t val get_ret_type : t -> Typ.t (** Return the return type of the procedure and type string *) @@ -256,7 +256,7 @@ val get_ret_var : t -> Pvar.t val get_start_node : t -> Node.t -val get_static_callees : t -> Typ.Procname.t list +val get_static_callees : t -> Procname.t list (** get a list of unique static callees excluding self *) val is_defined : t -> bool @@ -321,4 +321,4 @@ module SQLite : SqliteUtils.Data with type t = t option (** per-procedure CFGs are stored in the SQLite "procedures" table as NULL if the procedure has no CFG *) -val load : Typ.Procname.t -> t option +val load : Procname.t -> t option diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml new file mode 100644 index 000000000..6b6f151c6 --- /dev/null +++ b/infer/src/IR/Procname.ml @@ -0,0 +1,810 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd +module Hashtbl = Caml.Hashtbl +module F = Format + +(** Level of verbosity of some to_string functions. *) +type detail_level = Verbose | Non_verbose | Simple [@@deriving compare, equal] + +let is_verbose v = match v with Verbose -> true | _ -> false + +module Java = struct + type kind = + | Non_Static + (** in Java, procedures called with invokevirtual, invokespecial, and invokeinterface *) + | Static (** in Java, procedures called with invokestatic *) + [@@deriving compare] + + (* TODO: use Mangled.t here *) + type java_type = Typ.Name.Java.Split.t [@@deriving compare] + + let java_void = Typ.Name.Java.Split.make "void" + + (** Type of java procedure names. *) + type t = + { method_name: string + ; parameters: java_type list + ; class_name: Typ.Name.t + ; return_type: java_type option (* option because constructors have no return type *) + ; kind: kind } + [@@deriving compare] + + let make class_name return_type method_name parameters kind = + {class_name; return_type; method_name; parameters; kind} + + + let pp_type_verbosity verbosity fmt java_type = + Typ.Name.Java.Split.pp_type_verbosity ~verbose:(is_verbose verbosity) fmt java_type + + + (** Given a list of types, it creates a unique string of types separated by commas *) + let rec pp_param_list verbosity fmt inputList = + match inputList with + | [] -> + () + | [head] -> + pp_type_verbosity verbosity fmt head + | head :: rest -> + pp_type_verbosity verbosity fmt head ; + F.pp_print_string fmt "," ; + pp_param_list verbosity fmt rest + + + let java_type_of_name class_name = Typ.Name.Java.Split.of_string (Typ.Name.name class_name) + + (** It is the same as java_type_to_string_verbosity, but Java return types are optional because of + constructors without type *) + let pp_return_type verbosity fmt j = + match j.return_type with None -> () | Some typ -> pp_type_verbosity verbosity fmt typ + + + let get_class_name j = Typ.Name.name j.class_name + + let get_class_type_name j = j.class_name + + let get_simple_class_name j = Typ.Name.Java.Split.(j |> get_class_name |> of_string |> type_name) + + let get_package j = Typ.Name.Java.Split.(j |> get_class_name |> of_string |> package) + + let get_method j = j.method_name + + let replace_method_name method_name j = {j with method_name} + + let replace_parameters parameters j = {j with parameters} + + let replace_return_type ret_type j = {j with return_type= Some ret_type} + + let get_parameters j = j.parameters + + (** Prints a string of a java procname with the given level of verbosity *) + let pp ?(withclass = false) verbosity fmt j = + match verbosity with + | 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 pp_class_name verbosity fmt j = + pp_type_verbosity verbosity fmt (Typ.Name.Java.split_typename j.class_name) + in + let separator = + match (j.return_type, verbosity) with None, _ -> "" | Some _, Verbose -> ":" | _ -> " " + in + if not (equal_detail_level verbosity Verbose) then + F.fprintf fmt "%a%s" (pp_return_type verbosity) j separator ; + F.fprintf fmt "%a.%s(%a)" (pp_class_name verbosity) j j.method_name + (pp_param_list verbosity) j.parameters ; + if equal_detail_level verbosity Verbose then + F.fprintf fmt "%s%a" separator (pp_return_type verbosity) j + | Simple -> + (* methodname(...) or without ... if there are no parameters *) + let pp_class_prefix ~withclass verbosity fmt j = + if withclass then + F.fprintf fmt "%a." (pp_type_verbosity verbosity) + (Typ.Name.Java.split_typename j.class_name) + in + let params = match j.parameters with [] -> "" | _ -> "..." in + let pp_method_name ~withclass verbosity fmt j = + if String.equal j.method_name "" then + F.pp_print_string fmt (get_simple_class_name j) + else F.fprintf fmt "%a%s" (pp_class_prefix ~withclass verbosity) j j.method_name + in + F.fprintf fmt "%a(%s)" (pp_method_name ~withclass verbosity) j params + + + let get_return_typ pname_java = + let rec java_from_string = function + | "" | "void" -> + Typ.void + | "int" -> + Typ.int + | "byte" -> + Typ.java_byte + | "short" -> + Typ.java_short + | "boolean" -> + Typ.boolean + | "char" -> + Typ.char + | "long" -> + Typ.long + | "float" -> + Typ.float + | "double" -> + Typ.double + | typ_str when String.contains typ_str '[' -> + let stripped_typ = String.sub typ_str ~pos:0 ~len:(String.length typ_str - 2) in + Typ.mk (Tptr (Typ.mk_array (java_from_string stripped_typ), Pk_pointer)) + | typ_str -> + Typ.mk (Tstruct (Typ.Name.Java.from_string typ_str)) + in + let typ = java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java) in + match typ.desc with Tstruct _ -> Typ.mk (Tptr (typ, Pk_pointer)) | _ -> typ + + + let is_close {method_name} = String.equal method_name "close" + + let constructor_method_name = "" + + let class_initializer_method_name = "" + + let is_class_initializer {method_name} = String.equal method_name class_initializer_method_name + + let get_class_initializer class_name = + { method_name= class_initializer_method_name + ; parameters= [] + ; class_name + ; return_type= Some java_void + ; kind= Static } + + + let is_constructor {method_name} = String.equal method_name constructor_method_name + + let is_anonymous_inner_class_constructor {class_name} = + Typ.Name.Java.is_anonymous_inner_class_name class_name + + + let is_static {kind} = match kind with Static -> true | _ -> false + + let is_lambda {method_name} = String.is_prefix ~prefix:"lambda$" method_name + + let is_generated {method_name} = String.is_prefix ~prefix:"$" method_name + + let is_access_method {method_name} = + match String.rsplit2 method_name ~on:'$' with + | Some ("access", s) -> + let is_int = + try + ignore (int_of_string s) ; + true + with Failure _ -> false + in + is_int + | _ -> + false + + + let is_autogen_method {method_name} = String.contains method_name '$' + + (** Check if the proc name has the type of a java vararg. Note: currently only checks that the + last argument has type Object[]. *) + let is_vararg {parameters} = + (* FIXME this looks wrong due to the dot in the type name *) + List.last parameters + |> Option.exists ~f:(fun java_type -> + String.equal "java.lang.Object[]" (Typ.Name.Java.Split.type_name java_type) ) + + + let is_external java_pname = + let package = get_package java_pname in + Option.exists ~f:Config.java_package_is_external package +end + +module Parameter = struct + (** Type for parameters in clang procnames, [Some name] means the parameter is of type pointer to + struct, with [name] being the name of the struct, [None] means the parameter is of some other + type. *) + type clang_parameter = Typ.Name.t option [@@deriving compare] + + (** Type for parameters in procnames, for java and clang. *) + type t = JavaParameter of Java.java_type | ClangParameter of clang_parameter + [@@deriving compare] + + let of_typ typ = + match typ.Typ.desc with Typ.Tptr ({desc= Tstruct name}, Pk_pointer) -> Some name | _ -> None + + + let pp_parameters fmt parameters = + if List.exists ~f:Option.is_some parameters then + (* the tests rely on the fact that we discard non-pointer-to-struct types for some reason, + hence the slight re-implementation of [Pp.seq] to avoid building the list of [Some] items + explicitly *) + let rec pp_parameters_aux fmt = function + | [] -> + () + | [Some param] -> + F.pp_print_string fmt (Typ.Name.to_string param) + | None :: parameters -> + pp_parameters_aux fmt parameters + | (Some _ as param_some) :: None :: parameters -> + pp_parameters_aux fmt (param_some :: parameters) + | Some param :: (Some _ :: _ as parameters) -> + F.fprintf fmt "%s," (Typ.Name.to_string param) ; + pp_parameters_aux fmt parameters + in + F.fprintf fmt "(%a)" pp_parameters_aux parameters + + + let clang_param_of_name class_name : clang_parameter = Some class_name +end + +module ObjC_Cpp = struct + type kind = + | CPPMethod of {mangled: string option} + | CPPConstructor of {mangled: string option; is_constexpr: bool} + | CPPDestructor of {mangled: string option} + | ObjCClassMethod + | ObjCInstanceMethod + | ObjCInternalMethod + [@@deriving compare] + + type t = + { class_name: Typ.Name.t + ; kind: kind + ; method_name: string + ; parameters: Parameter.clang_parameter list + ; template_args: Typ.template_spec_info } + [@@deriving compare] + + let make class_name method_name kind template_args parameters = + {class_name; method_name; kind; template_args; parameters} + + + let get_class_name objc_cpp = Typ.Name.name objc_cpp.class_name + + let get_class_type_name objc_cpp = objc_cpp.class_name + + let get_class_qualifiers objc_cpp = Typ.Name.qual_name objc_cpp.class_name + + let objc_method_kind_of_bool is_instance = + if is_instance then ObjCInstanceMethod else ObjCClassMethod + + + let is_objc_constructor method_name = + String.equal method_name "new" || String.is_prefix ~prefix:"init" method_name + + + let is_objc_kind = function + | ObjCClassMethod | ObjCInstanceMethod | ObjCInternalMethod -> + true + | _ -> + false + + + let is_objc_method {kind} = is_objc_kind kind + + let is_objc_dealloc method_name = String.equal method_name "dealloc" + + let is_destructor = function + | {kind= CPPDestructor _} -> + true + | name -> + is_objc_dealloc name.method_name + + + let is_inner_destructor ({method_name} as pname) = + is_destructor pname && String.is_prefix ~prefix:Config.clang_inner_destructor_prefix method_name + + + let is_constexpr = function {kind= CPPConstructor {is_constexpr= true}} -> true | _ -> false + + let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name + + let pp_verbose_kind fmt = function + | CPPMethod {mangled} | CPPDestructor {mangled} -> + F.fprintf fmt "(%s)" (Option.value ~default:"" mangled) + | CPPConstructor {mangled; is_constexpr} -> + F.fprintf fmt "{%s%s}" + (Option.value ~default:"" mangled) + (if is_constexpr then "|constexpr" else "") + | ObjCClassMethod -> + F.pp_print_string fmt "class" + | ObjCInstanceMethod -> + F.pp_print_string fmt "instance" + | ObjCInternalMethod -> + F.pp_print_string fmt "internal" + + + let pp verbosity fmt osig = + match verbosity with + | Simple -> + F.pp_print_string fmt osig.method_name + | Non_verbose -> + F.fprintf fmt "%s::%s" (Typ.Name.name osig.class_name) osig.method_name + | Verbose -> + F.fprintf fmt "%s::%s%a%a" (Typ.Name.name osig.class_name) osig.method_name + Parameter.pp_parameters osig.parameters pp_verbose_kind osig.kind + + + let get_parameters osig = osig.parameters + + let replace_parameters new_parameters osig = {osig with parameters= new_parameters} +end + +module C = struct + (** Type of c procedure names. *) + type t = + { name: QualifiedCppName.t + ; mangled: string option + ; parameters: Parameter.clang_parameter list + ; template_args: Typ.template_spec_info } + [@@deriving compare] + + let c name mangled parameters template_args = + {name; mangled= Some mangled; parameters; template_args} + + + let from_string name = + { name= QualifiedCppName.of_qual_string name + ; mangled= None + ; parameters= [] + ; template_args= NoTemplate } + + + let pp verbosity fmt {name; mangled; parameters} = + let plain = QualifiedCppName.to_qual_string name in + match verbosity with + | Simple -> + F.fprintf fmt "%s()" plain + | Non_verbose -> + F.pp_print_string fmt plain + | Verbose -> + let pp_mangled fmt = function None -> () | Some s -> F.fprintf fmt "{%s}" s in + F.fprintf fmt "%s%a%a" plain Parameter.pp_parameters parameters pp_mangled mangled + + + let get_parameters c = c.parameters + + let replace_parameters new_parameters c = {c with parameters= new_parameters} +end + +module Block = struct + (** Type of Objective C block names. *) + type block_name = string [@@deriving compare] + + type t = {name: block_name; parameters: Parameter.clang_parameter list} [@@deriving compare] + + let make name parameters = {name; parameters} + + let pp verbosity fmt bsig = + match verbosity with + | Simple -> + F.pp_print_string fmt "block" + | Non_verbose -> + F.pp_print_string fmt bsig.name + | Verbose -> + F.fprintf fmt "%s%a" bsig.name Parameter.pp_parameters bsig.parameters + + + let get_parameters block = block.parameters + + let replace_parameters new_parameters block = {block with parameters= new_parameters} +end + +(** Type of procedure names. *) +type t = + | Java of Java.t + | C of C.t + | Linters_dummy_method + | Block of Block.t + | ObjC_Cpp of ObjC_Cpp.t + | WithBlockParameters of t * Block.block_name list +[@@deriving compare] + +let equal = [%compare.equal: t] + +(** hash function for procname *) +let hash = Hashtbl.hash + +let with_block_parameters base blocks = WithBlockParameters (base, blocks) + +let is_java = function Java _ -> true | _ -> false + +(* TODO: deprecate this unfortunately named function and use is_clang instead *) +let is_c_method = function ObjC_Cpp _ -> true | _ -> false + +let is_c_function = function C _ -> true | _ -> false + +let is_clang = function ObjC_Cpp name -> ObjC_Cpp.is_objc_method name | name -> is_c_function name + +let is_java_lift f = function Java java_pname -> f java_pname | _ -> false + +let is_java_access_method = is_java_lift Java.is_access_method + +let is_java_class_initializer = is_java_lift Java.is_class_initializer + +let is_objc_method procname = + match procname with ObjC_Cpp name -> ObjC_Cpp.is_objc_method name | _ -> false + + +let block_name_of_procname procname = + match procname with + | Block block -> + block.name + | _ -> + Logging.die InternalError "Only to be called with Objective-C block names" + + +let empty_block = Block {name= ""; parameters= []} + +(** Replace the class name component of a procedure name. In case of Java, replace package and class + name. *) +let rec replace_class t (new_class : Typ.Name.t) = + match t with + | Java j -> + Java {j with class_name= new_class} + | ObjC_Cpp osig -> + ObjC_Cpp {osig with class_name= new_class} + | WithBlockParameters (base, blocks) -> + WithBlockParameters (replace_class base new_class, blocks) + | C _ | Block _ | Linters_dummy_method -> + t + + +let get_class_type_name = function + | Java java_pname -> + Some (Java.get_class_type_name java_pname) + | ObjC_Cpp objc_pname -> + Some (ObjC_Cpp.get_class_type_name objc_pname) + | _ -> + None + + +let get_class_name = function + | Java java_pname -> + Some (Java.get_class_name java_pname) + | ObjC_Cpp objc_pname -> + Some (ObjC_Cpp.get_class_name objc_pname) + | _ -> + None + + +let is_method_in_objc_protocol t = + match t with ObjC_Cpp osig -> Typ.Name.is_objc_protocol osig.class_name | _ -> false + + +let rec objc_cpp_replace_method_name t (new_method_name : string) = + match t with + | ObjC_Cpp osig -> + ObjC_Cpp {osig with method_name= new_method_name} + | WithBlockParameters (base, blocks) -> + WithBlockParameters (objc_cpp_replace_method_name base new_method_name, blocks) + | C _ | Block _ | Linters_dummy_method | Java _ -> + t + + +(** Return the method/function of a procname. *) +let rec get_method = function + | ObjC_Cpp name -> + name.method_name + | WithBlockParameters (base, _) -> + get_method base + | C {name} -> + QualifiedCppName.to_qual_string name + | Block {name} -> + name + | Java j -> + j.method_name + | Linters_dummy_method -> + "Linters_dummy_method" + + +(** Return whether the procname is a block procname. *) +let is_objc_block = function Block _ -> true | _ -> false + +(** Return the language of the procedure. *) +let get_language = function + | ObjC_Cpp _ -> + Language.Clang + | C _ -> + Language.Clang + | Block _ -> + Language.Clang + | Linters_dummy_method -> + Language.Clang + | WithBlockParameters _ -> + Language.Clang + | Java _ -> + Language.Java + + +(** [is_constructor pname] returns true if [pname] is a constructor *) +let is_constructor = function + | Java js -> + String.equal js.method_name Java.constructor_method_name + | ObjC_Cpp {kind= CPPConstructor _} -> + true + | ObjC_Cpp {kind; method_name} when ObjC_Cpp.is_objc_kind kind -> + ObjC_Cpp.is_objc_constructor method_name + | _ -> + false + + +(** [is_infer_undefined pn] returns true if [pn] is a special Infer undefined proc *) +let is_infer_undefined pn = + match pn with + | Java j -> + let regexp = Str.regexp_string "com.facebook.infer.builtins.InferUndefined" in + 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 = function + | C {name} + when String.is_prefix ~prefix:Config.clang_initializer_prefix + (QualifiedCppName.to_qual_string name) -> + let name_str = QualifiedCppName.to_qual_string name in + let prefix_len = String.length Config.clang_initializer_prefix in + Some (String.sub name_str ~pos:prefix_len ~len:(String.length name_str - prefix_len)) + | _ -> + None + + +(** Very verbose representation of an existing Procname.t *) +let rec pp_unique_id fmt = function + | Java j -> + Java.pp Verbose fmt j + | C osig -> + C.pp Verbose fmt osig + | ObjC_Cpp osig -> + ObjC_Cpp.pp Verbose fmt osig + | Block bsig -> + Block.pp Verbose fmt bsig + | WithBlockParameters (base, []) -> + pp_unique_id fmt base + | WithBlockParameters (base, (_ :: _ as blocks)) -> + pp_unique_id fmt base ; + F.pp_print_string fmt "_" ; + Pp.seq ~sep:"_" F.pp_print_string fmt blocks + | Linters_dummy_method -> + F.pp_print_string fmt "Linters_dummy_method" + + +let to_unique_id proc_name = F.asprintf "%a" pp_unique_id proc_name + +(** Convert a proc name to a string for the user to see *) +let rec pp fmt = function + | Java j -> + Java.pp Non_verbose fmt j + | C osig -> + C.pp Non_verbose fmt osig + | ObjC_Cpp osig -> + ObjC_Cpp.pp Non_verbose fmt osig + | Block bsig -> + Block.pp Non_verbose fmt bsig + | WithBlockParameters (base, []) -> + pp fmt base + | WithBlockParameters (base, (_ :: _ as blocks)) -> + pp fmt base ; + F.pp_print_string fmt "_" ; + Pp.seq ~sep:"_" F.pp_print_string fmt blocks + | Linters_dummy_method -> + pp_unique_id fmt Linters_dummy_method + + +let to_string proc_name = F.asprintf "%a" pp proc_name + +(** Convenient representation of a procname for external tools (e.g. eclipse plugin) *) +let rec pp_simplified_string ?(withclass = false) fmt = function + | Java j -> + Java.pp ~withclass Simple fmt j + | C osig -> + C.pp Simple fmt osig + | ObjC_Cpp osig -> + ObjC_Cpp.pp Simple fmt osig + | Block bsig -> + Block.pp Simple fmt bsig + | WithBlockParameters (base, _) -> + pp_simplified_string fmt base + | Linters_dummy_method -> + pp_unique_id fmt Linters_dummy_method + + +let to_simplified_string ?withclass proc_name = + F.asprintf "%a" (pp_simplified_string ?withclass) proc_name + + +let from_string_c_fun func = C (C.from_string func) + +let java_inner_class_prefix_regex = Str.regexp "\\$[0-9]+" + +let hashable_name proc_name = + match proc_name with + | Java pname -> ( + (* Strip autogenerated anonymous inner class numbers in order to keep the bug hash + invariant when introducing new anonymous classes *) + let name = F.asprintf "%a" (Java.pp ~withclass:true Simple) pname in + match Str.search_forward java_inner_class_prefix_regex name 0 with + | _ -> + Str.global_replace java_inner_class_prefix_regex "$_" name + | exception Caml.Not_found -> + name ) + | ObjC_Cpp m when ObjC_Cpp.is_objc_method m -> + (* In Objective C, the list of parameters is part of the method name. To prevent the bug + hash to change when a parameter is introduced or removed, only the part of the name + before the first colon is used for the bug hash *) + let name = F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name in + List.hd_exn (String.split_on_chars name ~on:[':']) + | _ -> + (* Other cases for C and C++ method names *) + F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name + + +let rec get_parameters procname = + let clang_param_to_param clang_params = + List.map ~f:(fun par -> Parameter.ClangParameter par) clang_params + in + match procname with + | Java j -> + List.map ~f:(fun par -> Parameter.JavaParameter par) (Java.get_parameters j) + | C osig -> + clang_param_to_param (C.get_parameters osig) + | ObjC_Cpp osig -> + clang_param_to_param (ObjC_Cpp.get_parameters osig) + | Block bsig -> + clang_param_to_param (Block.get_parameters bsig) + | WithBlockParameters (base, _) -> + get_parameters base + | Linters_dummy_method -> + [] + + +let rec replace_parameters new_parameters procname = + let params_to_java_params params = + List.map + ~f:(fun param -> + match param with + | Parameter.JavaParameter par -> + par + | _ -> + Logging.(die InternalError) + "Expected Java parameters in Java procname, but got Clang parameters" params ) + params + in + let params_to_clang_params params = + List.map + ~f:(fun param -> + match param with + | Parameter.ClangParameter par -> + par + | _ -> + Logging.(die InternalError) + "Expected Clang parameters in Clang procname, but got Java parameters" params ) + params + in + match procname with + | Java j -> + Java (Java.replace_parameters (params_to_java_params new_parameters) j) + | C osig -> + C (C.replace_parameters (params_to_clang_params new_parameters) osig) + | ObjC_Cpp osig -> + ObjC_Cpp (ObjC_Cpp.replace_parameters (params_to_clang_params new_parameters) osig) + | Block bsig -> + Block (Block.replace_parameters (params_to_clang_params new_parameters) bsig) + | WithBlockParameters (base, blocks) -> + WithBlockParameters (replace_parameters new_parameters base, blocks) + | Linters_dummy_method -> + procname + + +let parameter_of_name procname class_name = + match procname with + | Java _ -> + Parameter.JavaParameter (Java.java_type_of_name class_name) + | _ -> + Parameter.ClangParameter (Parameter.clang_param_of_name class_name) + + +let describe f pn = + let name = hashable_name pn in + match String.lsplit2 ~on:'<' name with + | Some (name_without_template, _template_part) -> + F.pp_print_string f name_without_template + | None -> + F.pp_print_string f name + + +module Hashable = struct + type nonrec t = t + + let equal = equal + + let hash = hash +end + +module Hash = Hashtbl.Make (Hashable) + +module Map = PrettyPrintable.MakePPMap (struct + type nonrec t = t + + let compare = compare + + let pp = pp +end) + +module Set = PrettyPrintable.MakePPSet (struct + type nonrec t = t + + let compare = compare + + let pp = pp +end) + +let get_qualifiers pname = + match pname with + | C {name} -> + name + | ObjC_Cpp objc_cpp -> + ObjC_Cpp.get_class_qualifiers objc_cpp + |> QualifiedCppName.append_qualifier ~qual:objc_cpp.method_name + | _ -> + QualifiedCppName.empty + + +(** Convert a proc name to a filename *) +let to_filename ?crc_only pname = + (* filenames for clang procs are REVERSED qualifiers with '#' as separator *) + let pp_rev_qualified fmt pname = + let rev_qualifiers = get_qualifiers pname |> QualifiedCppName.to_rev_list in + Pp.seq ~sep:"#" F.pp_print_string fmt rev_qualifiers + in + let proc_id = + match pname with + | C {parameters; mangled} -> + let pp_mangled fmt = function None -> () | Some mangled -> F.fprintf fmt "#%s" mangled in + F.asprintf "%a%a%a" pp_rev_qualified pname Parameter.pp_parameters parameters pp_mangled + mangled + | ObjC_Cpp objc_cpp -> + F.asprintf "%a%a#%a" pp_rev_qualified pname Parameter.pp_parameters objc_cpp.parameters + ObjC_Cpp.pp_verbose_kind objc_cpp.kind + | _ -> + F.asprintf "%a" pp_unique_id pname + in + Escape.escape_filename @@ DB.append_crc_cutoff ?crc_only proc_id + + +module SQLite = struct + module T = struct + type nonrec t = t + + let compare = compare + + let hash = hash + + let sexp_of_t p = Sexp.Atom (F.asprintf "%a" pp p) + end + + module Serializer = SqliteUtils.MarshalledDataForComparison (T) + + let pname_to_key = Base.Hashtbl.create (module T) + + let serialize pname = + let default () = Serializer.serialize pname in + Base.Hashtbl.find_or_add pname_to_key pname ~default + + + let deserialize = Serializer.deserialize + + let clear_cache () = Base.Hashtbl.clear pname_to_key +end + +module SQLiteList = SqliteUtils.MarshalledDataNOTForComparison (struct + type nonrec t = t list +end) diff --git a/infer/src/IR/Procname.mli b/infer/src/IR/Procname.mli new file mode 100644 index 000000000..2f9287910 --- /dev/null +++ b/infer/src/IR/Procname.mli @@ -0,0 +1,316 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd +module F = Format + +(** Module for Procedure Names. *) + +(** Type of java procedure names. *) +module Java : sig + type kind = + | Non_Static + (** in Java, procedures called with invokevirtual, invokespecial, and invokeinterface *) + | Static (** in Java, procedures called with invokestatic *) + + type t [@@deriving compare] + + type java_type = Typ.Name.Java.Split.t + + val constructor_method_name : string + + val class_initializer_method_name : string + + val compare_java_type : java_type -> java_type -> int + + val make : Typ.Name.t -> java_type option -> string -> java_type list -> kind -> t + (** Create a Java procedure name from its class_name method_name args_type_name return_type_name + method_kind. *) + + val replace_method_name : string -> t -> t + (** Replace the method name of an existing java procname. *) + + val replace_parameters : java_type list -> t -> t + (** Replace the parameters of a java procname. *) + + val replace_return_type : java_type -> t -> t + (** Replace the method of a java procname. *) + + val get_class_name : t -> string + (** Return the fully qualified class name of a java procedure name (package + class name) *) + + val get_class_type_name : t -> Typ.Name.t + (** Return the class name as a typename of a java procedure name. *) + + val get_simple_class_name : t -> string + (** Return the simple class name of a java procedure name (i.e. name without the package info). *) + + val get_package : t -> string option + (** Return the package name of a java procedure name. *) + + val get_method : t -> string + (** Return the method name of a java procedure name. *) + + val get_parameters : t -> java_type list + (** Return the parameters of a java procedure name. *) + + val get_return_typ : t -> Typ.t + (** Return the return type of [pname_java]. return Tvoid if there's no return type *) + + val is_constructor : t -> bool + (** Whether the method is constructor *) + + val is_access_method : t -> bool + (** Check if the procedure name is an acess method (e.g. access$100 used to access private members + from a nested class. *) + + val is_autogen_method : t -> bool + (** Check if the procedure name is of an auto-generated method containing '$'. *) + + val is_anonymous_inner_class_constructor : t -> bool + (** Check if the procedure name is an anonymous inner class constructor. *) + + val is_close : t -> bool + (** Check if the method name is "close". *) + + val is_static : t -> bool + (** Check if the java procedure is static. *) + + val is_vararg : 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[]. *) + + val is_lambda : t -> bool + (** Check if the proc name comes from a lambda expression *) + + val is_generated : t -> bool + (** Check if the proc name comes from generated code *) + + val is_class_initializer : t -> bool + (** Check if this is a class initializer. *) + + val get_class_initializer : Typ.Name.t -> t + (** Given a java class, generate the procname of its static initializer. *) + + val is_external : t -> bool + (** Check if the method belongs to one of the specified external packages *) +end + +module Parameter : sig + (** Type for parameters in clang procnames, [Some name] means the parameter is of type pointer to + struct, with [name] being the name of the struct, [None] means the parameter is of some other + type. *) + type clang_parameter = Typ.Name.t option [@@deriving compare] + + (** Type for parameters in procnames, for java and clang. *) + type t = JavaParameter of Java.java_type | ClangParameter of clang_parameter + [@@deriving compare] + + val of_typ : Typ.t -> clang_parameter +end + +module ObjC_Cpp : sig + type kind = + | CPPMethod of {mangled: string option} + | CPPConstructor of {mangled: string option; is_constexpr: bool} + | CPPDestructor of {mangled: string option} + | ObjCClassMethod + | ObjCInstanceMethod + | ObjCInternalMethod + [@@deriving compare] + + (** Type of Objective C and C++ procedure names: method signatures. *) + type t = + { class_name: Typ.Name.t + ; kind: kind + ; method_name: string + ; parameters: Parameter.clang_parameter list + ; template_args: Typ.template_spec_info } + [@@deriving compare] + + val make : + Typ.Name.t -> string -> kind -> Typ.template_spec_info -> Parameter.clang_parameter list -> t + (** Create an objc procedure name from a class_name and method_name. *) + + val get_class_name : t -> string + + val get_class_type_name : t -> Typ.Name.t [@@warning "-32"] + + val get_class_qualifiers : t -> QualifiedCppName.t + + val objc_method_kind_of_bool : bool -> kind + (** Create ObjC method type from a bool is_instance. *) + + val is_objc_constructor : string -> bool + (** Check if this is a constructor method in Objective-C. *) + + val is_objc_dealloc : string -> bool + (** Check if this is a dealloc method in Objective-C. *) + + val is_destructor : t -> bool + (** Check if this is a dealloc method. *) + + val is_inner_destructor : t -> bool + (** Check if this is a frontend-generated "inner" destructor (see D5834555/D7189239) *) + + val is_constexpr : t -> bool + (** Check if this is a constexpr function. *) + + val is_cpp_lambda : t -> bool + (** Return whether the procname is a cpp lambda. *) +end + +module C : sig + (** Type of c procedure names. *) + type t = private + { name: QualifiedCppName.t + ; mangled: string option + ; parameters: Parameter.clang_parameter list + ; template_args: Typ.template_spec_info } + + val c : + QualifiedCppName.t -> string -> Parameter.clang_parameter list -> Typ.template_spec_info -> t + (** Create a C procedure name from plain and mangled name. *) +end + +module Block : sig + (** Type of Objective C block names. *) + type block_name = string + + type t = {name: block_name; parameters: Parameter.clang_parameter list} [@@deriving compare] + + val make : block_name -> Parameter.clang_parameter list -> t +end + +(** Type of procedure names. WithBlockParameters is used for creating an instantiation of a method + that contains block parameters and it's called with concrete blocks. For example: + [foo(Block block) {block();}] [bar() {foo(my_block)}] is executed as + [foo_my_block() {my_block(); }] where foo_my_block is created with WithBlockParameters (foo, + [my_block]) *) +type t = + | Java of Java.t + | C of C.t + | Linters_dummy_method + | Block of Block.t + | ObjC_Cpp of ObjC_Cpp.t + | WithBlockParameters of t * Block.block_name list +[@@deriving compare] + +val block_name_of_procname : t -> Block.block_name + +val equal : t -> t -> bool + +val get_class_type_name : t -> Typ.Name.t option + +val get_class_name : t -> string option + +val get_parameters : t -> Parameter.t list + +val replace_parameters : Parameter.t list -> t -> t + +val parameter_of_name : t -> Typ.Name.t -> Parameter.t + +val is_java_access_method : t -> bool + +val is_java_class_initializer : t -> bool + +val is_objc_method : t -> bool + +module Hash : Caml.Hashtbl.S with type key = t +(** Hash tables with proc names as keys. *) + +module Map : PrettyPrintable.PPMap with type key = t +(** Maps from proc names. *) + +module Set : PrettyPrintable.PPSet with type elt = t +(** Sets of proc names. *) + +module SQLite : sig + val serialize : t -> Sqlite3.Data.t + + val deserialize : Sqlite3.Data.t -> t + + val clear_cache : unit -> unit +end + +module SQLiteList : SqliteUtils.Data with type t = t list + +val empty_block : t +(** Empty block name. *) + +val get_language : t -> Language.t +(** Return the language of the procedure. *) + +val get_method : t -> string +(** Return the method/function of a procname. *) + +val is_objc_block : t -> bool +(** Return whether the procname is a block procname. *) + +val is_c_method : t -> bool +(** Return true this is an Objective-C/C++ method name. *) + +val is_clang : t -> bool +(** Return true if this is a C, C++, or Objective-C procedure name *) + +val is_constructor : t -> bool +(** Check if this is a constructor. *) + +val is_java : t -> bool +(** Check if this is a Java procedure name. *) + +val with_block_parameters : t -> Block.block_name list -> t +(** Create a procedure name instantiated with block parameters from a base procedure name and a list + of block procedure names (the arguments). *) + +val objc_cpp_replace_method_name : t -> string -> t + +val is_infer_undefined : t -> bool +(** Check if this is a special Infer undefined procedure. *) + +val get_global_name_of_initializer : t -> string option +(** Return the name of the global for which this procedure is the initializer if this is an + initializer, None otherwise. *) + +val pp : Format.formatter -> t -> unit +(** Pretty print a proc name for the user to see. *) + +val to_string : t -> string +(** Convert a proc name into a string for the user to see. *) + +val describe : Format.formatter -> t -> unit +(** to use in user messages *) + +val replace_class : t -> Typ.Name.t -> t +(** Replace the class name component of a procedure name. In case of Java, replace package and class + name. *) + +val is_method_in_objc_protocol : t -> bool + +val pp_simplified_string : ?withclass:bool -> F.formatter -> t -> unit +(** Pretty print a proc name as an easy string for the user to see in an IDE. *) + +val to_simplified_string : ?withclass:bool -> t -> string +(** Convert a proc name into an easy string for the user to see in an IDE. *) + +val from_string_c_fun : string -> t +(** Convert a string to a c function name. *) + +val hashable_name : t -> string +(** Convert the procedure name in a format suitable for computing the bug hash. *) + +val pp_unique_id : F.formatter -> t -> unit +(** Print a proc name as a unique identifier. *) + +val to_unique_id : t -> string +(** Convert a proc name into a unique identifier. *) + +val to_filename : ?crc_only:bool -> t -> string +(** Convert a proc name to a filename or only to its crc. *) + +val get_qualifiers : t -> QualifiedCppName.t +(** get qualifiers of C/objc/C++ method/function *) diff --git a/infer/src/IR/ProcnameDispatcher.ml b/infer/src/IR/ProcnameDispatcher.ml index bcdd0e2af..d77f7a891 100644 --- a/infer/src/IR/ProcnameDispatcher.ml +++ b/infer/src/IR/ProcnameDispatcher.ml @@ -21,11 +21,11 @@ and non_empty type typ = Typ.t -type c = Typ.Procname.C.t +type c = Procname.C.t -type objc_cpp = Typ.Procname.ObjC_Cpp.t +type objc_cpp = Procname.ObjC_Cpp.t -type java = Typ.Procname.Java.t +type java = Procname.Java.t type qual_name = QualifiedCppName.t @@ -53,8 +53,7 @@ let templated_name_of_class_name class_name = let templated_name_of_java java = let qual_name = - QualifiedCppName.of_list - [Typ.Procname.Java.get_class_name java; Typ.Procname.Java.get_method java] + QualifiedCppName.of_list [Procname.Java.get_class_name java; Procname.Java.get_method java] in (qual_name, []) @@ -117,7 +116,7 @@ let name_cons : | _ -> None in - let on_objc_cpp context f (objc_cpp : Typ.Procname.ObjC_Cpp.t) = + let on_objc_cpp context f (objc_cpp : Procname.ObjC_Cpp.t) = if match_fuzzy_name objc_cpp.method_name then on_templated_name context f (templated_name_of_class_name objc_cpp.class_name) else None @@ -138,7 +137,7 @@ let name_cons_f : | _ -> None in - let on_objc_cpp context f (objc_cpp : Typ.Procname.ObjC_Cpp.t) = + let on_objc_cpp context f (objc_cpp : Procname.ObjC_Cpp.t) = if f_name context objc_cpp.method_name then on_templated_name context f (templated_name_of_class_name objc_cpp.class_name) else None @@ -164,7 +163,7 @@ let all_names_cons : on_templated_name_rec context f (rest, []) ) in let on_templated_name = on_templated_name_rec in - let on_objc_cpp context f (objc_cpp : Typ.Procname.ObjC_Cpp.t) = + let on_objc_cpp context f (objc_cpp : Procname.ObjC_Cpp.t) = match on_objc_cpp context f objc_cpp with | Some _ as some -> some @@ -182,7 +181,7 @@ let templ_begin : let on_templated_name context f (qual_name, template_args) = match on_qual_name context f qual_name with None -> None | Some f -> Some (f, template_args) in - let on_objc_cpp context f (objc_cpp : Typ.Procname.ObjC_Cpp.t) = + let on_objc_cpp context f (objc_cpp : Procname.ObjC_Cpp.t) = match on_objc_cpp context f objc_cpp with | None -> None @@ -468,7 +467,7 @@ module Call = struct -> ('context, 'f_out, 'arg_payload) pre_result } type ('context, 'f, 'arg_payload) dispatcher = - 'context -> Typ.Procname.t -> 'arg_payload FuncArg.t list -> 'f option + 'context -> Procname.t -> 'arg_payload FuncArg.t list -> 'f option let args_begin : ('context, 'f_in, 'f_out, non_empty, 'arg_payload) path_matcher @@ -785,8 +784,7 @@ module Call = struct let wrong_args_internal_error : _ matcher = let on_procname procname = - Logging.(die InternalError) - "Unexpected number/types of arguments for %a" Typ.Procname.pp procname + Logging.(die InternalError) "Unexpected number/types of arguments for %a" Procname.pp procname in let on_c _context c _args = on_procname (C c) in let on_java _context java _args = on_procname (Java java) in @@ -907,7 +905,7 @@ end module ProcName = struct include NameCommon - type ('context, 'f, 'arg_payload) dispatcher = 'context -> Typ.Procname.t -> 'f option + type ('context, 'f, 'arg_payload) dispatcher = 'context -> Procname.t -> 'f option let make_dispatcher : ('context, 'f, 'arg_payload) matcher list -> ('context, 'f, 'arg_payload) dispatcher = @@ -919,7 +917,7 @@ module ProcName = struct List.find_map matchers ~f:(fun (matcher : _ matcher) -> matcher.on_templated_name context templated_name ) in - let on_java context (java : Typ.Procname.Java.t) = + let on_java context (java : Procname.Java.t) = let templated_name = templated_name_of_java java in on_templated_name context templated_name in diff --git a/infer/src/IR/ProcnameDispatcher.mli b/infer/src/IR/ProcnameDispatcher.mli index 95b8c5723..6c27e0d33 100644 --- a/infer/src/IR/ProcnameDispatcher.mli +++ b/infer/src/IR/ProcnameDispatcher.mli @@ -141,8 +141,7 @@ module type NameCommon = sig end module ProcName : - NameCommon - with type ('context, 'f, 'arg_payload) dispatcher = 'context -> Typ.Procname.t -> 'f option + NameCommon with type ('context, 'f, 'arg_payload) dispatcher = 'context -> Procname.t -> 'f option module TypName : NameCommon with type ('context, 'f, 'arg_payload) dispatcher = 'context -> Typ.name -> 'f option @@ -156,7 +155,7 @@ module Call : sig include Common with type ('context, 'f, 'arg_payload) dispatcher = - 'context -> Typ.Procname.t -> 'arg_payload FuncArg.t list -> 'f option + 'context -> Procname.t -> 'arg_payload FuncArg.t list -> 'f option val merge_dispatchers : ('context, 'f, 'arg_payload) dispatcher diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index 7b694a916..6d5cc0398 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -16,11 +16,10 @@ type translation_unit = SourceFile.t option [@@deriving compare] (** Kind of global variables *) type pvar_kind = - | Local_var of Typ.Procname.t (** local variable belonging to a function *) - | Callee_var of Typ.Procname.t (** local variable belonging to a callee *) - | Abduced_retvar of Typ.Procname.t * Location.t - (** synthetic variable to represent return value *) - | Abduced_ref_param of Typ.Procname.t * int * Location.t + | Local_var of Procname.t (** local variable belonging to a function *) + | Callee_var of Procname.t (** local variable belonging to a callee *) + | Abduced_retvar of Procname.t * Location.t (** synthetic variable to represent return value *) + | Abduced_ref_param of Procname.t * int * Location.t (** synthetic variable to represent param passed by reference *) | Global_var of { translation_unit: translation_unit @@ -38,7 +37,7 @@ type t = {pv_hash: int; pv_name: Mangled.t; pv_kind: pvar_kind} [@@deriving comp let get_name_of_local_with_procname var = match var.pv_kind with | Local_var pname -> - Mangled.from_string (F.asprintf "%s_%a" (Mangled.to_string var.pv_name) Typ.Procname.pp pname) + Mangled.from_string (F.asprintf "%s_%a" (Mangled.to_string var.pv_name) Procname.pp pname) | _ -> var.pv_name @@ -131,7 +130,7 @@ let is_frontend_tmp pvar = || match pvar.pv_kind with | Local_var pname -> - Typ.Procname.is_java pname && is_bytecode_tmp name + Procname.is_java pname && is_bytecode_tmp name | _ -> false @@ -218,7 +217,7 @@ let to_callee pname pvar = 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 : Typ.Procname.t) : t = +let mk (name : Mangled.t) (proc_name : Procname.t) : t = {pv_hash= name_hash name; pv_name= name; pv_kind= Local_var proc_name} @@ -228,7 +227,7 @@ let get_ret_param_pvar pname = mk Ident.name_return_param 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 : Typ.Procname.t) : t = +let mk_callee (name : Mangled.t) (proc_name : Procname.t) : t = {pv_hash= name_hash name; pv_name= name; pv_kind= Callee_var proc_name} @@ -250,15 +249,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 : Typ.Procname.t) (loc : Location.t) : t = - let name = Mangled.from_string (F.asprintf "$RET_%a" Typ.Procname.pp_unique_id proc_name) in +let mk_abduced_ret (proc_name : Procname.t) (loc : Location.t) : t = + let name = Mangled.from_string (F.asprintf "$RET_%a" Procname.pp_unique_id proc_name) in {pv_hash= name_hash name; pv_name= name; pv_kind= Abduced_retvar (proc_name, loc)} -let mk_abduced_ref_param (proc_name : Typ.Procname.t) (index : int) (loc : Location.t) : t = - let name = - Mangled.from_string (F.asprintf "$REF_PARAM_VAL_%a" Typ.Procname.pp_unique_id proc_name) - in +let mk_abduced_ref_param (proc_name : Procname.t) (index : int) (loc : Location.t) : t = + let name = Mangled.from_string (F.asprintf "$REF_PARAM_VAL_%a" Procname.pp_unique_id proc_name) in {pv_hash= name_hash name; pv_name= name; pv_kind= Abduced_ref_param (proc_name, index, loc)} @@ -286,12 +283,12 @@ let get_initializer_pname {pv_name; pv_kind} = match translation_unit with | Some file -> let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in - Typ.Procname.C - (Typ.Procname.C.c (QualifiedCppName.of_qual_string name) mangled [] Typ.NoTemplate) + Procname.C + (Procname.C.c (QualifiedCppName.of_qual_string name) mangled [] Typ.NoTemplate) |> Option.return | None -> None - else Some (Typ.Procname.from_string_c_fun name) + else Some (Procname.from_string_c_fun name) | _ -> None diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index 232919ea3..a820eabbd 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -27,7 +27,7 @@ val compare_modulo_this : t -> t -> int val equal : t -> t -> bool (** Equality for pvar's *) -val get_declaring_function : t -> Typ.Procname.t option +val get_declaring_function : t -> Procname.t option (** if not a global, return function declaring var *) val d : t -> unit @@ -36,10 +36,10 @@ val d : t -> unit val get_name : t -> Mangled.t (** Get the name component of a program variable. *) -val get_ret_pvar : Typ.Procname.t -> t +val get_ret_pvar : Procname.t -> t (** [get_ret_pvar proc_name] retuns the return pvar associated with the procedure name *) -val get_ret_param_pvar : Typ.Procname.t -> t +val get_ret_param_pvar : Procname.t -> t (** [get_ret_param_pvar proc_name] retuns the return_param pvar associated with the procedure name *) val get_simplified_name : t -> string @@ -92,16 +92,16 @@ val is_objc_static_local_of_proc_name : string -> t -> bool val is_block_pvar : t -> bool (** Check if a pvar is a local pointing to a block in objc *) -val mk : Mangled.t -> Typ.Procname.t -> t +val mk : Mangled.t -> Procname.t -> t (** [mk name proc_name] creates a program var with the given function name *) -val mk_abduced_ref_param : Typ.Procname.t -> int -> Location.t -> t +val mk_abduced_ref_param : Procname.t -> int -> Location.t -> t (** create an abduced variable for a parameter passed by reference *) -val mk_abduced_ret : Typ.Procname.t -> Location.t -> t +val mk_abduced_ret : Procname.t -> Location.t -> t (** create an abduced return variable for a call to [proc_name] at [loc] *) -val mk_callee : Mangled.t -> Typ.Procname.t -> t +val mk_callee : Mangled.t -> Procname.t -> t (** [mk_callee name proc_name] creates a program var for a callee function with the given function name *) @@ -116,7 +116,7 @@ val mk_global : -> t (** create a global variable with the given name *) -val mk_tmp : string -> Typ.Procname.t -> t +val mk_tmp : string -> Procname.t -> t (** create a fresh temporary variable local to procedure [pname]. for use in the frontends only! *) val pp : Pp.env -> F.formatter -> t -> unit @@ -130,7 +130,7 @@ val pp_value_non_verbose : F.formatter -> t -> unit val pp_translation_unit : F.formatter -> translation_unit -> unit -val to_callee : Typ.Procname.t -> t -> t +val to_callee : Procname.t -> t -> t (** Turn an ordinary program variable into a callee program variable *) val to_seed : t -> t @@ -154,7 +154,7 @@ val is_pod : t -> bool (** Is the variable's type a "Plain Old Data" type (C++)? Always (potentially incorrectly) returns [true] for non-globals. *) -val get_initializer_pname : t -> Typ.Procname.t option +val get_initializer_pname : t -> Procname.t option (** Get the procname of the initializer function for the given global variable *) val get_name_of_local_with_procname : t -> Mangled.t diff --git a/infer/src/IR/Sil.ml b/infer/src/IR/Sil.ml index 62164981d..7ea560956 100644 --- a/infer/src/IR/Sil.ml +++ b/infer/src/IR/Sil.ml @@ -194,7 +194,7 @@ let add_with_block_parameters_flag instr = | Call (ret_id_typ, Exp.Const (Const.Cfun pname), arg_ts, loc, cf) -> if List.exists ~f:(fun (exp, _) -> Exp.is_objc_block_closure exp) arg_ts - && Typ.Procname.is_clang pname + && Procname.is_clang pname (* to be extended to other methods *) then let cf' = {cf with cf_with_block_parameters= true} in diff --git a/infer/src/IR/SourceFiles.ml b/infer/src/IR/SourceFiles.ml index c9b866827..580b75d26 100644 --- a/infer/src/IR/SourceFiles.ml +++ b/infer/src/IR/SourceFiles.ml @@ -23,7 +23,7 @@ let get_existing_data source_file = SqliteUtils.result_option ~finalize:false db ~log:"looking for pre-existing source file data" stmt ~read_row:(fun stmt -> let tenv = Sqlite3.column stmt 0 |> Tenv.SQLite.deserialize - and proc_names = Sqlite3.column stmt 1 |> Typ.Procname.SQLiteList.deserialize in + and proc_names = Sqlite3.column stmt 1 |> Procname.SQLiteList.deserialize in (tenv, proc_names) ) ) @@ -64,7 +64,7 @@ let add source_file cfg tenv integer_type_widths = ~source_file:(SourceFile.SQLite.serialize source_file) ~tenv:(Tenv.SQLite.serialize tenv) ~integer_type_widths:(Typ.IntegerWidths.SQLite.serialize integer_type_widths) - ~proc_names:(Typ.Procname.SQLiteList.serialize proc_names) + ~proc_names:(Procname.SQLiteList.serialize proc_names) let get_all ~filter () = @@ -91,7 +91,7 @@ let proc_names_of_source source = |> SqliteUtils.check_result_code db ~log:"load bind source file" ; SqliteUtils.result_single_column_option ~finalize:false db ~log:"SourceFiles.proc_names_of_source" load_stmt - |> Option.value_map ~default:[] ~f:Typ.Procname.SQLiteList.deserialize ) + |> Option.value_map ~default:[] ~f:Procname.SQLiteList.deserialize ) let exists_source_statement = @@ -152,7 +152,7 @@ let select_all_source_files_statement = let pp_all ~filter ~type_environment ~procedure_names ~freshly_captured fmt () = let pp_procnames fmt procs = F.fprintf fmt "@[" ; - List.iter ~f:(F.fprintf fmt "%a@," Typ.Procname.pp) procs ; + List.iter ~f:(F.fprintf fmt "%a@," Procname.pp) procs ; F.fprintf fmt "@]" in let pp_if stmt title condition deserialize pp fmt column = @@ -163,8 +163,7 @@ let pp_all ~filter ~type_environment ~procedure_names ~freshly_captured fmt () = F.fprintf fmt "%a@,%a%a%a" SourceFile.pp source_file (pp_if stmt "type_environment" type_environment Tenv.SQLite.deserialize Tenv.pp_per_file) 1 - (pp_if stmt "procedure_names" procedure_names Typ.Procname.SQLiteList.deserialize - pp_procnames) + (pp_if stmt "procedure_names" procedure_names Procname.SQLiteList.deserialize pp_procnames) 2 (pp_if stmt "freshly_captured" freshly_captured deserialize_freshly_captured Format.pp_print_bool) diff --git a/infer/src/IR/SourceFiles.mli b/infer/src/IR/SourceFiles.mli index 85291f504..b5a677fc3 100644 --- a/infer/src/IR/SourceFiles.mli +++ b/infer/src/IR/SourceFiles.mli @@ -13,7 +13,7 @@ val add : SourceFile.t -> Cfg.t -> Tenv.per_file -> Typ.IntegerWidths.t option - val get_all : filter:Filtering.source_files_filter -> unit -> SourceFile.t list (** get all the source files in the database *) -val proc_names_of_source : SourceFile.t -> Typ.Procname.t list +val proc_names_of_source : SourceFile.t -> Procname.t list (** list of all the proc names (declared and defined) found in a source file *) val is_captured : SourceFile.t -> bool diff --git a/infer/src/IR/SpecializeProcdesc.ml b/infer/src/IR/SpecializeProcdesc.ml index 3ab9b0e7c..26a59dedf 100644 --- a/infer/src/IR/SpecializeProcdesc.ml +++ b/infer/src/IR/SpecializeProcdesc.ml @@ -104,7 +104,7 @@ let with_formals_types_proc callee_pdesc resolved_pdesc substitutions = when call_flags.CallFlags.cf_virtual && redirect_typename id <> None -> let redirected_typename = Option.value_exn (redirect_typename id) in let redirected_typ = mk_ptr_typ redirected_typename in - let redirected_pname = Typ.Procname.replace_class callee_pname redirected_typename in + let redirected_pname = Procname.replace_class callee_pname redirected_typename in let args = let other_args = List.map ~f:(fun (exp, typ) -> (convert_exp exp, typ)) origin_args in (Exp.Var id, redirected_typ) :: other_args @@ -152,8 +152,8 @@ let with_formals_types ?(has_clang_model = false) callee_pdesc resolved_pname ar result | Unequal_lengths -> L.(debug Analysis Medium) - "Call mismatch: method %a has %i paramters but is called with %i arguments@." - Typ.Procname.pp resolved_pname + "Call mismatch: method %a has %i paramters but is called with %i arguments@." Procname.pp + resolved_pname (List.length callee_attributes.formals) (List.length args) ; raise UnmatchedParameters @@ -171,7 +171,7 @@ let with_formals_types ?(has_clang_model = false) callee_pdesc resolved_pname ar Logging.die InternalError "specialize_types should only be called with defined procedures, but we cannot find \ the captured file of procname %a" - Typ.Procname.pp pname + Procname.pp pname else callee_attributes.translation_unit in let resolved_attributes = @@ -185,7 +185,7 @@ let with_formals_types ?(has_clang_model = false) callee_pdesc resolved_pname ar let resolved_proc_desc = with_formals_types_proc callee_pdesc resolved_proc_desc substitutions in (* The attributes here are used to retrieve the per-file type environment for Clang languages. The analysis for Java is using a global type environment *) - if not (Typ.Procname.is_java resolved_pname) then + if not (Procname.is_java resolved_pname) then Attributes.store ~proc_desc:(Some resolved_proc_desc) resolved_attributes ; resolved_proc_desc @@ -298,7 +298,7 @@ let with_block_args callee_pdesc pname_with_block_args block_args = let callee_attributes = Procdesc.get_attributes callee_pdesc in (* Substitution from a block parameter to the block name and the new formals that correspond to the captured variables *) - let substitutions : (Typ.Procname.t * (Mangled.t * Typ.t) list) Mangled.Map.t = + let substitutions : (Procname.t * (Mangled.t * Typ.t) list) Mangled.Map.t = List.fold2_exn callee_attributes.formals block_args ~init:Mangled.Map.empty ~f:(fun subts (param_name, _) block_arg_opt -> match block_arg_opt with @@ -341,7 +341,7 @@ let with_block_args callee_pdesc pname_with_block_args block_args = Logging.die InternalError "specialize_with_block_args ahould only be called with defined procedures, but we cannot \ find the captured file of procname %a" - Typ.Procname.pp pname + Procname.pp pname in let resolved_attributes = { callee_attributes with diff --git a/infer/src/IR/SpecializeProcdesc.mli b/infer/src/IR/SpecializeProcdesc.mli index 316717104..c27ee5d24 100644 --- a/infer/src/IR/SpecializeProcdesc.mli +++ b/infer/src/IR/SpecializeProcdesc.mli @@ -10,13 +10,13 @@ open! IStd exception UnmatchedParameters val with_formals_types : - ?has_clang_model:bool -> Procdesc.t -> Typ.Procname.t -> (Exp.t * Typ.t) list -> Procdesc.t + ?has_clang_model:bool -> Procdesc.t -> Procname.t -> (Exp.t * Typ.t) list -> Procdesc.t (** 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 *) -val with_block_args : Procdesc.t -> Typ.Procname.t -> Exp.closure option list -> Procdesc.t +val with_block_args : Procdesc.t -> Procname.t -> Exp.closure option list -> Procdesc.t (** Creates a copy of a procedure description given a list of possible closures that are passed as arguments to the method. The resulting procdesc is isomorphic but diff --git a/infer/src/IR/Struct.ml b/infer/src/IR/Struct.ml index b2f94cac4..f741413ab 100644 --- a/infer/src/IR/Struct.ml +++ b/infer/src/IR/Struct.ml @@ -17,9 +17,8 @@ type t = { fields: fields (** non-static fields *) ; statics: fields (** static fields *) ; supers: Typ.Name.t list (** superclasses *) - ; methods: Typ.Procname.t list (** methods defined *) - ; exported_objc_methods: Typ.Procname.t list - (** methods in ObjC interface, subset of [methods] *) + ; methods: Procname.t list (** methods defined *) + ; exported_objc_methods: Procname.t list (** methods in ObjC interface, subset of [methods] *) ; annots: Annot.Item.t (** annotations *) ; dummy: bool (** dummy struct for class including static method *) } @@ -49,9 +48,9 @@ let pp pe name f {fields; supers; methods; exported_objc_methods; annots} = fields (Pp.seq (fun f n -> F.fprintf f "@\n\t\t%a" Typ.Name.pp n)) supers - (Pp.seq (fun f m -> F.fprintf f "@\n\t\t%a" Typ.Procname.pp m)) + (Pp.seq (fun f m -> F.fprintf f "@\n\t\t%a" Procname.pp m)) methods - (Pp.seq (fun f m -> F.fprintf f "@\n\t\t%a" Typ.Procname.pp m)) + (Pp.seq (fun f m -> F.fprintf f "@\n\t\t%a" Procname.pp m)) exported_objc_methods Annot.Item.pp annots else Typ.Name.pp f name diff --git a/infer/src/IR/Struct.mli b/infer/src/IR/Struct.mli index e030a2671..2c6740e4f 100644 --- a/infer/src/IR/Struct.mli +++ b/infer/src/IR/Struct.mli @@ -18,9 +18,8 @@ type t = private { fields: fields (** non-static fields *) ; statics: fields (** static fields *) ; supers: Typ.Name.t list (** supers *) - ; methods: Typ.Procname.t list (** methods defined *) - ; exported_objc_methods: Typ.Procname.t list - (** methods in ObjC interface, subset of [methods] *) + ; methods: Procname.t list (** methods defined *) + ; exported_objc_methods: Procname.t list (** methods in ObjC interface, subset of [methods] *) ; annots: Annot.Item.t (** annotations *) ; dummy: bool (** dummy struct for class including static method *) } @@ -35,8 +34,8 @@ val internal_mk_struct : ?default:t -> ?fields:fields -> ?statics:fields - -> ?methods:Typ.Procname.t list - -> ?exported_objc_methods:Typ.Procname.t list + -> ?methods:Procname.t list + -> ?exported_objc_methods:Procname.t list -> ?supers:Typ.Name.t list -> ?annots:Annot.Item.t -> ?dummy:bool diff --git a/infer/src/IR/Tenv.mli b/infer/src/IR/Tenv.mli index 253dd9c87..d9e4b5b88 100644 --- a/infer/src/IR/Tenv.mli +++ b/infer/src/IR/Tenv.mli @@ -37,8 +37,8 @@ val mk_struct : -> ?default:Struct.t -> ?fields:Struct.fields -> ?statics:Struct.fields - -> ?methods:Typ.Procname.t list - -> ?exported_objc_methods:Typ.Procname.t list + -> ?methods:Procname.t list + -> ?exported_objc_methods:Procname.t list -> ?supers:Typ.Name.t list -> ?annots:Annot.Item.t -> ?dummy:bool diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index aa9174ba9..d6ce4e420 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -265,8 +265,24 @@ let void = mk Tvoid let void_star = mk (Tptr (mk Tvoid, Pk_pointer)) +let java_byte = mk (Tint IShort) + +let java_short = java_byte + +let boolean = mk (Tint IBool) + +let char = mk (Tint IChar) + +let float = mk (Tfloat FFloat) + +let double = mk (Tfloat FDouble) + +let int = mk (Tint IInt) + let uint = mk (Tint IUInt) +let long = mk (Tint ILong) + let get_ikind_opt {desc} = match desc with Tint ikind -> Some ikind | _ -> None (* TODO: size_t should be implementation-dependent. *) @@ -431,7 +447,7 @@ module Name = struct (** e.g. {type_name="int"; package=None} for primitive types * or {type_name="PrintWriter"; package=Some "java.io"} for objects. *) - type t = {package: string option; type_name: string} + type t = {package: string option; type_name: string} [@@deriving compare] let make ?package type_name = {type_name; package} @@ -454,6 +470,12 @@ module Name = struct let java_lang_string = make ~package:"java.lang" "String" let void = make "void" + + let pp_type_verbosity ~verbose fmt = function + | {package= Some package; type_name} when verbose -> + F.fprintf fmt "%s.%s" package type_name + | {type_name} -> + F.pp_print_string fmt type_name end let from_string name_str = JavaClass (Mangled.from_string name_str) @@ -597,826 +619,3 @@ let has_block_prefix s = type typ = t - -module Procname = struct - (** 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 is_verbose v = match v with Verbose -> true | _ -> false - - module Java = struct - type kind = - | Non_Static - (** in Java, procedures called with invokevirtual, invokespecial, and invokeinterface *) - | Static (** in Java, procedures called with invokestatic *) - [@@deriving compare] - - (* TODO: use Mangled.t here *) - type java_type = Name.Java.Split.t = {package: string option; type_name: string} - [@@deriving compare] - - let java_void = {package= None; type_name= "void"} - - (** Type of java procedure names. *) - type t = - { method_name: string - ; parameters: java_type list - ; class_name: Name.t - ; return_type: java_type option (* option because constructors have no return type *) - ; kind: kind } - [@@deriving compare] - - let make class_name return_type method_name parameters kind = - {class_name; return_type; method_name; parameters; kind} - - - (** A type is a pair (package, type_name) that is translated in a string package.type_name *) - let pp_type_verbosity verbosity fmt p = - match p with - | {package= Some package; type_name} when is_verbose verbosity -> - F.fprintf fmt "%s.%s" package type_name - | {type_name} -> - F.pp_print_string fmt type_name - - - (** Given a list of types, it creates a unique string of types separated by commas *) - let rec pp_param_list verbosity fmt inputList = - match inputList with - | [] -> - () - | [head] -> - pp_type_verbosity verbosity fmt head - | head :: rest -> - pp_type_verbosity verbosity fmt head ; - F.pp_print_string fmt "," ; - pp_param_list verbosity fmt rest - - - let java_type_of_name class_name = Name.Java.Split.of_string (Name.name class_name) - - (** It is the same as java_type_to_string_verbosity, but Java return types are optional because - of constructors without type *) - let pp_return_type verbosity fmt j = - match j.return_type with None -> () | Some typ -> pp_type_verbosity verbosity fmt typ - - - let get_class_name j = Name.name j.class_name - - let get_class_type_name j = j.class_name - - let get_simple_class_name j = Name.Java.Split.(j |> get_class_name |> of_string |> type_name) - - let get_package j = Name.Java.Split.(j |> get_class_name |> of_string |> package) - - let get_method j = j.method_name - - let replace_method_name method_name j = {j with method_name} - - let replace_parameters parameters j = {j with parameters} - - let replace_return_type ret_type j = {j with return_type= Some ret_type} - - let get_parameters j = j.parameters - - (** Prints a string of a java procname with the given level of verbosity *) - let pp ?(withclass = false) verbosity fmt j = - match verbosity with - | 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 pp_class_name verbosity fmt j = - pp_type_verbosity verbosity fmt (Name.Java.split_typename j.class_name) - in - let separator = - match (j.return_type, verbosity) with - | None, _ -> - "" - | Some _, Verbose -> - ":" - | _ -> - " " - in - if not (equal_detail_level verbosity Verbose) then - F.fprintf fmt "%a%s" (pp_return_type verbosity) j separator ; - F.fprintf fmt "%a.%s(%a)" (pp_class_name verbosity) j j.method_name - (pp_param_list verbosity) j.parameters ; - if equal_detail_level verbosity Verbose then - F.fprintf fmt "%s%a" separator (pp_return_type verbosity) j - | Simple -> - (* methodname(...) or without ... if there are no parameters *) - let pp_class_prefix ~withclass verbosity fmt j = - if withclass then - F.fprintf fmt "%a." (pp_type_verbosity verbosity) - (Name.Java.split_typename j.class_name) - in - let params = match j.parameters with [] -> "" | _ -> "..." in - let pp_method_name ~withclass verbosity fmt j = - if String.equal j.method_name "" then - F.pp_print_string fmt (get_simple_class_name j) - else F.fprintf fmt "%a%s" (pp_class_prefix ~withclass verbosity) j j.method_name - in - F.fprintf fmt "%a(%s)" (pp_method_name ~withclass verbosity) j params - - - let get_return_typ pname_java = - let rec java_from_string = function - | "" | "void" -> - mk Tvoid - | "int" -> - mk (Tint IInt) - | "byte" -> - mk (Tint IShort) - | "short" -> - mk (Tint IShort) - | "boolean" -> - mk (Tint IBool) - | "char" -> - mk (Tint IChar) - | "long" -> - mk (Tint ILong) - | "float" -> - mk (Tfloat FFloat) - | "double" -> - mk (Tfloat FDouble) - | typ_str when String.contains typ_str '[' -> - let stripped_typ = String.sub typ_str ~pos:0 ~len:(String.length typ_str - 2) in - mk (Tptr (mk_array (java_from_string stripped_typ), Pk_pointer)) - | typ_str -> - mk (Tstruct (Name.Java.from_string typ_str)) - in - let typ = java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java) in - match typ.desc with Tstruct _ -> mk (Tptr (typ, Pk_pointer)) | _ -> typ - - - let is_close {method_name} = String.equal method_name "close" - - let constructor_method_name = "" - - let class_initializer_method_name = "" - - let is_class_initializer {method_name} = String.equal method_name class_initializer_method_name - - let get_class_initializer class_name = - { method_name= class_initializer_method_name - ; parameters= [] - ; class_name - ; return_type= Some java_void - ; kind= Static } - - - let is_constructor {method_name} = String.equal method_name constructor_method_name - - let is_anonymous_inner_class_constructor {class_name} = - Name.Java.is_anonymous_inner_class_name class_name - - - let is_static {kind} = match kind with Static -> true | _ -> false - - let is_lambda {method_name} = String.is_prefix ~prefix:"lambda$" method_name - - let is_generated {method_name} = String.is_prefix ~prefix:"$" method_name - - let is_access_method {method_name} = - match String.rsplit2 method_name ~on:'$' with - | Some ("access", s) -> - let is_int = - try - ignore (int_of_string s) ; - true - with Failure _ -> false - in - is_int - | _ -> - false - - - let is_autogen_method {method_name} = String.contains method_name '$' - - (** Check if the proc name has the type of a java vararg. - Note: currently only checks that the last argument has type Object[]. *) - let is_vararg {parameters} = - match List.last parameters with Some {type_name= "java.lang.Object[]"} -> true | _ -> false - - - let is_external java_pname = - let package = get_package java_pname in - Option.exists ~f:Config.java_package_is_external package - end - - module Parameter = struct - (** Type for parameters in clang procnames, [Some name] means the parameter is of type pointer to struct, with [name] - being the name of the struct, [None] means the parameter is of some other type. *) - type clang_parameter = Name.t option [@@deriving compare] - - (** Type for parameters in procnames, for java and clang. *) - type t = JavaParameter of Java.java_type | ClangParameter of clang_parameter - [@@deriving compare] - - let of_typ typ = - match typ.T.desc with T.Tptr ({desc= Tstruct name}, Pk_pointer) -> Some name | _ -> None - - - let pp_parameters fmt parameters = - if List.exists ~f:Option.is_some parameters then - (* the tests rely on the fact that we discard non-pointer-to-struct types for some reason, - hence the slight re-implementation of [Pp.seq] to avoid building the list of [Some] items - explicitly *) - let rec pp_parameters_aux fmt = function - | [] -> - () - | [Some param] -> - F.pp_print_string fmt (Name.to_string param) - | None :: parameters -> - pp_parameters_aux fmt parameters - | (Some _ as param_some) :: None :: parameters -> - pp_parameters_aux fmt (param_some :: parameters) - | Some param :: (Some _ :: _ as parameters) -> - F.fprintf fmt "%s," (Name.to_string param) ; - pp_parameters_aux fmt parameters - in - F.fprintf fmt "(%a)" pp_parameters_aux parameters - - - let clang_param_of_name class_name : clang_parameter = Some class_name - end - - module ObjC_Cpp = struct - type kind = - | CPPMethod of {mangled: string option} - | CPPConstructor of {mangled: string option; is_constexpr: bool} - | CPPDestructor of {mangled: string option} - | ObjCClassMethod - | ObjCInstanceMethod - | ObjCInternalMethod - [@@deriving compare] - - type t = - { class_name: Name.t - ; kind: kind - ; method_name: string - ; parameters: Parameter.clang_parameter list - ; template_args: template_spec_info } - [@@deriving compare] - - let make class_name method_name kind template_args parameters = - {class_name; method_name; kind; template_args; parameters} - - - let get_class_name objc_cpp = Name.name objc_cpp.class_name - - let get_class_type_name objc_cpp = objc_cpp.class_name - - let get_class_qualifiers objc_cpp = Name.qual_name objc_cpp.class_name - - let objc_method_kind_of_bool is_instance = - if is_instance then ObjCInstanceMethod else ObjCClassMethod - - - let is_objc_constructor method_name = - String.equal method_name "new" || String.is_prefix ~prefix:"init" method_name - - - let is_objc_kind = function - | ObjCClassMethod | ObjCInstanceMethod | ObjCInternalMethod -> - true - | _ -> - false - - - let is_objc_method {kind} = is_objc_kind kind - - let is_objc_dealloc method_name = String.equal method_name "dealloc" - - let is_destructor = function - | {kind= CPPDestructor _} -> - true - | name -> - is_objc_dealloc name.method_name - - - let is_inner_destructor ({method_name} as pname) = - is_destructor pname - && String.is_prefix ~prefix:Config.clang_inner_destructor_prefix method_name - - - let is_constexpr = function {kind= CPPConstructor {is_constexpr= true}} -> true | _ -> false - - let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name - - let pp_verbose_kind fmt = function - | CPPMethod {mangled} | CPPDestructor {mangled} -> - F.fprintf fmt "(%s)" (Option.value ~default:"" mangled) - | CPPConstructor {mangled; is_constexpr} -> - F.fprintf fmt "{%s%s}" - (Option.value ~default:"" mangled) - (if is_constexpr then "|constexpr" else "") - | ObjCClassMethod -> - F.pp_print_string fmt "class" - | ObjCInstanceMethod -> - F.pp_print_string fmt "instance" - | ObjCInternalMethod -> - F.pp_print_string fmt "internal" - - - let pp verbosity fmt osig = - match verbosity with - | Simple -> - F.pp_print_string fmt osig.method_name - | Non_verbose -> - F.fprintf fmt "%s::%s" (Name.name osig.class_name) osig.method_name - | Verbose -> - F.fprintf fmt "%s::%s%a%a" (Name.name osig.class_name) osig.method_name - Parameter.pp_parameters osig.parameters pp_verbose_kind osig.kind - - - let get_parameters osig = osig.parameters - - let replace_parameters new_parameters osig = {osig with parameters= new_parameters} - end - - module C = struct - (** Type of c procedure names. *) - type t = - { name: QualifiedCppName.t - ; mangled: string option - ; parameters: Parameter.clang_parameter list - ; template_args: template_spec_info } - [@@deriving compare] - - let c name mangled parameters template_args = - {name; mangled= Some mangled; parameters; template_args} - - - let from_string name = - { name= QualifiedCppName.of_qual_string name - ; mangled= None - ; parameters= [] - ; template_args= NoTemplate } - - - let pp verbosity fmt {name; mangled; parameters} = - let plain = QualifiedCppName.to_qual_string name in - match verbosity with - | Simple -> - F.fprintf fmt "%s()" plain - | Non_verbose -> - F.pp_print_string fmt plain - | Verbose -> - let pp_mangled fmt = function None -> () | Some s -> F.fprintf fmt "{%s}" s in - F.fprintf fmt "%s%a%a" plain Parameter.pp_parameters parameters pp_mangled mangled - - - let get_parameters c = c.parameters - - let replace_parameters new_parameters c = {c with parameters= new_parameters} - end - - module Block = struct - (** Type of Objective C block names. *) - type block_name = string [@@deriving compare] - - type t = {name: block_name; parameters: Parameter.clang_parameter list} [@@deriving compare] - - let make name parameters = {name; parameters} - - let pp verbosity fmt bsig = - match verbosity with - | Simple -> - F.pp_print_string fmt "block" - | Non_verbose -> - F.pp_print_string fmt bsig.name - | Verbose -> - F.fprintf fmt "%s%a" bsig.name Parameter.pp_parameters bsig.parameters - - - let get_parameters block = block.parameters - - let replace_parameters new_parameters block = {block with parameters= new_parameters} - end - - (** Type of procedure names. *) - type t = - | Java of Java.t - | C of C.t - | Linters_dummy_method - | Block of Block.t - | ObjC_Cpp of ObjC_Cpp.t - | WithBlockParameters of t * Block.block_name list - [@@deriving compare] - - let equal = [%compare.equal: t] - - (** hash function for procname *) - let hash = Hashtbl.hash - - let with_block_parameters base blocks = WithBlockParameters (base, blocks) - - let is_java = function Java _ -> true | _ -> false - - (* TODO: deprecate this unfortunately named function and use is_clang instead *) - let is_c_method = function ObjC_Cpp _ -> true | _ -> false - - let is_c_function = function C _ -> true | _ -> false - - let is_clang = function - | ObjC_Cpp name -> - ObjC_Cpp.is_objc_method name - | name -> - is_c_function name - - - let is_java_lift f = function Java java_pname -> f java_pname | _ -> false - - let is_java_access_method = is_java_lift Java.is_access_method - - let is_java_class_initializer = is_java_lift Java.is_class_initializer - - let is_objc_method procname = - match procname with ObjC_Cpp name -> ObjC_Cpp.is_objc_method name | _ -> false - - - let block_name_of_procname procname = - match procname with - | Block block -> - block.name - | _ -> - Logging.die InternalError "Only to be called with Objective-C block names" - - - let empty_block = Block {name= ""; parameters= []} - - (** Replace the class name component of a procedure name. - In case of Java, replace package and class name. *) - let rec replace_class t (new_class : Name.t) = - match t with - | Java j -> - Java {j with class_name= new_class} - | ObjC_Cpp osig -> - ObjC_Cpp {osig with class_name= new_class} - | WithBlockParameters (base, blocks) -> - WithBlockParameters (replace_class base new_class, blocks) - | C _ | Block _ | Linters_dummy_method -> - t - - - let get_class_type_name = function - | Java java_pname -> - Some (Java.get_class_type_name java_pname) - | ObjC_Cpp objc_pname -> - Some (ObjC_Cpp.get_class_type_name objc_pname) - | _ -> - None - - - let get_class_name = function - | Java java_pname -> - Some (Java.get_class_name java_pname) - | ObjC_Cpp objc_pname -> - Some (ObjC_Cpp.get_class_name objc_pname) - | _ -> - None - - - let is_method_in_objc_protocol t = - match t with ObjC_Cpp osig -> Name.is_objc_protocol osig.class_name | _ -> false - - - let rec objc_cpp_replace_method_name t (new_method_name : string) = - match t with - | ObjC_Cpp osig -> - ObjC_Cpp {osig with method_name= new_method_name} - | WithBlockParameters (base, blocks) -> - WithBlockParameters (objc_cpp_replace_method_name base new_method_name, blocks) - | C _ | Block _ | Linters_dummy_method | Java _ -> - t - - - (** Return the method/function of a procname. *) - let rec get_method = function - | ObjC_Cpp name -> - name.method_name - | WithBlockParameters (base, _) -> - get_method base - | C {name} -> - QualifiedCppName.to_qual_string name - | Block {name} -> - name - | Java j -> - j.method_name - | Linters_dummy_method -> - "Linters_dummy_method" - - - (** Return whether the procname is a block procname. *) - let is_objc_block = function Block _ -> true | _ -> false - - (** Return the language of the procedure. *) - let get_language = function - | ObjC_Cpp _ -> - Language.Clang - | C _ -> - Language.Clang - | Block _ -> - Language.Clang - | Linters_dummy_method -> - Language.Clang - | WithBlockParameters _ -> - Language.Clang - | Java _ -> - Language.Java - - - (** [is_constructor pname] returns true if [pname] is a constructor *) - let is_constructor = function - | Java js -> - String.equal js.method_name Java.constructor_method_name - | ObjC_Cpp {kind= CPPConstructor _} -> - true - | ObjC_Cpp {kind; method_name} when ObjC_Cpp.is_objc_kind kind -> - ObjC_Cpp.is_objc_constructor method_name - | _ -> - false - - - (** [is_infer_undefined pn] returns true if [pn] is a special Infer undefined proc *) - let is_infer_undefined pn = - match pn with - | Java j -> - let regexp = Str.regexp_string "com.facebook.infer.builtins.InferUndefined" in - 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 = function - | C {name} - when String.is_prefix ~prefix:Config.clang_initializer_prefix - (QualifiedCppName.to_qual_string name) -> - let name_str = QualifiedCppName.to_qual_string name in - let prefix_len = String.length Config.clang_initializer_prefix in - Some (String.sub name_str ~pos:prefix_len ~len:(String.length name_str - prefix_len)) - | _ -> - None - - - (** Very verbose representation of an existing Procname.t *) - let rec pp_unique_id fmt = function - | Java j -> - Java.pp Verbose fmt j - | C osig -> - C.pp Verbose fmt osig - | ObjC_Cpp osig -> - ObjC_Cpp.pp Verbose fmt osig - | Block bsig -> - Block.pp Verbose fmt bsig - | WithBlockParameters (base, []) -> - pp_unique_id fmt base - | WithBlockParameters (base, (_ :: _ as blocks)) -> - pp_unique_id fmt base ; - F.pp_print_string fmt "_" ; - Pp.seq ~sep:"_" F.pp_print_string fmt blocks - | Linters_dummy_method -> - F.pp_print_string fmt "Linters_dummy_method" - - - let to_unique_id proc_name = F.asprintf "%a" pp_unique_id proc_name - - (** Convert a proc name to a string for the user to see *) - let rec pp fmt = function - | Java j -> - Java.pp Non_verbose fmt j - | C osig -> - C.pp Non_verbose fmt osig - | ObjC_Cpp osig -> - ObjC_Cpp.pp Non_verbose fmt osig - | Block bsig -> - Block.pp Non_verbose fmt bsig - | WithBlockParameters (base, []) -> - pp fmt base - | WithBlockParameters (base, (_ :: _ as blocks)) -> - pp fmt base ; - F.pp_print_string fmt "_" ; - Pp.seq ~sep:"_" F.pp_print_string fmt blocks - | Linters_dummy_method -> - pp_unique_id fmt Linters_dummy_method - - - let to_string proc_name = F.asprintf "%a" pp proc_name - - (** Convenient representation of a procname for external tools (e.g. eclipse plugin) *) - let rec pp_simplified_string ?(withclass = false) fmt = function - | Java j -> - Java.pp ~withclass Simple fmt j - | C osig -> - C.pp Simple fmt osig - | ObjC_Cpp osig -> - ObjC_Cpp.pp Simple fmt osig - | Block bsig -> - Block.pp Simple fmt bsig - | WithBlockParameters (base, _) -> - pp_simplified_string fmt base - | Linters_dummy_method -> - pp_unique_id fmt Linters_dummy_method - - - let to_simplified_string ?withclass proc_name = - F.asprintf "%a" (pp_simplified_string ?withclass) proc_name - - - let from_string_c_fun func = C (C.from_string func) - - let java_inner_class_prefix_regex = Str.regexp "\\$[0-9]+" - - let hashable_name proc_name = - match proc_name with - | Java pname -> ( - (* Strip autogenerated anonymous inner class numbers in order to keep the bug hash - invariant when introducing new anonymous classes *) - let name = F.asprintf "%a" (Java.pp ~withclass:true Simple) pname in - match Str.search_forward java_inner_class_prefix_regex name 0 with - | _ -> - Str.global_replace java_inner_class_prefix_regex "$_" name - | exception Caml.Not_found -> - name ) - | ObjC_Cpp m when ObjC_Cpp.is_objc_method m -> - (* In Objective C, the list of parameters is part of the method name. To prevent the bug - hash to change when a parameter is introduced or removed, only the part of the name - before the first colon is used for the bug hash *) - let name = F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name in - List.hd_exn (String.split_on_chars name ~on:[':']) - | _ -> - (* Other cases for C and C++ method names *) - F.asprintf "%a" (pp_simplified_string ~withclass:true) proc_name - - - let rec get_parameters procname = - let clang_param_to_param clang_params = - List.map ~f:(fun par -> Parameter.ClangParameter par) clang_params - in - match procname with - | Java j -> - List.map ~f:(fun par -> Parameter.JavaParameter par) (Java.get_parameters j) - | C osig -> - clang_param_to_param (C.get_parameters osig) - | ObjC_Cpp osig -> - clang_param_to_param (ObjC_Cpp.get_parameters osig) - | Block bsig -> - clang_param_to_param (Block.get_parameters bsig) - | WithBlockParameters (base, _) -> - get_parameters base - | Linters_dummy_method -> - [] - - - let rec replace_parameters new_parameters procname = - let params_to_java_params params = - List.map - ~f:(fun param -> - match param with - | Parameter.JavaParameter par -> - par - | _ -> - Logging.(die InternalError) - "Expected Java parameters in Java procname, but got Clang parameters" params ) - params - in - let params_to_clang_params params = - List.map - ~f:(fun param -> - match param with - | Parameter.ClangParameter par -> - par - | _ -> - Logging.(die InternalError) - "Expected Clang parameters in Clang procname, but got Java parameters" params ) - params - in - match procname with - | Java j -> - Java (Java.replace_parameters (params_to_java_params new_parameters) j) - | C osig -> - C (C.replace_parameters (params_to_clang_params new_parameters) osig) - | ObjC_Cpp osig -> - ObjC_Cpp (ObjC_Cpp.replace_parameters (params_to_clang_params new_parameters) osig) - | Block bsig -> - Block (Block.replace_parameters (params_to_clang_params new_parameters) bsig) - | WithBlockParameters (base, blocks) -> - WithBlockParameters (replace_parameters new_parameters base, blocks) - | Linters_dummy_method -> - procname - - - let parameter_of_name procname class_name = - match procname with - | Java _ -> - Parameter.JavaParameter (Java.java_type_of_name class_name) - | _ -> - Parameter.ClangParameter (Parameter.clang_param_of_name class_name) - - - let describe f pn = - let name = hashable_name pn in - match String.lsplit2 ~on:'<' name with - | Some (name_without_template, _template_part) -> - F.pp_print_string f name_without_template - | None -> - F.pp_print_string f name - - - module Hashable = struct - type nonrec t = t - - let equal = equal - - let hash = hash - end - - module Hash = Hashtbl.Make (Hashable) - - module Map = PrettyPrintable.MakePPMap (struct - type nonrec t = t - - let compare = compare - - let pp = pp - end) - - module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare - - let pp = pp - end) - - let get_qualifiers pname = - match pname with - | C {name} -> - name - | ObjC_Cpp objc_cpp -> - ObjC_Cpp.get_class_qualifiers objc_cpp - |> QualifiedCppName.append_qualifier ~qual:objc_cpp.method_name - | _ -> - QualifiedCppName.empty - - - (** Convert a proc name to a filename *) - let to_filename ?crc_only pname = - (* filenames for clang procs are REVERSED qualifiers with '#' as separator *) - let pp_rev_qualified fmt pname = - let rev_qualifiers = get_qualifiers pname |> QualifiedCppName.to_rev_list in - Pp.seq ~sep:"#" F.pp_print_string fmt rev_qualifiers - in - let proc_id = - match pname with - | C {parameters; mangled} -> - let pp_mangled fmt = function - | None -> - () - | Some mangled -> - F.fprintf fmt "#%s" mangled - in - F.asprintf "%a%a%a" pp_rev_qualified pname Parameter.pp_parameters parameters pp_mangled - mangled - | ObjC_Cpp objc_cpp -> - F.asprintf "%a%a#%a" pp_rev_qualified pname Parameter.pp_parameters objc_cpp.parameters - ObjC_Cpp.pp_verbose_kind objc_cpp.kind - | _ -> - F.asprintf "%a" pp_unique_id pname - in - Escape.escape_filename @@ DB.append_crc_cutoff ?crc_only proc_id - - - module SQLite = struct - module T = struct - type nonrec t = t - - let compare = compare - - let hash = hash - - let sexp_of_t p = Sexp.Atom (F.asprintf "%a" pp p) - end - - module Serializer = SqliteUtils.MarshalledDataForComparison (T) - - let pname_to_key = Base.Hashtbl.create (module T) - - let serialize pname = - let default () = Serializer.serialize pname in - Base.Hashtbl.find_or_add pname_to_key pname ~default - - - let deserialize = Serializer.deserialize - - let clear_cache () = Base.Hashtbl.clear pname_to_key - end - - module SQLiteList = SqliteUtils.MarshalledDataNOTForComparison (struct - type nonrec t = t list - end) -end diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index 24e3fb43e..f5ebb092d 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -137,9 +137,26 @@ val mk_array : ?default:t -> ?quals:type_quals -> ?length:IntLit.t -> ?stride:In val void : t (** void type *) +val java_byte : t + +val java_short : t + +val boolean : t + +val char : t + +val int : t +(** signed int type *) + val uint : t (** unsigned int type *) +val long : t + +val float : t + +val double : t + val void_star : t (** void* type *) @@ -186,6 +203,8 @@ module Name : sig val get_template_spec_info : t -> template_spec_info option + val is_objc_protocol : t -> bool + module C : sig val from_string : string -> t @@ -196,10 +215,12 @@ module Name : sig module Java : sig module Split : sig - type t + type t [@@deriving compare] val make : ?package:string -> string -> t + val of_string : string -> t + val java_lang_object : t val java_lang_string : t @@ -209,6 +230,8 @@ module Name : sig val package : t -> string option val type_name : t -> string + + val pp_type_verbosity : verbose:bool -> F.formatter -> t -> unit end val from_string : string -> t @@ -230,6 +253,10 @@ module Name : sig (** Given an inner classname like C$Inner1$Inner2, return Some C$Inner1. If the class is not an inner class, return None *) + val is_anonymous_inner_class_name : t -> bool + + val split_typename : t -> Split.t + val java_lang_object : t val java_io_serializable : t @@ -326,311 +353,3 @@ val has_block_prefix : string -> bool val unsome : string -> t option -> t type typ = t - -module Procname : sig - (** Module for Procedure Names. *) - - (** Type of java procedure names. *) - module Java : sig - type kind = - | Non_Static - (** in Java, procedures called with invokevirtual, invokespecial, and invokeinterface *) - | Static (** in Java, procedures called with invokestatic *) - - type t [@@deriving compare] - - type java_type = Name.Java.Split.t - - val constructor_method_name : string - - val class_initializer_method_name : string - - val compare_java_type : java_type -> java_type -> int - - val make : Name.t -> java_type option -> string -> java_type list -> kind -> t - (** Create a Java procedure name from its - class_name method_name args_type_name return_type_name method_kind. *) - - val replace_method_name : string -> t -> t - (** Replace the method name of an existing java procname. *) - - val replace_parameters : java_type list -> t -> t - (** Replace the parameters of a java procname. *) - - val replace_return_type : java_type -> t -> t - (** Replace the method of a java procname. *) - - val get_class_name : t -> string - (** Return the fully qualified class name of a java procedure name (package + class name) *) - - val get_class_type_name : t -> Name.t - (** Return the class name as a typename of a java procedure name. *) - - val get_simple_class_name : t -> string - (** Return the simple class name of a java procedure name (i.e. name without the package info). *) - - val get_package : t -> string option - (** Return the package name of a java procedure name. *) - - val get_method : t -> string - (** Return the method name of a java procedure name. *) - - val get_parameters : t -> java_type list - (** Return the parameters of a java procedure name. *) - - val get_return_typ : t -> typ - (** Return the return type of [pname_java]. return Tvoid if there's no return type *) - - val is_constructor : t -> bool - (** Whether the method is constructor *) - - val is_access_method : t -> bool - (** Check if the procedure name is an acess method (e.g. access$100 used to - access private members from a nested class. *) - - val is_autogen_method : t -> bool - (** Check if the procedure name is of an auto-generated method containing '$'. *) - - val is_anonymous_inner_class_constructor : t -> bool - (** Check if the procedure name is an anonymous inner class constructor. *) - - val is_close : t -> bool - (** Check if the method name is "close". *) - - val is_static : t -> bool - (** Check if the java procedure is static. *) - - val is_vararg : 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[]. *) - - val is_lambda : t -> bool - (** Check if the proc name comes from a lambda expression *) - - val is_generated : t -> bool - (** Check if the proc name comes from generated code *) - - val is_class_initializer : t -> bool - (** Check if this is a class initializer. *) - - val get_class_initializer : Name.t -> t - (** Given a java class, generate the procname of its static initializer. *) - - val is_external : t -> bool - (** Check if the method belongs to one of the specified external packages *) - end - - module Parameter : sig - (** Type for parameters in clang procnames, [Some name] means the parameter is of type pointer to struct, with [name] -being the name of the struct, [None] means the parameter is of some other type. *) - type clang_parameter = Name.t option [@@deriving compare] - - (** Type for parameters in procnames, for java and clang. *) - type t = JavaParameter of Java.java_type | ClangParameter of clang_parameter - [@@deriving compare] - - val of_typ : typ -> clang_parameter - end - - module ObjC_Cpp : sig - type kind = - | CPPMethod of {mangled: string option} - | CPPConstructor of {mangled: string option; is_constexpr: bool} - | CPPDestructor of {mangled: string option} - | ObjCClassMethod - | ObjCInstanceMethod - | ObjCInternalMethod - [@@deriving compare] - - (** Type of Objective C and C++ procedure names: method signatures. *) - type t = - { class_name: Name.t - ; kind: kind - ; method_name: string - ; parameters: Parameter.clang_parameter list - ; template_args: template_spec_info } - [@@deriving compare] - - val make : Name.t -> string -> kind -> template_spec_info -> Parameter.clang_parameter list -> t - (** Create an objc procedure name from a class_name and method_name. *) - - val get_class_name : t -> string - - val get_class_type_name : t -> Name.t [@@warning "-32"] - - val get_class_qualifiers : t -> QualifiedCppName.t - - val objc_method_kind_of_bool : bool -> kind - (** Create ObjC method type from a bool is_instance. *) - - val is_objc_constructor : string -> bool - (** Check if this is a constructor method in Objective-C. *) - - val is_objc_dealloc : string -> bool - (** Check if this is a dealloc method in Objective-C. *) - - val is_destructor : t -> bool - (** Check if this is a dealloc method. *) - - val is_inner_destructor : t -> bool - (** Check if this is a frontend-generated "inner" destructor (see D5834555/D7189239) *) - - val is_constexpr : t -> bool - (** Check if this is a constexpr function. *) - - val is_cpp_lambda : t -> bool - (** Return whether the procname is a cpp lambda. *) - end - - module C : sig - (** Type of c procedure names. *) - type t = private - { name: QualifiedCppName.t - ; mangled: string option - ; parameters: Parameter.clang_parameter list - ; template_args: template_spec_info } - - val c : - QualifiedCppName.t -> string -> Parameter.clang_parameter list -> template_spec_info -> t - (** Create a C procedure name from plain and mangled name. *) - end - - module Block : sig - (** Type of Objective C block names. *) - type block_name = string - - type t = {name: block_name; parameters: Parameter.clang_parameter list} [@@deriving compare] - - val make : block_name -> Parameter.clang_parameter list -> t - end - - (** Type of procedure names. - WithBlockParameters is used for creating an instantiation of a method that contains block parameters - and it's called with concrete blocks. For example: - foo(Block block) {block();} - bar() {foo(my_block)} is executed as foo_my_block() {my_block(); } - where foo_my_block is created with WithBlockParameters (foo, [my_block]) *) - type t = - | Java of Java.t - | C of C.t - | Linters_dummy_method - | Block of Block.t - | ObjC_Cpp of ObjC_Cpp.t - | WithBlockParameters of t * Block.block_name list - [@@deriving compare] - - val block_name_of_procname : t -> Block.block_name - - val equal : t -> t -> bool - - val get_class_type_name : t -> Name.t option - - val get_class_name : t -> string option - - val get_parameters : t -> Parameter.t list - - val replace_parameters : Parameter.t list -> t -> t - - val parameter_of_name : t -> Name.t -> Parameter.t - - val is_java_access_method : t -> bool - - val is_java_class_initializer : t -> bool - - val is_objc_method : t -> bool - - module Hash : Caml.Hashtbl.S with type key = t - (** Hash tables with proc names as keys. *) - - module Map : PrettyPrintable.PPMap with type key = t - (** Maps from proc names. *) - - module Set : PrettyPrintable.PPSet with type elt = t - (** Sets of proc names. *) - - module SQLite : sig - val serialize : t -> Sqlite3.Data.t - - val deserialize : Sqlite3.Data.t -> t - - val clear_cache : unit -> unit - end - - module SQLiteList : SqliteUtils.Data with type t = t list - - val empty_block : t - (** Empty block name. *) - - val get_language : t -> Language.t - (** Return the language of the procedure. *) - - val get_method : t -> string - (** Return the method/function of a procname. *) - - val is_objc_block : t -> bool - (** Return whether the procname is a block procname. *) - - val is_c_method : t -> bool - (** Return true this is an Objective-C/C++ method name. *) - - val is_clang : t -> bool - (** Return true if this is a C, C++, or Objective-C procedure name *) - - val is_constructor : t -> bool - (** Check if this is a constructor. *) - - val is_java : t -> bool - (** Check if this is a Java procedure name. *) - - val with_block_parameters : t -> Block.block_name list -> t - (** Create a procedure name instantiated with block parameters from a base procedure name - and a list of block procedure names (the arguments). *) - - val objc_cpp_replace_method_name : t -> string -> t - - val is_infer_undefined : t -> bool - (** Check if this is a special Infer undefined procedure. *) - - val get_global_name_of_initializer : t -> string option - (** Return the name of the global for which this procedure is the initializer if this is an - initializer, None otherwise. *) - - val pp : Format.formatter -> t -> unit - (** Pretty print a proc name for the user to see. *) - - val to_string : t -> string - (** Convert a proc name into a string for the user to see. *) - - val describe : Format.formatter -> t -> unit - (** to use in user messages *) - - val replace_class : t -> Name.t -> t - (** Replace the class name component of a procedure name. - In case of Java, replace package and class name. *) - - val is_method_in_objc_protocol : t -> bool - - val pp_simplified_string : ?withclass:bool -> F.formatter -> t -> unit - (** Pretty print a proc name as an easy string for the user to see in an IDE. *) - - val to_simplified_string : ?withclass:bool -> t -> string - (** Convert a proc name into an easy string for the user to see in an IDE. *) - - val from_string_c_fun : string -> t - (** Convert a string to a c function name. *) - - val hashable_name : t -> string - (** Convert the procedure name in a format suitable for computing the bug hash. *) - - val pp_unique_id : F.formatter -> t -> unit - (** Print a proc name as a unique identifier. *) - - val to_unique_id : t -> string - (** Convert a proc name into a unique identifier. *) - - val to_filename : ?crc_only:bool -> t -> string - (** Convert a proc name to a filename or only to its crc. *) - - val get_qualifiers : t -> QualifiedCppName.t - (** get qualifiers of C/objc/C++ method/function *) -end diff --git a/infer/src/IR/Var.ml b/infer/src/IR/Var.ml index 67e0b752c..1ecf29d65 100644 --- a/infer/src/IR/Var.ml +++ b/infer/src/IR/Var.ml @@ -54,7 +54,7 @@ let get_declaring_function = function let is_local_to_procedure proc_name var = - get_declaring_function var |> Option.exists ~f:(Typ.Procname.equal proc_name) + get_declaring_function var |> Option.exists ~f:(Procname.equal proc_name) let get_all_vars_in_exp e = diff --git a/infer/src/IR/Var.mli b/infer/src/IR/Var.mli index 9b662aba2..396984535 100644 --- a/infer/src/IR/Var.mli +++ b/infer/src/IR/Var.mli @@ -33,7 +33,7 @@ val get_pvar : t -> Pvar.t option val is_global : t -> bool -val is_local_to_procedure : Typ.Procname.t -> t -> bool +val is_local_to_procedure : Procname.t -> t -> bool val is_return : t -> bool diff --git a/infer/src/absint/AbstractInterpreter.ml b/infer/src/absint/AbstractInterpreter.ml index fe069ace1..192cec40e 100644 --- a/infer/src/absint/AbstractInterpreter.ml +++ b/infer/src/absint/AbstractInterpreter.ml @@ -29,7 +29,7 @@ end = struct L.(die InternalError) "Exceeded max widening threshold %d while analyzing %a. Please check your widening \ operator or increase the threshold" - Config.max_widens Typ.Procname.pp (Procdesc.get_proc_name pdesc) ; + Config.max_widens Procname.pp (Procdesc.get_proc_name pdesc) ; visit_count' end @@ -217,7 +217,7 @@ module AbstractInterpreterCommon (TransferFunctions : TransferFunctions.SIL) = s else if is_narrowing && not (Domain.leq ~lhs:new_pre ~rhs:old_state.State.pre) then ( L.(debug Analysis Verbose) "Terminate narrowing because old and new states are not comparable at %a:%a@." - Typ.Procname.pp (Summary.get_proc_name summary) Node.pp_id node_id ; + Procname.pp (Summary.get_proc_name summary) Node.pp_id node_id ; (inv_map, ReachedFixPoint) ) else let visit_count' = diff --git a/infer/src/absint/LowerHil.ml b/infer/src/absint/LowerHil.ml index a6cb1a6b5..a455d552a 100644 --- a/infer/src/absint/LowerHil.ml +++ b/infer/src/absint/LowerHil.ml @@ -36,7 +36,7 @@ module Make (TransferFunctions : TransferFunctions.HIL) (HilConfig : HilConfig) let is_java_unlock pname actuals = (* would check is_java, but we want to include builtins too *) - (not (Typ.Procname.is_c_method pname)) + (not (Procname.is_c_method pname)) && match ConcurrencyModels.get_lock_effect pname actuals with Unlock _ -> true | _ -> false diff --git a/infer/src/absint/PatternMatch.ml b/infer/src/absint/PatternMatch.ml index bf906f117..6c3fad2f7 100644 --- a/infer/src/absint/PatternMatch.ml +++ b/infer/src/absint/PatternMatch.ml @@ -178,8 +178,7 @@ let get_vararg_type_names tenv (call_node : Procdesc.Node.t) (ivar : Pvar.t) : s |> Option.exists ~f:(fun t2 -> Instrs.exists instrs ~f:(function | Sil.Call ((t1, _), Exp.Const (Const.Cfun pn), _, _, _) -> - Ident.equal t1 t2 - && Typ.Procname.equal pn (Typ.Procname.from_string_c_fun "__new_array") + Ident.equal t1 t2 && Procname.equal pn (Procname.from_string_c_fun "__new_array") | _ -> false ) ) in @@ -283,8 +282,8 @@ let method_is_initializer (tenv : Tenv.t) (proc_attributes : ProcAttributes.t) : | Some this_type -> if type_has_initializer tenv this_type then match proc_attributes.ProcAttributes.proc_name with - | Typ.Procname.Java pname_java -> - let mname = Typ.Procname.Java.get_method pname_java in + | Procname.Java pname_java -> + let mname = Procname.Java.get_method pname_java in List.exists ~f:(String.equal mname) initializer_methods | _ -> false @@ -313,7 +312,7 @@ let java_get_vararg_values node pvar idenv = [] -let proc_calls resolve_attributes pdesc filter : (Typ.Procname.t * ProcAttributes.t) list = +let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t) list = let res = ref [] in let do_instruction _ instr = match instr with @@ -335,13 +334,13 @@ let proc_calls resolve_attributes pdesc filter : (Typ.Procname.t * ProcAttribute let is_override_of proc_name = - let method_name = Typ.Procname.get_method proc_name in - let parameter_length = List.length (Typ.Procname.get_parameters proc_name) in + let method_name = Procname.get_method proc_name in + let parameter_length = List.length (Procname.get_parameters proc_name) in Staged.stage (fun pname -> - (not (Typ.Procname.is_constructor pname)) - && String.equal (Typ.Procname.get_method pname) method_name + (not (Procname.is_constructor pname)) + && String.equal (Procname.get_method pname) method_name (* TODO (T32979782): match parameter types, taking subtyping and type erasure into account *) - && Int.equal (List.length (Typ.Procname.get_parameters pname)) parameter_length ) + && Int.equal (List.length (Procname.get_parameters pname)) parameter_length ) let override_find ?(check_current_type = true) f tenv proc_name = @@ -361,11 +360,10 @@ let override_find ?(check_current_type = true) f tenv proc_name = if check_current_type && f proc_name then Some proc_name else match proc_name with - | Typ.Procname.Java proc_name_java -> - find_super_type - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name proc_name_java)) - | Typ.Procname.ObjC_Cpp proc_name_cpp -> - find_super_type (Typ.Procname.ObjC_Cpp.get_class_type_name proc_name_cpp) + | Procname.Java proc_name_java -> + find_super_type (Typ.Name.Java.from_string (Procname.Java.get_class_name proc_name_java)) + | Procname.ObjC_Cpp proc_name_cpp -> + find_super_type (Procname.ObjC_Cpp.get_class_type_name proc_name_cpp) | _ -> None @@ -421,9 +419,9 @@ let is_java_enum tenv typename = is_subtype_of_str tenv typename "java.lang.Enum (** tests whether any class attributes (e.g., [@ThreadSafe]) pass check of first argument, including for supertypes*) let check_class_attributes check tenv = function - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> let check_class_annots _ {Struct.annots} = check annots in - supertype_exists tenv check_class_annots (Typ.Procname.Java.get_class_type_name java_pname) + supertype_exists tenv check_class_annots (Procname.Java.get_class_type_name java_pname) | _ -> false @@ -431,8 +429,8 @@ let check_class_attributes check tenv = function (** 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 - | Typ.Procname.Java java_pname -> ( - match Tenv.lookup tenv (Typ.Procname.Java.get_class_type_name java_pname) with + | Procname.Java java_pname -> ( + match Tenv.lookup tenv (Procname.Java.get_class_type_name java_pname) with | Some struct_typ -> check struct_typ.annots | _ -> diff --git a/infer/src/absint/PatternMatch.mli b/infer/src/absint/PatternMatch.mli index f7fd04a8d..a683ec33a 100644 --- a/infer/src/absint/PatternMatch.mli +++ b/infer/src/absint/PatternMatch.mli @@ -105,22 +105,22 @@ val java_get_vararg_values : Procdesc.Node.t -> Pvar.t -> Idenv.t -> Exp.t list (** Get the values of a vararg parameter given the pvar used to assign the elements. *) val proc_calls : - (Typ.Procname.t -> ProcAttributes.t option) + (Procname.t -> ProcAttributes.t option) -> Procdesc.t - -> (Typ.Procname.t -> ProcAttributes.t -> bool) - -> (Typ.Procname.t * ProcAttributes.t) list + -> (Procname.t -> ProcAttributes.t -> bool) + -> (Procname.t * ProcAttributes.t) list (** Return the callees that satisfy [filter]. *) val override_exists : - ?check_current_type:bool -> (Typ.Procname.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool + ?check_current_type:bool -> (Procname.t -> bool) -> Tenv.t -> Procname.t -> bool (** Return true if applying the given predicate to an override of [procname] (including [procname] itself when [check_current_type] is true, which it is by default) returns true. *) -val override_iter : (Typ.Procname.t -> unit) -> Tenv.t -> Typ.Procname.t -> unit +val override_iter : (Procname.t -> unit) -> Tenv.t -> Procname.t -> unit (** Apply the given predicate to procname and each override of [procname]. For the moment, this only works for Java *) -val lookup_attributes : Tenv.t -> Typ.Procname.t -> ProcAttributes.t option +val lookup_attributes : Tenv.t -> Procname.t -> ProcAttributes.t option val type_get_annotation : Tenv.t -> Typ.t -> Annot.Item.t option @@ -139,11 +139,11 @@ val is_throwable : Tenv.t -> Typ.Name.t -> bool val is_java_enum : Tenv.t -> Typ.Name.t -> bool (** Checks if the type is Java enum (extends java.lang.Enum) *) -val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool +val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> bool (** tests whether any class attributes (e.g., [@ThreadSafe]) pass check of first argument, including supertypes*) -val check_current_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool +val check_current_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> bool (** tests whether any class attributes (e.g., [@ThreadSafe]) pass check of first argument, for current class only*) @@ -151,4 +151,4 @@ val find_superclasses_with_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Name.t -> Typ.Name.t list (** find superclasss with attributes (e.g., [@ThreadSafe]), including current class*) -val is_override_of : Typ.Procname.t -> (Typ.Procname.t -> bool) Staged.t +val is_override_of : Procname.t -> (Procname.t -> bool) Staged.t diff --git a/infer/src/absint/SummaryPayload.ml b/infer/src/absint/SummaryPayload.ml index 20b983b28..cd48d958d 100644 --- a/infer/src/absint/SummaryPayload.ml +++ b/infer/src/absint/SummaryPayload.ml @@ -20,11 +20,11 @@ module type S = sig val of_summary : Summary.t -> t option - val read_full : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> (Procdesc.t * t) option + val read_full : caller_summary:Summary.t -> callee_pname:Procname.t -> (Procdesc.t * t) option - val read : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> t option + val read : caller_summary:Summary.t -> callee_pname:Procname.t -> t option - val read_toplevel_procedure : Typ.Procname.t -> t option + val read_toplevel_procedure : Procname.t -> t option end module Make (P : Payload) : S with type t = P.t = struct diff --git a/infer/src/absint/SummaryPayload.mli b/infer/src/absint/SummaryPayload.mli index b6a5696e9..6b042ab3e 100644 --- a/infer/src/absint/SummaryPayload.mli +++ b/infer/src/absint/SummaryPayload.mli @@ -22,14 +22,14 @@ module type S = sig val of_summary : Summary.t -> t option (** Read the corresponding part of the payload from the procedure summary *) - val read_full : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> (Procdesc.t * t) option + val read_full : caller_summary:Summary.t -> callee_pname:Procname.t -> (Procdesc.t * t) option (** Return the proc desc and payload for the given procedure. Runs the analysis on-demand if necessary. *) - val read : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> t option + val read : caller_summary:Summary.t -> callee_pname:Procname.t -> t option (** Return the payload for the given procedure. Runs the analysis on-demand if necessary. *) - val read_toplevel_procedure : Typ.Procname.t -> t option + val read_toplevel_procedure : Procname.t -> t option end module Make (P : Payload) : S with type t = P.t diff --git a/infer/src/al/ALIssues.ml b/infer/src/al/ALIssues.ml index 2c36bd319..79173f65f 100644 --- a/infer/src/al/ALIssues.ml +++ b/infer/src/al/ALIssues.ml @@ -480,7 +480,7 @@ let log_frontend_issue method_decl_opt (node : Ctl_parser_types.ast_node) | Some method_decl -> CType_decl.CProcname.from_decl_for_linters method_decl | None -> - Typ.Procname.Linters_dummy_method + Procname.Linters_dummy_method in let issue_log', errlog = IssueLog.get_or_add ~proc:procname !issue_log in issue_log := issue_log' ; diff --git a/infer/src/al/cPredicates.ml b/infer/src/al/cPredicates.ml index d99b8e8d0..02a772cfa 100644 --- a/infer/src/al/cPredicates.ml +++ b/infer/src/al/cPredicates.ml @@ -768,11 +768,11 @@ let get_method_name_from_context context = let is_objc_constructor context = - Typ.Procname.ObjC_Cpp.is_objc_constructor (get_method_name_from_context context) + Procname.ObjC_Cpp.is_objc_constructor (get_method_name_from_context context) let is_objc_dealloc context = - Typ.Procname.ObjC_Cpp.is_objc_dealloc (get_method_name_from_context context) + Procname.ObjC_Cpp.is_objc_dealloc (get_method_name_from_context context) let is_in_method context name = diff --git a/infer/src/backend/CallGraph.ml b/infer/src/backend/CallGraph.ml index 9f8afd95e..b3a7dba97 100644 --- a/infer/src/backend/CallGraph.ml +++ b/infer/src/backend/CallGraph.ml @@ -8,9 +8,9 @@ open! IStd module F = Format module type NodeSig = sig - type t = private {id: int; pname: Typ.Procname.t; mutable successors: int list; mutable flag: bool} + type t = private {id: int; pname: Procname.t; mutable successors: int list; mutable flag: bool} - val make : int -> Typ.Procname.t -> int list -> t + val make : int -> Procname.t -> int list -> t val add_successor : t -> int -> unit @@ -22,7 +22,7 @@ module type NodeSig = sig end module Node : NodeSig = struct - type t = {id: int; pname: Typ.Procname.t; mutable successors: int list; mutable flag: bool} + type t = {id: int; pname: Procname.t; mutable successors: int list; mutable flag: bool} let make id pname successors = {id; pname; successors; flag= false} @@ -37,13 +37,13 @@ module Node : NodeSig = struct let pp_edge fmt src dst = F.fprintf fmt " %a -> %a ;@\n" pp_id src pp_id dst in let pp_flag fmt flag = F.fprintf fmt "%B" flag in F.fprintf fmt " %a [ label = %S, flag = %a ];@\n" pp_id id - (F.asprintf "%a" Typ.Procname.pp pname) + (F.asprintf "%a" Procname.pp pname) pp_flag flag ; List.iter successors ~f:(pp_edge fmt id) ; F.pp_print_newline fmt () end -module IdMap = Typ.Procname.Hash +module IdMap = Procname.Hash module NodeMap = Caml.Hashtbl.Make (Int) (** [node_map] is a map from ids (unique ints) to nodes corresponding to defined procedures. diff --git a/infer/src/backend/CallGraph.mli b/infer/src/backend/CallGraph.mli index 62dfa7376..836f1dd51 100644 --- a/infer/src/backend/CallGraph.mli +++ b/infer/src/backend/CallGraph.mli @@ -8,9 +8,9 @@ open! IStd module F = Format module type NodeSig = sig - type t = private {id: int; pname: Typ.Procname.t; mutable successors: int list; mutable flag: bool} + type t = private {id: int; pname: Procname.t; mutable successors: int list; mutable flag: bool} - val make : int -> Typ.Procname.t -> int list -> t + val make : int -> Procname.t -> int list -> t val add_successor : t -> int -> unit @@ -37,15 +37,15 @@ val n_procs : t -> int val mem : t -> int -> bool (** is an int [id] the index of a node in the graph? *) -val flag : t -> Typ.Procname.t -> unit +val flag : t -> Procname.t -> unit -val flag_reachable : t -> Typ.Procname.t -> unit +val flag_reachable : t -> Procname.t -> unit (** flag all nodes reachable from the node of the given procname, if it exists *) val get_unflagged_leaves : t -> Node.t list (** get all leaves that have their flag set to false *) -val remove : t -> Typ.Procname.t -> unit +val remove : t -> Procname.t -> unit val to_dotty : t -> string -> unit (** output call graph in dotty format with the given filename in results dir *) @@ -56,11 +56,11 @@ val trim_id_map : t -> unit val remove_unflagged_and_unflag_all : t -> unit (** remove all nodes with flag set to false, and set flag to false on all remaining nodes *) -val add_edge : t -> pname:Typ.Procname.t -> successor_pname:Typ.Procname.t -> unit +val add_edge : t -> pname:Procname.t -> successor_pname:Procname.t -> unit (** add an edge from [pname] to [successor_pname] in the graph, creating a node for [pname] if there isn't one already *) -val create_node : t -> Typ.Procname.t -> Typ.Procname.t list -> unit +val create_node : t -> Procname.t -> Procname.t list -> unit (** create a new node with edges from [pname] to [successor_pnames] in the graph *) val fold_flagged : t -> f:(Node.t -> 'a -> 'a) -> 'a -> 'a diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index 3812388c0..4579eff5a 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -259,8 +259,8 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; zero_issue; infini in let msg = (* Java Only *) - if String.equal method_name Typ.Procname.Java.constructor_method_name then "constructor" - else if String.equal method_name Typ.Procname.Java.class_initializer_method_name then + if String.equal method_name Procname.Java.constructor_method_name then "constructor" + else if String.equal method_name Procname.Java.class_initializer_method_name then "class initializer" else "this function" in diff --git a/infer/src/backend/ExternalPerfData.ml b/infer/src/backend/ExternalPerfData.ml index c1676244d..d5dc76ac3 100644 --- a/infer/src/backend/ExternalPerfData.ml +++ b/infer/src/backend/ExternalPerfData.ml @@ -8,9 +8,9 @@ open! IStd module L = Logging module PerfProfilerDataMap = Caml.Map.Make (struct - type t = Typ.Procname.t + type t = Procname.t - let compare = Typ.Procname.compare + let compare = Procname.compare end) let global_perf_profiler_data : Perf_profiler_t.perf_profiler_item PerfProfilerDataMap.t ref = diff --git a/infer/src/backend/ExternalPerfData.mli b/infer/src/backend/ExternalPerfData.mli index d4a16e9b3..57ec1e26c 100644 --- a/infer/src/backend/ExternalPerfData.mli +++ b/infer/src/backend/ExternalPerfData.mli @@ -7,4 +7,4 @@ open! IStd -val in_profiler_data_map : Typ.Procname.t -> bool +val in_profiler_data_map : Procname.t -> bool diff --git a/infer/src/backend/InferAnalyze.ml b/infer/src/backend/InferAnalyze.ml index d50139e71..41a68b43d 100644 --- a/infer/src/backend/InferAnalyze.ml +++ b/infer/src/backend/InferAnalyze.ml @@ -13,9 +13,7 @@ module F = Format module L = Logging let clear_caches () = - Ondemand.LocalCache.clear () ; - Summary.OnDisk.clear_cache () ; - Typ.Procname.SQLite.clear_cache () + Ondemand.LocalCache.clear () ; Summary.OnDisk.clear_cache () ; Procname.SQLite.clear_cache () let analyze_target : SchedulerTypes.target Tasks.doer = @@ -37,7 +35,7 @@ let analyze_target : SchedulerTypes.target Tasks.doer = decr procs_left ; if Int.( <= ) !procs_left 0 then ( L.log_task "Analysing block of %d procs, starting with %a@." per_procedure_logging_granularity - Typ.Procname.pp proc_name ; + Procname.pp proc_name ; procs_left := per_procedure_logging_granularity ) ; Ondemand.analyze_proc_name_toplevel exe_env proc_name in diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 6df74ac5c..7c24ff3e1 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -23,16 +23,16 @@ let error_desc_to_plain_string error_desc = let error_desc_to_dotty_string error_desc = Localise.error_desc_get_dotty error_desc -let compute_key (bug_type : string) (proc_name : Typ.Procname.t) (filename : string) = +let compute_key (bug_type : string) (proc_name : Procname.t) (filename : string) = let base_filename = Filename.basename filename - and simple_procedure_name = Typ.Procname.get_method proc_name in + and simple_procedure_name = Procname.get_method proc_name in String.concat ~sep:"|" [base_filename; simple_procedure_name; bug_type] -let compute_hash ~(severity : string) ~(bug_type : string) ~(proc_name : Typ.Procname.t) +let compute_hash ~(severity : string) ~(bug_type : string) ~(proc_name : Procname.t) ~(file : string) ~(qualifier : string) = let base_filename = Filename.basename file in - let hashable_procedure_name = Typ.Procname.hashable_name proc_name in + let hashable_procedure_name = Procname.hashable_name proc_name in let location_independent_qualifier = (* Removing the line,column, and infer temporary variable (e.g., n$67) information from the error message as well as the index of the annonymmous class to make the hash invariant @@ -97,8 +97,8 @@ let summary_values summary = let pp fmt = Pp.seq pp_line fmt lines_visited in F.asprintf "%t" pp in - { vname= Typ.Procname.to_string proc_name - ; vname_id= Typ.Procname.to_filename proc_name + { vname= Procname.to_string proc_name + ; vname_id= Procname.to_filename proc_name ; vspecs= List.length specs ; vto= Summary.Stats.failure_kind_to_string stats ; vsymop= Summary.Stats.symops stats @@ -213,17 +213,17 @@ end type json_issue_printer_typ = { error_filter: SourceFile.t -> IssueType.t -> bool - ; proc_name: Typ.Procname.t + ; proc_name: Procname.t ; proc_loc_opt: Location.t option ; err_key: Errlog.err_key ; err_data: Errlog.err_data } let procedure_id_of_procname proc_name = - match Typ.Procname.get_language proc_name with + match Procname.get_language proc_name with | Language.Java -> - Typ.Procname.to_unique_id proc_name + Procname.to_unique_id proc_name | _ -> - Typ.Procname.to_string proc_name + Procname.to_string proc_name module JsonIssuePrinter = MakeJsonListPrinter (struct @@ -314,14 +314,14 @@ module IssuesJson = struct end type json_costs_printer_typ = - {loc: Location.t; proc_name: Typ.Procname.t; cost_opt: CostDomain.summary option} + {loc: Location.t; proc_name: Procname.t; cost_opt: CostDomain.summary option} module JsonCostsPrinter = MakeJsonListPrinter (struct type elt = json_costs_printer_typ let to_string {loc; proc_name; cost_opt} = match cost_opt with - | Some {post; is_on_ui_thread} when not (Typ.Procname.is_java_access_method proc_name) -> + | Some {post; is_on_ui_thread} when not (Procname.is_java_access_method proc_name) -> let hum cost = let degree_with_term = CostDomain.BasicCost.get_degree_with_term cost in { Jsonbug_t.hum_polynomial= Format.asprintf "%a" CostDomain.BasicCost.pp_hum cost @@ -344,7 +344,7 @@ module JsonCostsPrinter = MakeJsonListPrinter (struct let file = SourceFile.to_rel_path loc.Location.file in { Jsonbug_t.hash= compute_hash ~severity:"" ~bug_type:"" ~proc_name ~file ~qualifier:"" ; loc= {file; lnum= loc.Location.line; cnum= loc.Location.col; enum= -1} - ; procedure_name= Typ.Procname.get_method proc_name + ; procedure_name= Procname.get_method proc_name ; procedure_id= procedure_id_of_procname proc_name ; is_on_ui_thread ; exec_cost= cost_info (CostDomain.get_cost_kind CostKind.OperationCost post) @@ -599,7 +599,7 @@ module StatsLogs = struct ClangMethodKind.to_string (Summary.get_attributes summary).clang_method_kind in let proc_name = Summary.get_proc_name summary in - let lang = Typ.Procname.get_language proc_name in + let lang = Procname.get_language proc_name in let stats = EventLogger.AnalysisStats { analysis_nodes_visited= Summary.Stats.nb_visited summary.stats @@ -608,7 +608,7 @@ module StatsLogs = struct ; clang_method_kind= (match lang with Language.Clang -> Some clang_method_kind | _ -> None) ; lang= Language.to_explicit_string lang ; method_location= Summary.get_loc summary - ; method_name= Typ.Procname.to_string proc_name + ; method_name= Procname.to_string proc_name ; num_preposts ; symops= Summary.Stats.symops summary.stats } in @@ -642,16 +642,16 @@ module PreconditionStats = struct match Prop.CategorizePreconditions.categorize preconditions with | Prop.CategorizePreconditions.Empty -> incr nr_empty ; - L.result "Procedure: %a footprint:Empty@." Typ.Procname.pp proc_name + L.result "Procedure: %a footprint:Empty@." Procname.pp proc_name | Prop.CategorizePreconditions.OnlyAllocation -> incr nr_onlyallocation ; - L.result "Procedure: %a footprint:OnlyAllocation@." Typ.Procname.pp proc_name + L.result "Procedure: %a footprint:OnlyAllocation@." Procname.pp proc_name | Prop.CategorizePreconditions.NoPres -> incr nr_nopres ; - L.result "Procedure: %a footprint:NoPres@." Typ.Procname.pp proc_name + L.result "Procedure: %a footprint:NoPres@." Procname.pp proc_name | Prop.CategorizePreconditions.DataConstraints -> incr nr_dataconstraints ; - L.result "Procedure: %a footprint:DataConstraints@." Typ.Procname.pp proc_name + L.result "Procedure: %a footprint:DataConstraints@." Procname.pp proc_name let pp_stats () = @@ -819,7 +819,7 @@ module SummaryStats = struct let do_summary proc_name summary = results := MetricResults.add !results proc_name summary - let pp_stats () = L.result "%a@\n" (MetricResults.pp ~pp_k:Typ.Procname.pp) !results + let pp_stats () = L.result "%a@\n" (MetricResults.pp ~pp_k:Procname.pp) !results end let error_filter filters proc_name file error_name = @@ -953,7 +953,7 @@ let pp_stats error_filter linereader summary stats stats_format_list = let pp_summary summary = - L.result "Procedure: %a@\n%a@." Typ.Procname.pp (Summary.get_proc_name summary) Summary.pp_text + L.result "Procedure: %a@\n%a@." Procname.pp (Summary.get_proc_name summary) Summary.pp_text summary diff --git a/infer/src/backend/Issue.ml b/infer/src/backend/Issue.ml index b86d7ff0b..2c7bf6bec 100644 --- a/infer/src/backend/Issue.ml +++ b/infer/src/backend/Issue.ml @@ -9,7 +9,7 @@ open! IStd module L = Logging type t = - { proc_name: Typ.Procname.t + { proc_name: Procname.t ; proc_location: Location.t ; err_key: Errlog.err_key ; err_data: Errlog.err_data } @@ -23,7 +23,7 @@ let compare_err_data_ (err_data1 : Errlog.err_data) (err_data2 : Errlog.err_data Location.compare err_data1.loc err_data2.loc -type proc_name_ = Typ.Procname.t +type proc_name_ = Procname.t (* ignore proc name *) let compare_proc_name_ _ _ = 0 diff --git a/infer/src/backend/Issue.mli b/infer/src/backend/Issue.mli index 17f72ac6d..714515fed 100644 --- a/infer/src/backend/Issue.mli +++ b/infer/src/backend/Issue.mli @@ -8,7 +8,7 @@ open! IStd type t = - { proc_name: Typ.Procname.t + { proc_name: Procname.t ; proc_location: Location.t ; err_key: Errlog.err_key ; err_data: Errlog.err_data } diff --git a/infer/src/backend/OndemandCapture.ml b/infer/src/backend/OndemandCapture.ml index 0df762149..75ccaf100 100644 --- a/infer/src/backend/OndemandCapture.ml +++ b/infer/src/backend/OndemandCapture.ml @@ -32,17 +32,17 @@ let try_capture (attributes : ProcAttributes.t) : ProcAttributes.t option = (* peek at the results to know if capture succeeded, but only in debug mode *) L.(debug Capture Verbose) "Captured file %a to get procedure %a but it wasn't found there@\n" SourceFile.pp - definition_file Typ.Procname.pp attributes.proc_name ) + definition_file Procname.pp attributes.proc_name ) else L.(debug Capture Verbose) "Wanted to capture file %a to get procedure %a but file was already captured@\n" - SourceFile.pp definition_file Typ.Procname.pp attributes.proc_name + SourceFile.pp definition_file Procname.pp attributes.proc_name in match definition_file_opt with | None -> L.(debug Capture Medium) - "Couldn't find source file for %a (declared in %a)@\n" Typ.Procname.pp - attributes.proc_name SourceFile.pp decl_file + "Couldn't find source file for %a (declared in %a)@\n" Procname.pp attributes.proc_name + SourceFile.pp decl_file | Some file -> try_compile file ) ; (* It's important to call load_defined_attributes again in all cases to make sure we try diff --git a/infer/src/backend/Procedures.ml b/infer/src/backend/Procedures.ml index 88045f39f..900b87fd9 100644 --- a/infer/src/backend/Procedures.ml +++ b/infer/src/backend/Procedures.ml @@ -13,7 +13,7 @@ let get_all ~filter () = SqliteUtils.result_fold_rows db ~log:"reading all procedure names" stmt ~init:[] ~f:(fun rev_results stmt -> let source_file = Sqlite3.column stmt 0 |> SourceFile.SQLite.deserialize in - let proc_name = Sqlite3.column stmt 1 |> Typ.Procname.SQLite.deserialize in + let proc_name = Sqlite3.column stmt 1 |> Procname.SQLite.deserialize in if filter source_file proc_name then proc_name :: rev_results else rev_results ) @@ -35,7 +35,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file Format.fprintf fmt "@[%s@,%a%a%a%a@]@\n" proc_name_hum (pp_if source_file_cond "source_file" SourceFile.pp) source_file - (pp_if proc_name_cond "proc_name" Typ.Procname.pp) + (pp_if proc_name_cond "proc_name" Procname.pp) proc_name (pp_column_if stmt attr_kind "attribute_kind" Attributes.deserialize_attributes_kind Attributes.pp_attributes_kind) @@ -50,6 +50,6 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file "SELECT proc_name, proc_name_hum, attr_kind, source_file, proc_attributes FROM procedures" |> Container.iter ~fold:(SqliteUtils.result_fold_rows db ~log:"print all procedures") ~f:(fun stmt -> - let proc_name = Sqlite3.column stmt 0 |> Typ.Procname.SQLite.deserialize in + let proc_name = Sqlite3.column stmt 0 |> Procname.SQLite.deserialize in let source_file = Sqlite3.column stmt 3 |> SourceFile.SQLite.deserialize in if filter source_file proc_name then pp_row stmt fmt source_file proc_name ) diff --git a/infer/src/backend/Procedures.mli b/infer/src/backend/Procedures.mli index 33c8393ee..ab0869121 100644 --- a/infer/src/backend/Procedures.mli +++ b/infer/src/backend/Procedures.mli @@ -7,7 +7,7 @@ open! IStd -val get_all : filter:Filtering.procedures_filter -> unit -> Typ.Procname.t list +val get_all : filter:Filtering.procedures_filter -> unit -> Procname.t list val pp_all : filter:Filtering.procedures_filter diff --git a/infer/src/backend/ReverseAnalysisCallGraph.ml b/infer/src/backend/ReverseAnalysisCallGraph.ml index 5f68084fb..0b012b201 100644 --- a/infer/src/backend/ReverseAnalysisCallGraph.ml +++ b/infer/src/backend/ReverseAnalysisCallGraph.ml @@ -9,7 +9,7 @@ open! IStd let register_summary graph summary = let caller_pname = Summary.get_proc_name summary in let callee_pnames = summary.Summary.callee_pnames in - Typ.Procname.Set.iter + Procname.Set.iter (fun callee_pname -> CallGraph.add_edge graph ~pname:callee_pname ~successor_pname:caller_pname) callee_pnames diff --git a/infer/src/backend/SchedulerTypes.ml b/infer/src/backend/SchedulerTypes.ml index 457043cb6..679ec3bb4 100644 --- a/infer/src/backend/SchedulerTypes.ml +++ b/infer/src/backend/SchedulerTypes.ml @@ -6,4 +6,4 @@ *) open! IStd -type target = Procname of Typ.Procname.t | File of SourceFile.t +type target = Procname of Procname.t | File of SourceFile.t diff --git a/infer/src/backend/SpecsFiles.mli b/infer/src/backend/SpecsFiles.mli index 0be7a220b..8586f075f 100644 --- a/infer/src/backend/SpecsFiles.mli +++ b/infer/src/backend/SpecsFiles.mli @@ -14,6 +14,6 @@ val iter_from_config : f:(Summary.t -> unit) -> unit (** Iterates over all sumaries from the .specs files unless a list of specs files has been passed on the command line *) -val delete : Typ.Procname.t -> unit +val delete : Procname.t -> unit (** Delete the .specs file associated with a summary and remove the summary from the caches in Summary.ml and ondemand.ml *) diff --git a/infer/src/backend/Summary.ml b/infer/src/backend/Summary.ml index 5972f2eb6..cd2ac807d 100644 --- a/infer/src/backend/Summary.ml +++ b/infer/src/backend/Summary.ml @@ -71,7 +71,7 @@ include struct ; status: Status.t ; proc_desc: Procdesc.t ; err_log: Errlog.t - ; mutable callee_pnames: Typ.Procname.Set.t } + ; mutable callee_pnames: Procname.Set.t } [@@deriving fields] end @@ -102,7 +102,7 @@ let pp_errlog fmt err_log = let pp_signature fmt summary = let pp_formal fmt (p, typ) = F.fprintf fmt "%a %a" (Typ.pp_full Pp.text) typ Mangled.pp p in - F.fprintf fmt "%a %a(%a)" (Typ.pp_full Pp.text) (get_ret_type summary) Typ.Procname.pp + F.fprintf fmt "%a %a(%a)" (Typ.pp_full Pp.text) (get_ret_type summary) Procname.pp (get_proc_name summary) (Pp.seq ~sep:", " pp_formal) (get_formals summary) @@ -133,21 +133,21 @@ let pp_html source fmt summary = module OnDisk = struct open PolyVariantEqual - type cache = t Typ.Procname.Hash.t + type cache = t Procname.Hash.t - let cache : cache = Typ.Procname.Hash.create 128 + let cache : cache = Procname.Hash.create 128 - let clear_cache () = Typ.Procname.Hash.clear cache + let clear_cache () = Procname.Hash.clear cache - let remove_from_cache pname = Typ.Procname.Hash.remove cache pname + let remove_from_cache pname = Procname.Hash.remove cache pname (** Add the summary to the table for the given function *) - let add (proc_name : Typ.Procname.t) (summary : t) : unit = - Typ.Procname.Hash.replace cache proc_name summary + let add (proc_name : Procname.t) (summary : t) : unit = + Procname.Hash.replace cache proc_name summary let specs_filename pname = - let pname_file = Typ.Procname.to_filename pname in + let pname_file = Procname.to_filename pname in pname_file ^ Config.specs_files_suffix @@ -213,7 +213,7 @@ module OnDisk = struct let get proc_name = - match Typ.Procname.Hash.find cache proc_name with + match Procname.Hash.find cache proc_name with | summary -> BackendStats.incr_summary_cache_hits () ; Some summary @@ -258,15 +258,15 @@ module OnDisk = struct ; status= Status.Pending ; proc_desc ; err_log= Errlog.empty () - ; callee_pnames= Typ.Procname.Set.empty } + ; callee_pnames= Procname.Set.empty } in - Typ.Procname.Hash.replace cache (Procdesc.get_proc_name proc_desc) summary ; + Procname.Hash.replace cache (Procdesc.get_proc_name proc_desc) summary ; summary let dummy = let dummy_attributes = - ProcAttributes.default (SourceFile.invalid __FILE__) Typ.Procname.empty_block + ProcAttributes.default (SourceFile.invalid __FILE__) Procname.empty_block in let dummy_proc_desc = Procdesc.from_proc_attributes dummy_attributes in reset dummy_proc_desc diff --git a/infer/src/backend/Summary.mli b/infer/src/backend/Summary.mli index 4402f689b..314f84b47 100644 --- a/infer/src/backend/Summary.mli +++ b/infer/src/backend/Summary.mli @@ -47,11 +47,11 @@ type t = ; status: Status.t ; proc_desc: Procdesc.t ; err_log: Errlog.t - ; mutable callee_pnames: Typ.Procname.Set.t } + ; mutable callee_pnames: Procname.Set.t } val poly_fields : t PolyFields.t -val get_proc_name : t -> Typ.Procname.t +val get_proc_name : t -> Procname.t (** Get the procedure name *) val get_proc_desc : t -> Procdesc.t @@ -79,29 +79,29 @@ val pp_text : Format.formatter -> t -> unit (** Print the summary in text format *) module OnDisk : sig - val has_model : Typ.Procname.t -> bool + val has_model : Procname.t -> bool (** Check if a summary for a given procedure exists in the models directory *) val clear_cache : unit -> unit (** Remove all the elements from the cache of summaries *) - val remove_from_cache : Typ.Procname.t -> unit + val remove_from_cache : Procname.t -> unit (** Remove an element from the cache of summaries. Contrast to reset which re-initializes a summary keeping the same Procdesc and updates the cache accordingly. *) - val get : Typ.Procname.t -> t option + val get : Procname.t -> t option (** Return the summary option for the procedure name *) val reset : Procdesc.t -> t (** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) - val specs_filename_of_procname : Typ.Procname.t -> DB.filename + val specs_filename_of_procname : Procname.t -> DB.filename (** Return the path to the .specs file for the given procedure in the current results directory *) val load_from_file : DB.filename -> t option (** Load procedure summary from the given file *) - val proc_resolve_attributes : Typ.Procname.t -> ProcAttributes.t option + val proc_resolve_attributes : Procname.t -> ProcAttributes.t option (** Try to find the attributes for a defined proc. First look at specs (to get attributes computed by analysis) then look at the attributes table. If no attributes can be found, return None. *) diff --git a/infer/src/backend/SyntacticCallGraph.ml b/infer/src/backend/SyntacticCallGraph.ml index 5c3182fed..47ae197d8 100644 --- a/infer/src/backend/SyntacticCallGraph.ml +++ b/infer/src/backend/SyntacticCallGraph.ml @@ -6,11 +6,11 @@ *) open! IStd module L = Logging -module IdMap = Typ.Procname.Hash +module IdMap = Procname.Hash let build_from_captured_procs g = let hashcons_pname = - let pname_tbl : Typ.Procname.t IdMap.t = IdMap.create 1001 in + let pname_tbl : Procname.t IdMap.t = IdMap.create 1001 in fun pname -> match IdMap.find_opt pname_tbl pname with | Some pname' -> @@ -21,9 +21,9 @@ let build_from_captured_procs g = let db = ResultsDatabase.get_database () in let stmt = Sqlite3.prepare db "SELECT proc_name, callees FROM procedures" in SqliteUtils.result_fold_rows db ~log:"creating call graph" stmt ~init:() ~f:(fun () stmt -> - let proc_name = Sqlite3.column stmt 0 |> Typ.Procname.SQLite.deserialize |> hashcons_pname in + let proc_name = Sqlite3.column stmt 0 |> Procname.SQLite.deserialize |> hashcons_pname in let callees = - Sqlite3.column stmt 1 |> Typ.Procname.SQLiteList.deserialize |> List.map ~f:hashcons_pname + Sqlite3.column stmt 1 |> Procname.SQLiteList.deserialize |> List.map ~f:hashcons_pname in CallGraph.create_node g proc_name callees ) @@ -66,9 +66,9 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = let syntactic_call_graph = CallGraph.create CallGraph.default_initial_capacity in let initialized = ref false in let pending : CallGraph.Node.t list ref = ref [] in - let scheduled = ref Typ.Procname.Set.empty in + let scheduled = ref Procname.Set.empty in let is_empty () = - let empty = !initialized && List.is_empty !pending && Typ.Procname.Set.is_empty !scheduled in + let empty = !initialized && List.is_empty !pending && Procname.Set.is_empty !scheduled in if empty then ( remaining := 0 ; L.progress "Finished call graph scheduling, %d procs remaining (in, or reaching, cycles).@." @@ -88,7 +88,7 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = next_aux () | n :: ns -> pending := ns ; - scheduled := Typ.Procname.Set.add n.pname !scheduled ; + scheduled := Procname.Set.add n.pname !scheduled ; CallGraph.flag syntactic_call_graph n.pname ; Some (Procname n.pname) in @@ -97,7 +97,7 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = assert false | Procname pname -> decr remaining ; - scheduled := Typ.Procname.Set.remove pname !scheduled ; + scheduled := Procname.Set.remove pname !scheduled ; CallGraph.remove syntactic_call_graph pname in let next () = diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index d4f7c3f53..bc8f31e8a 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -10,7 +10,7 @@ open! IStd (** Module to register and invoke callbacks *) type proc_callback_args = - {get_procs_in_file: Typ.Procname.t -> Typ.Procname.t list; summary: Summary.t; exe_env: Exe_env.t} + {get_procs_in_file: Procname.t -> Procname.t list; summary: Summary.t; exe_env: Exe_env.t} type proc_callback_t = proc_callback_args -> Summary.t @@ -49,7 +49,7 @@ let get_procedure_definition exe_env proc_name = let iterate_procedure_callbacks exe_env summary = let proc_desc = Summary.get_proc_desc summary in let proc_name = Procdesc.get_proc_name proc_desc in - let procedure_language = Typ.Procname.get_language proc_name in + let procedure_language = Procname.get_language proc_name in Language.curr_language := procedure_language ; let get_procs_in_file proc_name = let source_file = @@ -68,7 +68,7 @@ let iterate_procedure_callbacks exe_env summary = PerfEvent.( log (fun logger -> log_begin_event logger ~name ~categories:["backend"] - ~arguments:[("proc", `String (Typ.Procname.to_string proc_name))] + ~arguments:[("proc", `String (Procname.to_string proc_name))] () )) ; let summary = callback {get_procs_in_file; summary; exe_env} in PerfEvent.(log (fun logger -> log_end_event logger ())) ; @@ -85,7 +85,7 @@ let iterate_cluster_callbacks all_procs exe_env source_file = let language_matches language = match procedures with | (_, summary) :: _ -> - Language.equal language (Typ.Procname.get_language (Summary.get_proc_name summary)) + Language.equal language (Procname.get_language (Summary.get_proc_name summary)) | _ -> true in diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index 8abec2e34..ae0102682 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -10,7 +10,7 @@ open! IStd (** Module to register and invoke callbacks *) type proc_callback_args = - {get_procs_in_file: Typ.Procname.t -> Typ.Procname.t list; summary: Summary.t; exe_env: Exe_env.t} + {get_procs_in_file: Procname.t -> Procname.t list; summary: Summary.t; exe_env: Exe_env.t} (** Type of a procedure callback: @@ -35,5 +35,5 @@ val register_cluster_callback : name:string -> Language.t -> cluster_callback_t val iterate_procedure_callbacks : Exe_env.t -> Summary.t -> Summary.t (** Invoke all registered procedure callbacks on the given procedure. *) -val iterate_cluster_callbacks : Typ.Procname.t list -> Exe_env.t -> SourceFile.t -> unit +val iterate_cluster_callbacks : Procname.t list -> Exe_env.t -> SourceFile.t -> unit (** Invoke all registered cluster callbacks on a cluster of procedures. *) diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index c4132d5eb..405bbca72 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -22,8 +22,8 @@ let is_one_of_classes = QualifiedCppName.Match.match_qualifiers let is_method_of_objc_cpp_class pname matcher = match pname with - | Typ.Procname.ObjC_Cpp objc_cpp -> - let class_qual_opt = Typ.Procname.ObjC_Cpp.get_class_qualifiers objc_cpp in + | Procname.ObjC_Cpp objc_cpp -> + let class_qual_opt = Procname.ObjC_Cpp.get_class_qualifiers objc_cpp in is_one_of_classes matcher class_qual_opt | _ -> false @@ -166,7 +166,7 @@ let rec find_normal_variable_load_ tenv (seen : Exp.Set.t) node id : DExp.t opti L.d_ln () ) ; exp_lv_dexp_ tenv seen node e | Sil.Call ((id0, _), Exp.Const (Const.Cfun pn), (e, _) :: _, _, _) - when Ident.equal id id0 && Typ.Procname.equal pn (Typ.Procname.from_string_c_fun "__cast") -> + when Ident.equal id id0 && Procname.equal pn (Procname.from_string_c_fun "__cast") -> if verbose then ( L.d_str "find_normal_variable_load cast on " ; Exp.d_exp e ; @@ -962,7 +962,7 @@ let explain_access_ proc_name tenv ?(use_buckets = false) ?(outermost_array = fa L.d_ln () ) ; Some e | Some (Sil.Call (_, Exp.Const (Const.Cfun fn), [(e, _)], _, _)) - when List.exists ~f:(Typ.Procname.equal fn) + when List.exists ~f:(Procname.equal fn) [BuiltinDecl.free; BuiltinDecl.__delete; BuiltinDecl.__delete_array] -> if verbose then ( L.d_str "explain_dereference Sil.Call " ; diff --git a/infer/src/backend/errdesc.mli b/infer/src/backend/errdesc.mli index 07cec3c1f..fa394115a 100644 --- a/infer/src/backend/errdesc.mli +++ b/infer/src/backend/errdesc.mli @@ -40,12 +40,12 @@ val explain_allocation_mismatch : PredSymb.res_action -> PredSymb.res_action -> (** Produce a description of a mismatch between an allocation function and a deallocation function *) val explain_array_access : - Typ.Procname.t -> Tenv.t -> Localise.deref_str -> 'a Prop.t -> Location.t -> Localise.error_desc + Procname.t -> Tenv.t -> Localise.deref_str -> 'a Prop.t -> Location.t -> Localise.error_desc (** Produce a description of the array access performed in the current instruction, if any. *) val explain_class_cast_exception : Tenv.t - -> Typ.Procname.t option + -> Procname.t option -> Exp.t -> Exp.t -> Exp.t @@ -61,7 +61,7 @@ val explain_deallocate_constant_string : string -> PredSymb.res_action -> Locali (** Explain a deallocate constant string error *) val explain_dereference : - Typ.Procname.t + Procname.t -> Tenv.t -> ?use_buckets:bool -> ?is_nullable:bool @@ -73,7 +73,7 @@ val explain_dereference : (** Produce a description of which expression is dereferenced in the current instruction, if any. *) val explain_dereference_as_caller_expression : - Typ.Procname.t + Procname.t -> Tenv.t -> ?use_buckets:bool -> Localise.deref_str diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index e03f97f50..1885bc025 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -38,16 +38,16 @@ let create_file_data table source = type t = - { proc_map: file_data Typ.Procname.Hash.t (** map from procedure name to file data *) + { proc_map: file_data Procname.Hash.t (** map from procedure name to file data *) ; file_map: file_data SourceFile.Hash.t (** map from source files to file data *) } let get_file_data exe_env pname = - try Some (Typ.Procname.Hash.find exe_env.proc_map pname) + try Some (Procname.Hash.find exe_env.proc_map pname) with Caml.Not_found -> let source_file_opt = match Attributes.load pname with | None -> - L.debug Analysis Medium "can't find attributes for %a@." Typ.Procname.pp pname ; + L.debug Analysis Medium "can't find attributes for %a@." Procname.pp pname ; None | Some proc_attributes when Config.reactive_capture -> let get_captured_file {ProcAttributes.translation_unit} = translation_unit in @@ -57,7 +57,7 @@ let get_file_data exe_env pname = in let get_file_data_for_source source_file = let file_data = create_file_data exe_env.file_map source_file in - Typ.Procname.Hash.replace exe_env.proc_map pname file_data ; + Procname.Hash.replace exe_env.proc_map pname file_data ; file_data in Option.map ~f:get_file_data_for_source source_file_opt @@ -92,7 +92,7 @@ let get_column_value ~value_on_java ~file_data_to_value ~column_name exe_env pro () in match proc_name with - | Typ.Procname.Java _ -> + | Procname.Java _ -> Lazy.force value_on_java | _ -> ( match get_file_data exe_env proc_name with @@ -102,12 +102,12 @@ let get_column_value ~value_on_java ~file_data_to_value ~column_name exe_env pro v | None -> let loc_opt = State.get_loc () in - L.die InternalError "get_column_value: %s not found for %a%a" column_name Typ.Procname.pp + L.die InternalError "get_column_value: %s not found for %a%a" column_name Procname.pp proc_name pp_loc_opt loc_opt ) | None -> let loc_opt = State.get_loc () in - L.die InternalError "get_column_value: file_data not found for %a%a" Typ.Procname.pp - proc_name pp_loc_opt loc_opt ) + L.die InternalError "get_column_value: file_data not found for %a%a" Procname.pp proc_name + pp_loc_opt loc_opt ) (** return the type environment associated to the procedure *) @@ -123,4 +123,4 @@ let get_integer_type_widths = ~file_data_to_value:file_data_to_integer_type_widths ~column_name:"integer type widths" -let mk () = {proc_map= Typ.Procname.Hash.create 17; file_map= SourceFile.Hash.create 1} +let mk () = {proc_map= Procname.Hash.create 17; file_map= SourceFile.Hash.create 1} diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index cec1685ba..a03ae9fe5 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -14,14 +14,14 @@ open! IStd type file_data type t = private - { proc_map: file_data Typ.Procname.Hash.t (** map from procedure name to file data *) + { proc_map: file_data Procname.Hash.t (** map from procedure name to file data *) ; file_map: file_data SourceFile.Hash.t (** map from source files to file data *) } val mk : unit -> t (** Create a new cache *) -val get_tenv : t -> Typ.Procname.t -> Tenv.t +val get_tenv : t -> Procname.t -> Tenv.t (** return the type environment associated with the procedure *) -val get_integer_type_widths : t -> Typ.Procname.t -> Typ.IntegerWidths.t +val get_integer_type_widths : t -> Procname.t -> Typ.IntegerWidths.t (** return the integer type widths associated with the procedure *) diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index a14aa067b..6738e7d4a 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -13,7 +13,7 @@ type path_filter = SourceFile.t -> bool type error_filter = IssueType.t -> bool -type proc_filter = Typ.Procname.t -> bool +type proc_filter = Procname.t -> bool type filters = {path_filter: path_filter; error_filter: error_filter; proc_filter: proc_filter} @@ -46,8 +46,8 @@ let is_matching patterns source_file = (** 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)) - && Language.equal (Typ.Procname.get_language proc_name) language - && String.equal (Typ.Procname.get_method proc_name) method_name + && Language.equal (Procname.get_language proc_name) language + && String.equal (Procname.get_method proc_name) method_name (* Module to create matcher based on strings present in the source file *) @@ -92,7 +92,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 -> Typ.Procname.t -> bool + type matcher = SourceFile.t -> Procname.t -> bool let default_matcher : matcher = fun _ _ -> false @@ -110,8 +110,8 @@ module FileOrProcMatcher = struct ~init:String.Map.empty m_patterns in let do_java pname_java = - let class_name = Typ.Procname.Java.get_class_name pname_java - and method_name = Typ.Procname.Java.get_method pname_java in + let class_name = Procname.Java.get_class_name pname_java + and method_name = Procname.Java.get_method pname_java in try let class_patterns = String.Map.find_exn pattern_map class_name in List.exists @@ -121,7 +121,7 @@ module FileOrProcMatcher = struct with Not_found_s _ | Caml.Not_found -> false in fun _ proc_name -> - match proc_name with Typ.Procname.Java pname_java -> do_java pname_java | _ -> false + match proc_name with Procname.Java pname_java -> do_java pname_java | _ -> false let create_file_matcher patterns = diff --git a/infer/src/backend/inferconfig.mli b/infer/src/backend/inferconfig.mli index c4230d895..ebf7b278e 100644 --- a/infer/src/backend/inferconfig.mli +++ b/infer/src/backend/inferconfig.mli @@ -14,20 +14,20 @@ type path_filter = SourceFile.t -> bool type error_filter = IssueType.t -> bool (** Filter type for a procedure name *) -type proc_filter = Typ.Procname.t -> bool +type proc_filter = Procname.t -> bool type filters = {path_filter: path_filter; error_filter: error_filter; proc_filter: proc_filter} val create_filters : unit -> filters (** Create filters based on the config file *) -val never_return_null_matcher : SourceFile.t -> Typ.Procname.t -> bool +val never_return_null_matcher : SourceFile.t -> Procname.t -> bool -val skip_translation_matcher : SourceFile.t -> Typ.Procname.t -> bool +val skip_translation_matcher : SourceFile.t -> Procname.t -> bool -val skip_implementation_matcher : SourceFile.t -> Typ.Procname.t -> bool +val skip_implementation_matcher : SourceFile.t -> Procname.t -> bool -val modeled_expensive_matcher : (string -> bool) -> Typ.Procname.t -> bool +val modeled_expensive_matcher : (string -> bool) -> Procname.t -> bool val test : unit -> unit (** Load the config file and list the files to report on *) diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 96f86806a..55e8d8068 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -15,21 +15,20 @@ module F = Format let exe_env_ref = ref None module LocalCache = struct - let results = lazy (Typ.Procname.Hash.create 128) + let results = lazy (Procname.Hash.create 128) - let clear () = Typ.Procname.Hash.clear (Lazy.force results) + let clear () = Procname.Hash.clear (Lazy.force results) - let remove pname = Typ.Procname.Hash.remove (Lazy.force results) pname + let remove pname = Procname.Hash.remove (Lazy.force results) pname let get proc_name = - let summ_opt_opt = Typ.Procname.Hash.find_opt (Lazy.force results) proc_name in + let summ_opt_opt = Procname.Hash.find_opt (Lazy.force results) proc_name in if Option.is_some summ_opt_opt then BackendStats.incr_ondemand_local_cache_hits () else BackendStats.incr_ondemand_local_cache_misses () ; summ_opt_opt - let add proc_name summary_option = - Typ.Procname.Hash.add (Lazy.force results) proc_name summary_option + let add proc_name summary_option = Procname.Hash.add (Lazy.force results) proc_name summary_option end let set_exe_env (env : Exe_env.t) = exe_env_ref := Some env @@ -46,12 +45,11 @@ let max_nesting_to_print = 8 let current_taskbar_status : (Mtime.t * string) option ref = ref None let is_active, add_active, remove_active = - let currently_analyzed = ref Typ.Procname.Set.empty in - let is_active proc_name = Typ.Procname.Set.mem proc_name !currently_analyzed - and add_active proc_name = - currently_analyzed := Typ.Procname.Set.add proc_name !currently_analyzed + let currently_analyzed = ref Procname.Set.empty in + let is_active proc_name = Procname.Set.mem proc_name !currently_analyzed + and add_active proc_name = currently_analyzed := Procname.Set.add proc_name !currently_analyzed and remove_active proc_name = - currently_analyzed := Typ.Procname.Set.remove proc_name !currently_analyzed + currently_analyzed := Procname.Set.remove proc_name !currently_analyzed in (is_active, add_active, remove_active) @@ -151,7 +149,7 @@ let analyze callee_summary = if !nesting <= max_nesting_to_print then String.make !nesting '>' else Printf.sprintf "%d>" !nesting in - F.asprintf "%s%a: %a" nesting SourceFile.pp source_file Typ.Procname.pp proc_name + F.asprintf "%s%a: %a" nesting SourceFile.pp source_file Procname.pp proc_name in current_taskbar_status := Some (t0, status) ; !ProcessPoolState.update_status t0 status ; @@ -166,13 +164,13 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = let start_time = Mtime_clock.counter () in fun () -> L.(debug Analysis Medium) - "Elapsed analysis time: %a: %a@\n" Typ.Procname.pp callee_pname Mtime.Span.pp + "Elapsed analysis time: %a: %a@\n" Procname.pp callee_pname Mtime.Span.pp (Mtime_clock.count start_time) in if Config.trace_ondemand then - L.progress "[%d] run_proc_analysis %a -> %a@." !nesting (Pp.option Typ.Procname.pp) + L.progress "[%d] run_proc_analysis %a -> %a@." !nesting (Pp.option Procname.pp) (Option.map caller_pdesc ~f:Procdesc.get_proc_name) - Typ.Procname.pp callee_pname ; + Procname.pp callee_pname ; let preprocess () = incr nesting ; Preanal.do_preanalysis (Option.value_exn !exe_env_ref) callee_pdesc ; @@ -224,11 +222,11 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = let source_file = attributes.ProcAttributes.translation_unit in let location = attributes.ProcAttributes.loc in L.internal_error "While analysing function %a:%a at %a@\n" SourceFile.pp source_file - Typ.Procname.pp callee_pname Location.pp_file_pos location ; + Procname.pp callee_pname Location.pp_file_pos location ; logged_error := true ) ; restore_global_state old_state ; not Config.keep_going ) ; - L.internal_error "@\nERROR RUNNING BACKEND: %a %s@\n@\nBACK TRACE@\n%s@?" Typ.Procname.pp + L.internal_error "@\nERROR RUNNING BACKEND: %a %s@\n@\nBACK TRACE@\n%s@?" Procname.pp callee_pname (Exn.to_string exn) backtrace ; match exn with | SymOp.Analysis_failure_exe kind -> @@ -246,7 +244,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = log (fun logger -> let callee_pname = Procdesc.get_proc_name callee_pdesc in log_begin_event logger ~name:"ondemand" ~categories:["backend"] - ~arguments:[("proc", `String (Typ.Procname.to_string callee_pname))] + ~arguments:[("proc", `String (Procname.to_string callee_pname))] () )) ; let summary = run_proc_analysis ~caller_pdesc callee_pdesc in PerfEvent.(log (fun logger -> log_end_event logger ())) ; @@ -278,7 +276,7 @@ let dump_duplicate_procs source_file procs = let fmt = F.formatter_of_out_channel outc in List.iter duplicate_procs ~f:(fun (pname, source_captured) -> F.fprintf fmt "DUPLICATE_SYMBOLS source:%a source_captured:%a pname:%a@\n" SourceFile.pp - source_file SourceFile.pp source_captured Typ.Procname.pp pname ) ; + source_file SourceFile.pp source_captured Procname.pp pname ) ; F.pp_print_flush fmt () ) in if not (List.is_empty duplicate_procs) then output_to_file duplicate_procs @@ -292,7 +290,7 @@ let create_perf_stats_report source_file = let register_callee ?caller_summary callee_pname = Option.iter ~f:(fun (summary : Summary.t) -> - summary.callee_pnames <- Typ.Procname.Set.add callee_pname summary.callee_pnames ) + summary.callee_pnames <- Procname.Set.add callee_pname summary.callee_pnames ) caller_summary @@ -303,7 +301,7 @@ let get_proc_desc callee_pname = ; lazy (Topl.get_proc_desc callee_pname) ] -type callee = ProcName of Typ.Procname.t | ProcDesc of Procdesc.t +type callee = ProcName of Procname.t | ProcDesc of Procdesc.t let proc_name_of_callee = function | ProcName proc_name -> @@ -346,7 +344,7 @@ let analyze_callee ?caller_summary callee = | None -> Summary.OnDisk.get callee_pname else ( - EventLogger.log_skipped_pname (F.asprintf "%a" Typ.Procname.pp callee_pname) ; + EventLogger.log_skipped_pname (F.asprintf "%a" Procname.pp callee_pname) ; Summary.OnDisk.get callee_pname ) in LocalCache.add callee_pname summ_opt ; diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index e47e33c77..e88f4d006 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -9,18 +9,18 @@ open! IStd (** Module for on-demand analysis. *) -val get_proc_desc : Typ.Procname.t -> Procdesc.t option +val get_proc_desc : Procname.t -> Procdesc.t option (** Find a proc desc for the procedure, perhaps loading it from disk. *) val analyze_proc_desc : caller_summary:Summary.t -> Procdesc.t -> Summary.t option (** [analyze_proc_desc ~caller_summary callee_pdesc] performs an on-demand analysis of callee_pdesc triggered during the analysis of caller_summary *) -val analyze_proc_name : caller_summary:Summary.t -> Typ.Procname.t -> Summary.t option +val analyze_proc_name : caller_summary:Summary.t -> Procname.t -> Summary.t option (** [analyze_proc_name ~caller_summary callee_pname] performs an on-demand analysis of callee_pname triggered during the analysis of caller_summary *) -val analyze_proc_name_no_caller : Typ.Procname.t -> Summary.t option +val analyze_proc_name_no_caller : Procname.t -> Summary.t option (** [analyze_proc_name_no_caller callee_pname] performs an on-demand analysis of callee_pname triggered by the top-level of a cluster checker *) @@ -31,12 +31,12 @@ module LocalCache : sig val clear : unit -> unit (** Empty the cache of ondemand results *) - val remove : Typ.Procname.t -> unit + val remove : Procname.t -> unit (** Remove an element from the cache of ondemand results *) end val analyze_file : Exe_env.t -> SourceFile.t -> unit (** Invoke all the callbacks registered in {!Callbacks} on the given file. *) -val analyze_proc_name_toplevel : Exe_env.t -> Typ.Procname.t -> unit +val analyze_proc_name_toplevel : Exe_env.t -> Procname.t -> unit (** Invoke all the callbacks registered in {!Callbacks} on the given procedure. *) diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 2fd24d938..74d7c7cd4 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -74,7 +74,7 @@ module Liveness = struct astate - let cache_node = ref (Procdesc.Node.dummy Typ.Procname.Linters_dummy_method) + let cache_node = ref (Procdesc.Node.dummy Procname.Linters_dummy_method) let cache_instr = ref Sil.skip_instr @@ -129,7 +129,7 @@ module Liveness = struct let add_nullify_instrs summary tenv liveness_inv_map = let address_taken_vars = - if Typ.Procname.is_java (Summary.get_proc_name summary) then AddressTaken.Domain.empty + if Procname.is_java (Summary.get_proc_name summary) then AddressTaken.Domain.empty (* can't take the address of a variable in Java *) else let initial = AddressTaken.Domain.empty in @@ -236,9 +236,7 @@ end let do_preanalysis exe_env pdesc = let summary = Summary.OnDisk.reset pdesc in let tenv = Exe_env.get_tenv exe_env (Procdesc.get_proc_name pdesc) in - if - Config.function_pointer_specialization - && not (Typ.Procname.is_java (Procdesc.get_proc_name pdesc)) + if Config.function_pointer_specialization && not (Procname.is_java (Procdesc.get_proc_name pdesc)) then FunctionPointerSubstitution.process summary tenv ; Liveness.process summary tenv ; AddAbstractionInstructions.process pdesc ; diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index a9263c218..dcf04ba27 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -131,7 +131,7 @@ end = struct line ; F.fprintf fmt "PROC: %a LINE: %a@\n" (Io_infer.Html.pp_proc_link [".."] proc_name) - (Escape.escape_xml (Typ.Procname.to_string proc_name)) + (Escape.escape_xml (Procname.to_string proc_name)) (Io_infer.Html.pp_line_link source [".."]) line ; F.fprintf fmt "
PREDS:@\n" ; @@ -174,10 +174,10 @@ end = struct let source = loc.file in let nodes = List.sort ~compare:Procdesc.Node.compare (Procdesc.get_nodes pdesc) in let linenum = loc.Location.line in - let fd, fmt = Io_infer.Html.create source [Typ.Procname.to_filename pname] in + let fd, fmt = Io_infer.Html.create source [Procname.to_filename pname] in F.fprintf fmt "

Procedure %a

@\n" (Io_infer.Html.pp_line_link source - ~text:(Some (Escape.escape_xml (Typ.Procname.to_string pname))) + ~text:(Some (Escape.escape_xml (Procname.to_string pname))) []) linenum ; pp_node_link_seq [] ~description:true fmt nodes ; @@ -257,7 +257,7 @@ end = struct match Procdesc.Node.get_kind n with | Procdesc.Node.Start_node -> let proc_name = Procdesc.Node.get_proc_name n in - let proc_name_escaped = Escape.escape_xml (Typ.Procname.to_string proc_name) in + let proc_name_escaped = Escape.escape_xml (Procname.to_string proc_name) in if Summary.OnDisk.get proc_name |> Option.is_some then ( F.pp_print_char fmt ' ' ; let label = F.asprintf "summary for %s" proc_name_escaped in @@ -309,9 +309,9 @@ end = struct if is_whitelisted file then ( let pdescs_in_file = try Hashtbl.find pdescs_in_source file - with Caml.Not_found -> Typ.Procname.Map.empty + with Caml.Not_found -> Procname.Map.empty in - let pdescs_in_file = Typ.Procname.Map.add proc_name proc_desc pdescs_in_file in + let pdescs_in_file = Procname.Map.add proc_name proc_desc pdescs_in_file in Hashtbl.replace pdescs_in_source file pdescs_in_file ; SourceFile.Set.add file files ) else files @@ -324,7 +324,7 @@ end = struct let pdescs_in_file = match Hashtbl.find pdescs_in_source file with | pdescs_map -> - Typ.Procname.Map.bindings pdescs_map |> List.map ~f:snd + Procname.Map.bindings pdescs_map |> List.map ~f:snd | exception Caml.Not_found -> [] in diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 39124da19..505e2eff3 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -31,15 +31,15 @@ let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn let procname = attrs.proc_name in let is_java_generated_method = match procname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_generated java_pname + | Procname.Java java_pname -> + Procname.Java.is_generated java_pname | _ -> false in let is_java_external_package = match procname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_external java_pname + | Procname.Java java_pname -> + Procname.Java.is_external java_pname | _ -> false in @@ -73,7 +73,7 @@ let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn = L.(die InternalError) "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?" - Typ.Procname.pp proc_name Typ.Procname.pp proc_name + Procname.pp proc_name Procname.pp proc_name let checker_exception issue_type error_message = diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index e1e9abbc0..ce9d1428d 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -13,7 +13,7 @@ type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t -> val log_issue_deprecated_using_state : Exceptions.severity - -> Typ.Procname.t + -> Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace @@ -23,7 +23,7 @@ val log_issue_deprecated_using_state : DEPRECATED as it can create race conditions between checkers. Use log_error/warning instead *) val log_frontend_issue : - Typ.Procname.t + Procname.t -> Exceptions.severity -> Errlog.t -> loc:Location.t @@ -43,7 +43,7 @@ val log_error_using_state : Summary.t -> exn -> unit (** Add an error to the given summary using biabduction state (DO NOT USE ELSEWHERE). *) val log_issue_external : - Typ.Procname.t + Procname.t -> issue_log:IssueLog.t -> Exceptions.severity -> loc:Location.t diff --git a/infer/src/biabduction/Abs.mli b/infer/src/biabduction/Abs.mli index a80de2c2b..668f4def4 100644 --- a/infer/src/biabduction/Abs.mli +++ b/infer/src/biabduction/Abs.mli @@ -13,29 +13,29 @@ open! IStd (** Abstraction rules discovered *) type rules -val abstract : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t +val abstract : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Abstract a proposition. *) val abstract_spec : - Typ.Procname.t -> Tenv.t -> Prop.normal BiabductionSummary.spec -> BiabductionSummary.NormSpec.t + Procname.t -> Tenv.t -> Prop.normal BiabductionSummary.spec -> BiabductionSummary.NormSpec.t (** Normalizes names and applies simplifications, soem of which require looking at both pre and post. *) -val abstract_junk : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t +val abstract_junk : 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_no_symop : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t +val abstract_no_symop : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Abstract a proposition but don't pay a SymOp *) val get_current_rules : unit -> rules (** Get the current rules discoveres *) -val lifted_abstract : Typ.Procname.t -> Tenv.t -> Propset.t -> Propset.t +val lifted_abstract : Procname.t -> Tenv.t -> Propset.t -> Propset.t (** Abstract each proposition in [propset] *) val remove_redundant_array_elements : - Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t + Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t (** Remove redundant elements in an array, and check for junk afterwards *) val reset_current_rules : unit -> unit diff --git a/infer/src/biabduction/Attribute.mli b/infer/src/biabduction/Attribute.mli index 1d32c48fd..18fff308e 100644 --- a/infer/src/biabduction/Attribute.mli +++ b/infer/src/biabduction/Attribute.mli @@ -89,7 +89,7 @@ val mark_vars_as_undefined : -> Prop.normal Prop.t -> ret_exp:Exp.t -> undefined_actuals_by_ref:Exp.t list - -> Typ.Procname.t + -> Procname.t -> Annot.Item.t -> Location.t -> PredSymb.path_pos diff --git a/infer/src/biabduction/Builtin.ml b/infer/src/biabduction/Builtin.ml index 71b745300..b5f27dd5c 100644 --- a/infer/src/biabduction/Builtin.ml +++ b/infer/src/biabduction/Builtin.ml @@ -18,7 +18,7 @@ type args = ; path: Paths.Path.t ; ret_id_typ: Ident.t * Typ.t ; args: (Exp.t * Typ.t) list - ; proc_name: Typ.Procname.t + ; proc_name: Procname.t ; loc: Location.t ; exe_env: Exe_env.t } @@ -29,32 +29,32 @@ type t = args -> ret_typ type registered = t (** builtin function names for which we do symbolic execution *) -let builtin_functions = Typ.Procname.Hash.create 4 +let builtin_functions = Procname.Hash.create 4 let check_register_populated () = (* check if BuiltinDefn were loaded before accessing register *) - if Int.equal (Typ.Procname.Hash.length builtin_functions) 0 then + if Int.equal (Procname.Hash.length builtin_functions) 0 then L.(die InternalError) "Builtins were not initialized" (** get the symbolic execution handler associated to the builtin function name *) let get name : t option = - try Some (Typ.Procname.Hash.find builtin_functions name) + try Some (Procname.Hash.find builtin_functions name) with Caml.Not_found -> check_register_populated () ; None -(** register a builtin [Typ.Procname.t] and symbolic execution handler *) +(** register a builtin [Procname.t] and symbolic execution handler *) let register proc_name sym_exe_fun : registered = - Typ.Procname.Hash.replace builtin_functions proc_name sym_exe_fun ; + 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 - Typ.Procname.Hash.iter (fun name _ -> builtin_names := name :: !builtin_names) builtin_functions ; - builtin_names := List.sort ~compare:Typ.Procname.compare !builtin_names ; - let pp pname = Format.fprintf fmt "%a@\n" Typ.Procname.pp pname in + Procname.Hash.iter (fun name _ -> builtin_names := name :: !builtin_names) builtin_functions ; + builtin_names := List.sort ~compare:Procname.compare !builtin_names ; + let pp pname = Format.fprintf fmt "%a@\n" Procname.pp pname in Format.fprintf fmt "Registered builtins:@\n @[" ; List.iter ~f:pp !builtin_names ; Format.fprintf fmt "@]@." diff --git a/infer/src/biabduction/Builtin.mli b/infer/src/biabduction/Builtin.mli index c86fe1e69..edb9f9144 100644 --- a/infer/src/biabduction/Builtin.mli +++ b/infer/src/biabduction/Builtin.mli @@ -17,7 +17,7 @@ type args = ; path: Paths.Path.t ; ret_id_typ: Ident.t * Typ.t ; args: (Exp.t * Typ.t) list - ; proc_name: Typ.Procname.t + ; proc_name: Procname.t ; loc: Location.t ; exe_env: Exe_env.t } @@ -27,10 +27,10 @@ type t = args -> ret_typ type registered -val register : Typ.Procname.t -> t -> registered -(** Register a builtin [Typ.Procname.t] and symbolic execution handler *) +val register : Procname.t -> t -> registered +(** Register a builtin [Procname.t] and symbolic execution handler *) -val get : Typ.Procname.t -> t option +val get : 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/biabduction/BuiltinDefn.ml b/infer/src/biabduction/BuiltinDefn.ml index b799f7990..0d69a7bbe 100644 --- a/infer/src/biabduction/BuiltinDefn.ml +++ b/infer/src/biabduction/BuiltinDefn.ml @@ -647,7 +647,7 @@ let execute_pthread_create ({Builtin.tenv; summary; prop_; path; args; exe_env} | Exp.Lvar pvar, _ -> let fun_name = Pvar.get_name pvar in let fun_string = Mangled.to_string fun_name in - Some (Typ.Procname.from_string_c_fun fun_string) + Some (Procname.from_string_c_fun fun_string) | Exp.Const (Cfun pname), _ -> Some pname | _ -> @@ -660,7 +660,7 @@ let execute_pthread_create ({Builtin.tenv; summary; prop_; path; args; exe_env} L.d_strln ", skipping call." ; [(prop_, path)] | Some pname -> ( - L.d_printfln "pthread_create: calling function %a" Typ.Procname.pp pname ; + L.d_printfln "pthread_create: calling function %a" Procname.pp pname ; match Ondemand.analyze_proc_name ~caller_summary:summary pname with | None -> (* no precondition to check, skip *) diff --git a/infer/src/biabduction/Dom.mli b/infer/src/biabduction/Dom.mli index a202be39d..f8f3fe345 100644 --- a/infer/src/biabduction/Dom.mli +++ b/infer/src/biabduction/Dom.mli @@ -13,11 +13,7 @@ open! IStd (** {2 Join Operators} *) val pathset_join : - Typ.Procname.t - -> Tenv.t - -> Paths.PathSet.t - -> Paths.PathSet.t - -> Paths.PathSet.t * Paths.PathSet.t + Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths.PathSet.t -> Paths.PathSet.t * Paths.PathSet.t (** Join two pathsets *) val proplist_collapse_pre : diff --git a/infer/src/biabduction/Paths.ml b/infer/src/biabduction/Paths.ml index 8060924e6..953cb8fa3 100644 --- a/infer/src/biabduction/Paths.ml +++ b/infer/src/biabduction/Paths.ml @@ -20,11 +20,11 @@ module Path : sig type session = int - val add_call : bool -> t -> Typ.Procname.t -> t -> t + val add_call : bool -> t -> Procname.t -> t -> t (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) - val add_skipped_call : t -> Typ.Procname.t -> string -> Location.t option -> t + val add_skipped_call : t -> Procname.t -> string -> Location.t option -> t (** add a call to a procname that's had to be skipped, along with the reason and the location of the procname when known *) @@ -74,7 +74,7 @@ end = struct let compare_stats_ _ _ = 0 - type procname_ = Typ.Procname.t + type procname_ = Procname.t let compare_procname_ _ _ = 0 @@ -442,17 +442,17 @@ end = struct let curr_loc = Procdesc.Node.get_loc curr_node in let descr = Format.asprintf "Skipping %a: %s" - (Typ.Procname.pp_simplified_string ~withclass:false) + (Procname.pp_simplified_string ~withclass:false) pname reason in let node_tags = [] in trace := Errlog.make_trace_element level curr_loc descr node_tags :: !trace ; Option.iter ~f:(fun loc -> - if Typ.Procname.is_java pname && not (SourceFile.is_invalid loc.Location.file) then + if Procname.is_java pname && not (SourceFile.is_invalid loc.Location.file) then let definition_descr = Format.asprintf "Definition of %a" - (Typ.Procname.pp_simplified_string ~withclass:false) + (Procname.pp_simplified_string ~withclass:false) pname in trace := Errlog.make_trace_element (level + 1) loc definition_descr [] :: !trace ) @@ -466,7 +466,7 @@ end = struct let pname = Procdesc.Node.get_proc_name curr_node in let descr = F.asprintf "start of procedure %a" - (Typ.Procname.pp_simplified_string ~withclass:false) + (Procname.pp_simplified_string ~withclass:false) pname in let node_tags = [Errlog.Procedure_start pname] in @@ -495,7 +495,7 @@ end = struct trace := Errlog.make_trace_element level curr_loc descr node_tags :: !trace | Procdesc.Node.Exit_node -> let pname = Procdesc.Node.get_proc_name curr_node in - let descr = F.asprintf "return from a call to %a" Typ.Procname.pp pname in + let descr = F.asprintf "return from a call to %a" Procname.pp pname in let node_tags = [Errlog.Procedure_end pname] in trace := Errlog.make_trace_element level curr_loc descr node_tags :: !trace | _ -> diff --git a/infer/src/biabduction/Paths.mli b/infer/src/biabduction/Paths.mli index e6dd5b115..31c03bda0 100644 --- a/infer/src/biabduction/Paths.mli +++ b/infer/src/biabduction/Paths.mli @@ -16,11 +16,11 @@ module Path : sig type session = int - val add_call : bool -> t -> Typ.Procname.t -> t -> t + val add_call : bool -> t -> Procname.t -> t -> t (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) - val add_skipped_call : t -> Typ.Procname.t -> string -> Location.t option -> t + val add_skipped_call : t -> Procname.t -> string -> Location.t option -> t (** add a call to a procname that's had to be skipped, along with the reason and the location of the procname when known *) diff --git a/infer/src/biabduction/PropUtil.ml b/infer/src/biabduction/PropUtil.ml index b95d25308..5adb6d207 100644 --- a/infer/src/biabduction/PropUtil.ml +++ b/infer/src/biabduction/PropUtil.ml @@ -12,7 +12,7 @@ let get_name_of_local (curr_f : Procdesc.t) (var_data : ProcAttributes.var_data) (* 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 = Typ.Procname.to_string (Procdesc.get_proc_name curr_f) in + let pname = Procname.to_string (Procdesc.get_proc_name curr_f) in let local_static e = match e with | Exp.Lvar pvar diff --git a/infer/src/biabduction/Prover.ml b/infer/src/biabduction/Prover.ml index 57416eef5..0e62c5f42 100644 --- a/infer/src/biabduction/Prover.ml +++ b/infer/src/biabduction/Prover.ml @@ -947,7 +947,7 @@ let check_inconsistency_base tenv prop = false | Some (_, _, pdesc) -> let procedure_attr = Procdesc.get_attributes pdesc in - let language = Typ.Procname.get_language (Procdesc.get_proc_name pdesc) in + let language = Procname.get_language (Procdesc.get_proc_name pdesc) in let is_java_this pvar = Language.equal language Java && Pvar.is_this pvar in let is_objc_instance_self pvar = Language.equal language Clang && Pvar.is_self pvar diff --git a/infer/src/biabduction/Prover.mli b/infer/src/biabduction/Prover.mli index 111700c54..85164c15a 100644 --- a/infer/src/biabduction/Prover.mli +++ b/infer/src/biabduction/Prover.mli @@ -59,8 +59,7 @@ val get_bounds : Tenv.t -> Prop.normal Prop.t -> Exp.t -> IntLit.t option * IntL (** {2 Abduction prover} *) -val check_implication : - Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> bool +val check_implication : Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> bool (** [check_implication p1 p2] returns true if [p1|-p2] *) type check = Bounds_check | Class_cast_check of Exp.t * Exp.t * Exp.t @@ -82,7 +81,7 @@ type implication_result = | ImplFail of check list val check_implication_for_footprint : - Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> implication_result + Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.exposed Prop.t -> implication_result (** [check_implication_for_footprint p1 p2] returns [Some(sub, frame, missing)] if [sub(p1 * missing) |- sub(p2 * frame)] where [sub] is a substitution which instantiates the primed vars of [p1] and [p2], which are assumed to be disjoint. *) diff --git a/infer/src/biabduction/Rearrange.ml b/infer/src/biabduction/Rearrange.ml index f4a760532..ad9bc1016 100644 --- a/infer/src/biabduction/Rearrange.ml +++ b/infer/src/biabduction/Rearrange.ml @@ -459,7 +459,7 @@ let mk_ptsto_exp_footprint pname tenv orig_prop (lexp, typ) max_stamp inst : let create_ptsto footprint_part off0 = match (root, off0, typ.Typ.desc) with | Exp.Lvar pvar, [], Typ.Tfun -> - let fun_name = Typ.Procname.from_string_c_fun (Mangled.to_string (Pvar.get_name pvar)) in + let fun_name = 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 @@ -725,9 +725,9 @@ let add_guarded_by_constraints tenv prop lexp pdesc = (dollar_normalize (class_str ^ ".class")) in let guarded_by_str_is_current_class guarded_by_str = function - | Typ.Procname.Java java_pname -> + | 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 (Typ.Procname.Java.get_class_name java_pname) + guarded_by_str_is_class guarded_by_str (Procname.Java.get_class_name java_pname) | _ -> false in @@ -738,8 +738,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 - | Typ.Procname.Java java_pname -> - let current_class_type_name = Typ.Procname.Java.get_class_type_name java_pname in + | Procname.Java java_pname -> + let current_class_type_name = Procname.Java.get_class_type_name java_pname in let comparison class_type_name _ = guarded_by_str_is_class_this (Typ.Name.to_string class_type_name) guarded_by_str in @@ -749,8 +749,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc = in (* return true if [guarded_by_str] is as suffix of ".this" *) let guarded_by_str_is_current_class_this guarded_by_str = function - | Typ.Procname.Java java_pname -> - guarded_by_str_is_class_this (Typ.Procname.Java.get_class_name java_pname) guarded_by_str + | Procname.Java java_pname -> + guarded_by_str_is_class_this (Procname.Java.get_class_name java_pname) guarded_by_str | _ -> false in @@ -879,11 +879,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc = guarded_by_str_is_current_class guarded_by_str pname && Procdesc.is_java_synchronized pdesc && - match pname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_static java_pname - | _ -> - false + match pname with Procname.Java java_pname -> Procname.Java.is_static java_pname | _ -> false in let warn accessed_fld guarded_by_str = let loc = State.get_loc_exn () in @@ -912,8 +908,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc = && Procdesc.is_java_synchronized pdesc && match pname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_static java_pname + | Procname.Java java_pname -> + Procname.Java.is_static java_pname | _ -> false ) || (* or the prop says we already have the lock *) @@ -959,8 +955,8 @@ let add_guarded_by_constraints tenv prop lexp pdesc = && (not (Annotations.pdesc_return_annot_ends_with pdesc Annotations.visibleForTesting)) && (not ( match Procdesc.get_proc_name pdesc with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_access_method java_pname + | Procname.Java java_pname -> + Procname.Java.is_access_method java_pname | _ -> false )) && (not (is_accessible_through_local_ref lexp)) @@ -1471,7 +1467,7 @@ let attr_has_annot is_annotation tenv prop exp = let attr_has_annot = function | Predicates.Apred ((Aretval (pname, ret_attr) | Aundef (pname, ret_attr, _, _)), _) when is_annotation ret_attr -> - Some (Typ.Procname.to_string pname) + Some (Procname.to_string pname) | _ -> None in @@ -1726,11 +1722,10 @@ let rearrange ?(report_deref_errors = true) pdesc tenv lexp typ prop loc : let pname = Procdesc.get_proc_name pdesc in let prop' = match pname with - | Typ.Procname.Java java_pname + | Procname.Java java_pname when Config.csl_analysis && !BiabductionConfig.footprint - && not - ( Typ.Procname.is_constructor pname - || Typ.Procname.Java.is_class_initializer java_pname ) -> + && not (Procname.is_constructor pname || Procname.Java.is_class_initializer java_pname) + -> add_guarded_by_constraints tenv prop lexp pdesc | _ -> prop diff --git a/infer/src/biabduction/RetainCyclesType.ml b/infer/src/biabduction/RetainCyclesType.ml index 62fa0dd57..8f5de8f54 100644 --- a/infer/src/biabduction/RetainCyclesType.ml +++ b/infer/src/biabduction/RetainCyclesType.ml @@ -12,7 +12,7 @@ type retain_cycle_field = {rc_field_name: Fieldname.t; rc_field_inst: Predicates type retain_cycle_edge_obj = {rc_from: retain_cycle_node; rc_field: retain_cycle_field} -type retain_cycle_edge = Object of retain_cycle_edge_obj | Block of Typ.Procname.t * Pvar.t +type retain_cycle_edge = Object of retain_cycle_edge_obj | Block of Procname.t * Pvar.t type t = {rc_head: retain_cycle_edge; rc_elements: retain_cycle_edge list} @@ -36,7 +36,7 @@ let compare_retain_cycle_edge (edge1 : retain_cycle_edge) (edge2 : retain_cycle_ | Object edge_obj1, Object edge_obj2 -> compare_retain_cycle_edge_obj edge_obj1 edge_obj2 | Block (procname1, _), Block (procname2, _) -> - Typ.Procname.compare procname1 procname2 + Procname.compare procname1 procname2 | Object _, Block _ -> 1 | Block _, Object _ -> @@ -173,7 +173,7 @@ let pp_dotty fmt cycle = (Typ.to_string obj.rc_from.rc_node_typ) Fieldname.pp obj.rc_field.rc_field_name | Block (name, _) -> - Typ.Procname.pp_unique_id fmt name + Procname.pp_unique_id fmt name in let pp_dotty_field fmt element = match element with diff --git a/infer/src/biabduction/RetainCyclesType.mli b/infer/src/biabduction/RetainCyclesType.mli index 2b46c1060..49d1452bf 100644 --- a/infer/src/biabduction/RetainCyclesType.mli +++ b/infer/src/biabduction/RetainCyclesType.mli @@ -13,7 +13,7 @@ type retain_cycle_field = {rc_field_name: Fieldname.t; rc_field_inst: Predicates type retain_cycle_edge_obj = {rc_from: retain_cycle_node; rc_field: retain_cycle_field} -type retain_cycle_edge = Object of retain_cycle_edge_obj | Block of Typ.Procname.t * Pvar.t +type retain_cycle_edge = Object of retain_cycle_edge_obj | Block of Procname.t * Pvar.t (** A retain cycle is a non-empty list of paths. It also contains a pointer to the head of the list to model the cycle structure. The next element from the end of the list is the head. *) diff --git a/infer/src/biabduction/State.ml b/infer/src/biabduction/State.ml index 6b4f2f31a..5bda8d791 100644 --- a/infer/src/biabduction/State.ml +++ b/infer/src/biabduction/State.ml @@ -223,7 +223,7 @@ let get_path_pos () = | Some (_, _, pdesc) -> Procdesc.get_proc_name pdesc | None -> - Typ.Procname.from_string_c_fun "unknown_procedure" + Procname.from_string_c_fun "unknown_procedure" in let nid = Procdesc.Node.get_id (get_node_exn ()) in (pname, (nid :> int)) @@ -260,7 +260,7 @@ let mark_instr_fail exn = type log_issue = - Typ.Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace -> exn -> unit + Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace -> exn -> unit let process_execution_failures (log_issue : log_issue) pname = let do_failure _ fs = diff --git a/infer/src/biabduction/State.mli b/infer/src/biabduction/State.mli index d28b0e5cf..613982605 100644 --- a/infer/src/biabduction/State.mli +++ b/infer/src/biabduction/State.mli @@ -77,9 +77,9 @@ val mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet. same kind and location and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) type log_issue = - Typ.Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace -> exn -> unit + Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace -> exn -> unit -val process_execution_failures : log_issue -> Typ.Procname.t -> unit +val process_execution_failures : log_issue -> Procname.t -> unit (** Process the failures during symbolic execution of a procedure *) val reset : unit -> unit diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index af63c480e..597dd7661 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -335,11 +335,11 @@ and prune_union tenv ~positive condition1 condition2 prop = let dangerous_functions = let dangerous_list = ["gets"] in - ref (List.map ~f:Typ.Procname.from_string_c_fun dangerous_list) + ref (List.map ~f:Procname.from_string_c_fun dangerous_list) let check_inherently_dangerous_function caller_pname callee_pname = - if List.exists ~f:(Typ.Procname.equal callee_pname) !dangerous_functions then + if List.exists ~f:(Procname.equal callee_pname) !dangerous_functions then let exn = Exceptions.Inherently_dangerous_function (Localise.desc_inherently_dangerous_function callee_pname) @@ -354,7 +354,7 @@ let reason_to_skip ~callee_desc : string option = else None in let reason_from_pname pname = - if Typ.Procname.is_method_in_objc_protocol pname then + if Procname.is_method_in_objc_protocol pname then Some "no implementation found for method declared in Objective-C protocol" else None in @@ -500,7 +500,7 @@ let check_deallocate_static_memory prop_after = let method_exists right_proc_name methods = if Language.curr_language_is Java then - List.exists ~f:(fun meth_name -> Typ.Procname.equal right_proc_name meth_name) methods + List.exists ~f:(fun meth_name -> 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 @@ -517,7 +517,7 @@ let resolve_method tenv class_name proc_name = let visited = ref Typ.Name.Set.empty in let rec resolve (class_name : Typ.Name.t) = visited := Typ.Name.Set.add class_name !visited ; - let right_proc_name = Typ.Procname.replace_class proc_name class_name in + let right_proc_name = Procname.replace_class proc_name class_name in match Tenv.lookup tenv class_name with | Some {methods; supers} when Typ.Name.is_class class_name -> ( if method_exists right_proc_name methods then Some right_proc_name @@ -559,7 +559,7 @@ let resolve_typename prop receiver_exp = (** If the dynamic type of the receiver actual T_actual is a subtype of the receiver 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 : Typ.Procname.t list = +let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Procname.t list = let resolve receiver_exp pname prop = match resolve_typename prop receiver_exp with | Some class_name -> @@ -569,8 +569,8 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Typ.Procna in let get_receiver_typ pname fallback_typ = match pname with - | Typ.Procname.Java pname_java -> ( - let name = Typ.Procname.Java.get_class_type_name pname_java in + | Procname.Java pname_java -> ( + let name = Procname.Java.get_class_type_name pname_java in match Tenv.lookup tenv name with | Some _ -> Typ.mk (Typ.Tptr (Typ.mk (Tstruct name), Pk_pointer)) @@ -605,16 +605,16 @@ let resolve_virtual_pname tenv prop actuals callee_pname call_flags : Typ.Procna (** Resolve the name of the procedure to call based on the type of the arguments *) -let resolve_pname ~caller_pdesc tenv prop args pname call_flags : Typ.Procname.t = +let resolve_pname ~caller_pdesc tenv prop args pname call_flags : Procname.t = let resolve_from_args resolved_pname args = - let resolved_parameters = Typ.Procname.get_parameters resolved_pname in + let resolved_parameters = Procname.get_parameters resolved_pname in let resolved_params = try List.fold2_exn ~f:(fun accu (arg_exp, _) name -> match resolve_typename prop arg_exp with | Some class_name -> - Typ.Procname.parameter_of_name resolved_pname class_name :: accu + Procname.parameter_of_name resolved_pname class_name :: accu | None -> name :: accu ) ~init:[] args resolved_parameters @@ -624,14 +624,14 @@ let resolve_pname ~caller_pdesc tenv prop args pname call_flags : Typ.Procname.t let file = loc.Location.file in L.(debug Analysis Medium) "Call mismatch: method %a has %i paramters but is called with %i arguments, in %a, %a@." - Typ.Procname.pp pname (List.length resolved_parameters) (List.length args) SourceFile.pp - file Location.pp loc ; + Procname.pp pname (List.length resolved_parameters) (List.length args) SourceFile.pp file + Location.pp loc ; raise SpecializeProcdesc.UnmatchedParameters in - Typ.Procname.replace_parameters resolved_params resolved_pname + Procname.replace_parameters resolved_params resolved_pname in let resolved_pname, other_args = - let parameters = Typ.Procname.get_parameters pname in + let parameters = Procname.get_parameters pname in let match_parameters args = Int.equal (List.length args) (List.length parameters) in match args with | [] -> @@ -656,7 +656,7 @@ let resolve_pname ~caller_pdesc tenv prop args pname call_flags : Typ.Procname.t let file = loc.Location.file in L.(debug Analysis Medium) "Call mismatch: method %a has %i paramters but is called with %i arguments, in %a, %a@." - Typ.Procname.pp pname (List.length parameters) (List.length args) SourceFile.pp file + Procname.pp pname (List.length parameters) (List.length args) SourceFile.pp file Location.pp loc ; raise SpecializeProcdesc.UnmatchedParameters in @@ -681,7 +681,7 @@ let resolve_args prop args = type resolve_and_analyze_result = - { resolved_pname: Typ.Procname.t + { resolved_pname: Procname.t ; resolved_procdesc_opt: Procdesc.t option ; resolved_summary_opt: Summary.t option ; dynamic_dispatch_status: EventLogger.dynamic_dispatch option } @@ -693,7 +693,7 @@ let resolve_and_analyze tenv ~caller_summary ?(has_clang_model = false) prop arg (* 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 : Procdesc.t option * Summary.t option = - if Typ.Procname.equal resolved_pname callee_proc_name then + if Procname.equal resolved_pname callee_proc_name then ( Ondemand.get_proc_desc callee_proc_name , Ondemand.analyze_proc_name ~caller_summary callee_proc_name ) else @@ -722,7 +722,7 @@ let resolve_and_analyze tenv ~caller_summary ?(has_clang_model = false) prop arg tenv prop args callee_proc_name call_flags in let dynamic_dispatch_status = - if Typ.Procname.equal callee_proc_name resolved_pname then None + if Procname.equal callee_proc_name resolved_pname then None else Some EventLogger.Dynamic_dispatch_successful in let resolved_procdesc_opt, resolved_summary_opt = analyze_ondemand resolved_pname in @@ -733,14 +733,14 @@ let resolve_and_analyze tenv ~caller_summary ?(has_clang_model = false) prop arg protocol. *) let call_constructor_url_update_args pname actual_params = let url_pname = - Typ.Procname.Java - (Typ.Procname.Java.make + Procname.Java + (Procname.Java.make (Typ.Name.Java.from_string "java.net.URL") None "" [Typ.Name.Java.Split.java_lang_string] - Typ.Procname.Java.Non_Static) + Procname.Java.Non_Static) in - if Typ.Procname.equal url_pname pname then + if 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 @@ -778,9 +778,9 @@ let receiver_self receiver prop = 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 - Typ.Procname.is_constructor callee_pname + Procname.is_constructor callee_pname && receiver_self receiver pre && !BiabductionConfig.footprint - && Typ.Procname.is_constructor current_pname + && Procname.is_constructor current_pname then let propset = prune_ne tenv ~positive:false (Exp.Var ret_id) Exp.zero pre in if Propset.is_empty propset then [] @@ -800,7 +800,7 @@ let handle_objc_instance_method_call_or_skip pdesc tenv actual_pars path callee_ = let path_description = F.sprintf "Message %s with receiver nil returns nil." - (Typ.Procname.to_simplified_string callee_pname) + (Procname.to_simplified_string callee_pname) in let receiver = match actual_pars with @@ -830,7 +830,7 @@ let handle_objc_instance_method_call_or_skip pdesc tenv actual_pars path callee_ if is_receiver_null then ( (* objective-c instance method with a null receiver just return objc_null(res). *) let path = Paths.Path.add_description path path_description in - L.d_printfln "Object-C method %a called with nil receiver. Returning 0/nil" Typ.Procname.pp + L.d_printfln "Object-C method %a called with nil receiver. Returning 0/nil" Procname.pp callee_pname ; (* We wish to nullify the result. However, in some cases, we want to add the attribute OBJC_NULL to it so that we @@ -911,12 +911,12 @@ let add_struct_value_to_footprint tenv abduced_pv typ prop = let is_rec_call callee_pname caller_pdesc = (* TODO: (t7147096) extend this to detect mutual recursion *) - Typ.Procname.equal callee_pname (Procdesc.get_proc_name caller_pdesc) + Procname.equal callee_pname (Procdesc.get_proc_name caller_pdesc) let add_constraints_on_retval tenv pdesc prop ret_exp ~has_nonnull_annot typ callee_pname callee_loc = - if Typ.Procname.is_infer_undefined callee_pname then prop + if Procname.is_infer_undefined callee_pname then prop else let lookup_abduced_expression p abduced_ret_pv = List.find_map @@ -950,7 +950,7 @@ let add_constraints_on_retval tenv pdesc prop ret_exp ~has_nonnull_annot typ cal let prop_with_abduced_var = let abduced_ret_pv = (* in Java, always re-use the same abduced ret var to prevent false alarms with repeated method calls *) - let loc = if Typ.Procname.is_java callee_pname then Location.dummy else callee_loc in + let loc = if Procname.is_java callee_pname then Location.dummy else callee_loc in Pvar.mk_abduced_ret callee_pname loc in if !BiabductionConfig.footprint then @@ -1111,8 +1111,8 @@ let resolve_and_analyze_clang current_summary tenv prop_r n_actual_params callee if Config.dynamic_dispatch && (not (is_variadic_procname callee_pname)) - && Typ.Procname.is_objc_method callee_pname - || Typ.Procname.is_objc_block callee_pname + && Procname.is_objc_method callee_pname + || Procname.is_objc_block callee_pname (* to be extended to other methods *) then try @@ -1223,7 +1223,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t let skip_res () = let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in Reporting.log_issue_deprecated_using_state Exceptions.Info current_pname exn ; - L.d_printfln "Skipping function '%a': %s" Typ.Procname.pp callee_pname reason ; + L.d_printfln "Skipping function '%a': %s" Procname.pp callee_pname reason ; Tabulation.log_call_trace ~caller_name:current_pname ~callee_name:callee_pname ?callee_attributes ~reason loc Tabulation.CR_skip ; unknown_or_scan_call ~is_scan:false ~reason ret_typ ret_annots @@ -1291,7 +1291,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t | _ -> () in - if not (Typ.Procname.is_java current_pname) then + if not (Procname.is_java current_pname) then check_already_dereferenced tenv current_pname cond prop__ ; check_condition_always_true_false () ; let n_cond, prop = check_arith_norm_exp tenv current_pname cond prop__ in @@ -1316,7 +1316,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t let resolved_pname = resolve_and_analyze_result.resolved_pname in match resolve_and_analyze_result.resolved_summary_opt with | None -> - let ret_typ = Typ.Procname.Java.get_return_typ callee_pname_java in + let ret_typ = Procname.Java.get_return_typ callee_pname_java in let ret_annots = load_ret_annots callee_pname in exec_skip_call ~reason:"unknown method" resolved_pname ret_annots ret_typ | Some resolved_summary -> ( @@ -1342,7 +1342,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t in match Ondemand.analyze_proc_name ~caller_summary:current_summary pname with | None -> - let ret_typ = Typ.Procname.Java.get_return_typ callee_pname_java in + let ret_typ = Procname.Java.get_return_typ callee_pname_java in let ret_annots = load_ret_annots callee_pname in exec_skip_call ~reason:"unknown method" ret_annots ret_typ | Some callee_summary -> ( @@ -1384,8 +1384,8 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t let resolved_pdesc_opt = resolve_and_analyze_result.resolved_procdesc_opt in let resolved_summary_opt = resolve_and_analyze_result.resolved_summary_opt in let dynamic_dispatch_status = resolve_and_analyze_result.dynamic_dispatch_status in - Logging.d_printfln "Original callee %s" (Typ.Procname.to_unique_id callee_pname) ; - Logging.d_printfln "Resolved callee %s" (Typ.Procname.to_unique_id resolved_pname) ; + Logging.d_printfln "Original callee %s" (Procname.to_unique_id callee_pname) ; + Logging.d_printfln "Resolved callee %s" (Procname.to_unique_id resolved_pname) ; let sentinel_result = if Language.curr_language_is Clang then check_variadic_sentinel_if_present @@ -1420,14 +1420,14 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t || match Config.biabduction_model_alloc_pattern with | Some pat -> - Str.string_match pat (Typ.Procname.to_string resolved_pname) 0 + Str.string_match pat (Procname.to_string resolved_pname) 0 | None -> false in let model_as_free resolved_pname = match Config.biabduction_model_free_pattern with | Some pat -> - Str.string_match pat (Typ.Procname.to_string resolved_pname) 0 + Str.string_match pat (Procname.to_string resolved_pname) 0 | None -> false in @@ -1473,7 +1473,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t L.d_str "Unknown function pointer " ; Exp.d_exp fun_exp ; L.d_strln ", returning undefined value." ; - let callee_pname = Typ.Procname.from_string_c_fun "__function_pointer__" in + let callee_pname = Procname.from_string_c_fun "__function_pointer__" in unknown_or_scan_call ~is_scan:false ~reason:"unresolved function pointer" (snd ret_id_typ) Annot.Item.empty Builtin. @@ -1666,7 +1666,7 @@ and unknown_or_scan_call ~is_scan ~reason ret_typ ret_annots List.fold ~f:do_exp ~init:prop filtered_args in let should_abduce_param_value pname = - let open Typ.Procname in + let open Procname in match pname with | Java _ -> (* FIXME (T19882766): we need to disable this for Java because it breaks too many tests *) @@ -1675,9 +1675,9 @@ and unknown_or_scan_call ~is_scan ~reason ret_typ ret_annots (* FIXME: we need to work around a frontend hack for std::shared_ptr * to silent some of the uninitialization warnings *) if - String.is_suffix ~suffix:"_std__shared_ptr" (Typ.Procname.to_string callee_pname) + String.is_suffix ~suffix:"_std__shared_ptr" (Procname.to_string callee_pname) (* Abduced parameters for the empty destructor body cause `Cannot star` *) - || Typ.Procname.ObjC_Cpp.is_destructor cpp_name + || Procname.ObjC_Cpp.is_destructor cpp_name then false else true | _ -> @@ -1699,7 +1699,7 @@ and unknown_or_scan_call ~is_scan ~reason ret_typ ret_annots let pre_final = let pdesc = Summary.get_proc_desc summary in (* in Java, assume that skip functions close resources passed as params *) - let pre_1 = if Typ.Procname.is_java callee_pname then remove_file_attribute pre else pre in + let pre_1 = if Procname.is_java callee_pname then remove_file_attribute pre else pre in let pre_2 = (* TODO(jjb): Should this use the type of ret_id, or ret_type from the procedure type? *) add_constraints_on_retval tenv pdesc pre_1 @@ -1823,7 +1823,7 @@ and sym_exec_objc_accessor callee_pname property_accesor ret_typ tenv ret_id pde let path_description = F.sprintf "Executing synthesized %s %s" (ProcAttributes.kind_of_objc_accessor_type property_accesor) - (Typ.Procname.to_simplified_string callee_pname) + (Procname.to_simplified_string callee_pname) in let path = Paths.Path.add_description path path_description in f_accessor ret_typ tenv ret_id pdesc cur_pname loc args prop |> List.map ~f:(fun p -> (p, path)) @@ -1880,7 +1880,7 @@ and proc_call ?dynamic_dispatch exe_env callee_summary actual_pars | [], _ -> L.d_printfln "**** ERROR: Procedure %a mismatch in the number of parameters ****" - Typ.Procname.pp callee_pname ; + Procname.pp callee_pname ; L.d_str "actual parameters: " ; Exp.d_list (List.map ~f:fst actual_pars) ; L.d_ln () ; diff --git a/infer/src/biabduction/SymExec.mli b/infer/src/biabduction/SymExec.mli index a70b0e611..bc3ac1c5e 100644 --- a/infer/src/biabduction/SymExec.mli +++ b/infer/src/biabduction/SymExec.mli @@ -46,7 +46,7 @@ val unknown_or_scan_call : is_scan:bool -> reason:string -> Typ.t -> Annot.Item. val check_variadic_sentinel : ?fails_on_nil:bool -> int -> int * int -> Builtin.t val check_arith_norm_exp : - Tenv.t -> Typ.Procname.t -> Exp.t -> Prop.normal Prop.t -> Exp.t * Prop.normal Prop.t + Tenv.t -> Procname.t -> Exp.t -> Prop.normal Prop.t -> Exp.t * Prop.normal Prop.t (** Check for arithmetic problems and normalize an expression. *) val prune : Tenv.t -> positive:bool -> Exp.t -> Prop.normal Prop.t -> Propset.t diff --git a/infer/src/biabduction/SymExecBlocks.ml b/infer/src/biabduction/SymExecBlocks.ml index e56e66aa5..c1b37e07f 100644 --- a/infer/src/biabduction/SymExecBlocks.ml +++ b/infer/src/biabduction/SymExecBlocks.ml @@ -61,7 +61,7 @@ let resolve_method_with_block_args_and_analyze ~caller_summary pname act_params containing either a Closure or None. *) let block_args = List.map act_params ~f:(function - | Exp.Closure cl, _ when Typ.Procname.is_objc_block cl.name -> + | Exp.Closure cl, _ when Procname.is_objc_block cl.name -> Some cl | _ -> None ) @@ -71,11 +71,11 @@ let resolve_method_with_block_args_and_analyze ~caller_summary pname act_params let block_name_args = List.filter_map block_args ~f:(function | Some (cl : Exp.closure) -> - Some (Typ.Procname.block_name_of_procname cl.name) + Some (Procname.block_name_of_procname cl.name) | None -> None ) in - Typ.Procname.with_block_parameters pname block_name_args + Procname.with_block_parameters pname block_name_args in (* new procdesc cloned from the original one, where the block parameters have been replaced by the block arguments. The formals have also been expanded with the captured variables *) diff --git a/infer/src/biabduction/SymExecBlocks.mli b/infer/src/biabduction/SymExecBlocks.mli index 65c078928..ea4dfc38e 100644 --- a/infer/src/biabduction/SymExecBlocks.mli +++ b/infer/src/biabduction/SymExecBlocks.mli @@ -9,7 +9,7 @@ open! IStd val resolve_method_with_block_args_and_analyze : caller_summary:Summary.t - -> Typ.Procname.t + -> Procname.t -> (Exp.t * Typ.t) list -> (Summary.t * (Exp.t * Typ.t) list) option (** [resolve_method_with_block_args_and_analyze caller_pdesc pname args] create a copy of the method diff --git a/infer/src/biabduction/Tabulation.ml b/infer/src/biabduction/Tabulation.ml index 4b622f455..f82c74edc 100644 --- a/infer/src/biabduction/Tabulation.ml +++ b/infer/src/biabduction/Tabulation.ml @@ -46,7 +46,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 Typ.Procname.t * Location.t * PredSymb.path_pos + | Deref_undef of Procname.t * Location.t * PredSymb.path_pos (** dereference a value coming from the given undefined function *) | Deref_undef_exp (** dereference an undefined expression *) @@ -107,9 +107,9 @@ let log_call_trace ~caller_name ~callee_name ?callee_attributes ?reason ?dynamic ; call_result= string_of_call_result res ; callee_clang_method_kind ; callee_source_file - ; callee_name= Typ.Procname.to_string callee_name - ; caller_name= Typ.Procname.to_string caller_name - ; lang= Typ.Procname.get_language caller_name |> Language.to_explicit_string + ; callee_name= Procname.to_string callee_name + ; caller_name= Procname.to_string caller_name + ; lang= Procname.get_language caller_name |> Language.to_explicit_string ; reason ; dynamic_dispatch } in @@ -171,14 +171,14 @@ let spec_find_rename trace_call summary : trace_call CR_not_found ; raise (Exceptions.Precondition_not_found - (Localise.verbatim_desc (Typ.Procname.to_string proc_name), __POS__)) ) ; + (Localise.verbatim_desc (Procname.to_string proc_name), __POS__)) ) ; let formal_parameters = List.map ~f:(fun (x, _) -> Pvar.mk_callee x proc_name) formals in (List.map ~f:rename_vars specs, formal_parameters) with Caml.Not_found -> - L.d_printfln "ERROR: found no entry for procedure %a. Give up..." Typ.Procname.pp proc_name ; + L.d_printfln "ERROR: found no entry for procedure %a. Give up..." Procname.pp proc_name ; raise (Exceptions.Precondition_not_found - (Localise.verbatim_desc (Typ.Procname.to_string proc_name), __POS__)) + (Localise.verbatim_desc (Procname.to_string proc_name), __POS__)) (** Process a splitting coming straight from a call to the prover: @@ -1018,8 +1018,7 @@ let mk_posts tenv prop callee_pname posts = let last_call_ret_non_null = List.exists ~f:(function - | Predicates.Apred (Aretval (pname, _), [exp]) when Typ.Procname.equal callee_pname pname - -> + | Predicates.Apred (Aretval (pname, _), [exp]) when Procname.equal callee_pname pname -> Prover.check_disequal tenv prop exp Exp.zero | _ -> false ) @@ -1432,8 +1431,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 - | Typ.Procname.Java pn_java -> - List.is_empty (Typ.Procname.Java.get_parameters pn_java) + | Procname.Java pn_java -> + List.is_empty (Procname.Java.get_parameters pn_java) | _ -> false in @@ -1461,8 +1460,8 @@ let exe_function_call ?dynamic_dispatch exe_env callee_summary tenv ret_id calle in let spec_list, formal_params = spec_find_rename trace_call callee_summary in let nspecs = List.length spec_list in - L.d_printfln "Found %d specs for function %s" nspecs (Typ.Procname.to_unique_id callee_pname) ; - L.d_printfln "START EXECUTING SPECS FOR %s from state" (Typ.Procname.to_unique_id callee_pname) ; + L.d_printfln "Found %d specs for function %s" nspecs (Procname.to_unique_id callee_pname) ; + L.d_printfln "START EXECUTING SPECS FOR %s from state" (Procname.to_unique_id callee_pname) ; Prop.d_prop prop ; L.d_ln () ; let exe_one_spec (n, spec) = diff --git a/infer/src/biabduction/Tabulation.mli b/infer/src/biabduction/Tabulation.mli index 6fc01134e..17f400bd5 100644 --- a/infer/src/biabduction/Tabulation.mli +++ b/infer/src/biabduction/Tabulation.mli @@ -16,8 +16,8 @@ type call_result = | CR_skip (** the callee was skipped *) val log_call_trace : - caller_name:Typ.Procname.t - -> callee_name:Typ.Procname.t + caller_name:Procname.t + -> callee_name:Procname.t -> ?callee_attributes:ProcAttributes.t -> ?reason:string -> ?dynamic_dispatch:EventLogger.dynamic_dispatch @@ -40,13 +40,13 @@ val find_dereference_without_null_check_in_sexp : path position *) val create_cast_exception : - Tenv.t -> Logging.ocaml_pos -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn + Tenv.t -> Logging.ocaml_pos -> Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn (** raise a cast exception *) -val prop_is_exn : Typ.Procname.t -> 'a Prop.t -> bool +val prop_is_exn : Procname.t -> 'a Prop.t -> bool (** check if a prop is an exception *) -val prop_get_exn_name : Typ.Procname.t -> 'a Prop.t -> Typ.Name.t option +val prop_get_exn_name : Procname.t -> 'a Prop.t -> Typ.Name.t option (** when prop is an exception, return the exception name *) val lookup_custom_errors : 'a Prop.t -> string option @@ -59,7 +59,7 @@ val exe_function_call : -> Tenv.t -> Ident.t -> Procdesc.t - -> Typ.Procname.t + -> Procname.t -> Location.t -> (Exp.t * Typ.t) list -> Prop.normal Prop.t diff --git a/infer/src/biabduction/interproc.ml b/infer/src/biabduction/interproc.ml index 26cf78db3..9eb36d5a7 100644 --- a/infer/src/biabduction/interproc.ml +++ b/infer/src/biabduction/interproc.ml @@ -209,7 +209,7 @@ let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t let f p = Prop.prop_normal_vars_to_primed_vars tenv p in Propset.map tenv f pset in - L.d_printfln "#### Extracted footprint of %a: ####" Typ.Procname.pp proc_name ; + L.d_printfln "#### Extracted footprint of %a: ####" Procname.pp proc_name ; L.d_increase_indent () ; Propset.d Prop.prop_emp pset' ; L.d_decrease_indent () ; @@ -217,7 +217,7 @@ let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t 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_printfln "#### Footprint of %a after Meet ####" Typ.Procname.pp proc_name ; + L.d_printfln "#### Footprint of %a after Meet ####" Procname.pp proc_name ; L.d_increase_indent () ; Propgraph.d_proplist Prop.prop_emp plist_meet ; L.d_decrease_indent () ; @@ -228,7 +228,7 @@ let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t let jplist = do_join_pre tenv plist_meet in L.d_decrease_indent () ; L.d_ln () ; - L.d_printfln "#### Footprint of %a after Join ####" Typ.Procname.pp proc_name ; + L.d_printfln "#### Footprint of %a after Join ####" Procname.pp proc_name ; L.d_increase_indent () ; BiabductionSummary.Jprop.d_list ~shallow:false jplist ; L.d_decrease_indent () ; @@ -236,7 +236,7 @@ let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t let jplist' = List.map ~f:(BiabductionSummary.Jprop.map (Prop.prop_rename_primed_footprint_vars tenv)) jplist in - L.d_printfln "#### Renamed footprint of %a: ####" Typ.Procname.pp proc_name ; + L.d_printfln "#### Renamed footprint of %a: ####" Procname.pp proc_name ; L.d_increase_indent () ; BiabductionSummary.Jprop.d_list ~shallow:false jplist' ; L.d_decrease_indent () ; @@ -247,7 +247,7 @@ let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t in List.map ~f:(BiabductionSummary.Jprop.map f) jplist' in - L.d_printfln "#### Abstracted footprint of %a: ####" Typ.Procname.pp proc_name ; + L.d_printfln "#### Abstracted footprint of %a: ####" Procname.pp proc_name ; L.d_increase_indent () ; BiabductionSummary.Jprop.d_list ~shallow:false jplist'' ; L.d_decrease_indent () ; @@ -435,10 +435,10 @@ let forward_tabulate summary exe_env tenv proc_cfg wl = in let status = Summary.get_status summary in F.sprintf "[%s:%s] %s" phase_string (Summary.Status.to_string status) - (Typ.Procname.to_string proc_name) + (Procname.to_string proc_name) in L.d_printfln "**** %s Node: %a, Procedure: %a, Session: %d, Todo: %d ****" (log_string pname) - Procdesc.Node.pp curr_node Typ.Procname.pp pname session (Paths.PathSet.size pathset_todo) ; + Procdesc.Node.pp curr_node Procname.pp pname session (Paths.PathSet.size pathset_todo) ; L.d_increase_indent () ; Propset.d Prop.prop_emp (Paths.PathSet.to_propset tenv pathset_todo) ; L.d_strln ".... Instructions: ...." ; @@ -615,8 +615,8 @@ let collect_postconditions wl tenv proc_cfg : Paths.PathSet.t * BiabductionSumma (* Assuming C++ developers use RAII, remove resources from the constructor posts *) let pathset = match pname with - | Typ.Procname.ObjC_Cpp _ -> - if Typ.Procname.is_constructor pname then + | Procname.ObjC_Cpp _ -> + if Procname.is_constructor pname then Paths.PathSet.map (fun prop -> Attribute.remove_resource tenv Racquire (Rmemory Mobjc) @@ -627,7 +627,7 @@ let collect_postconditions wl tenv proc_cfg : Paths.PathSet.t * BiabductionSumma | _ -> pathset in - L.d_printfln "#### [FUNCTION %a] Analysis result ####" Typ.Procname.pp pname ; + L.d_printfln "#### [FUNCTION %a] Analysis result ####" Procname.pp pname ; Propset.d Prop.prop_emp (Paths.PathSet.to_propset tenv pathset) ; L.d_ln () ; let res = @@ -645,7 +645,7 @@ let collect_postconditions wl tenv proc_cfg : Paths.PathSet.t * BiabductionSumma L.d_strln "Leak in post collection" ; assert false in - L.d_printfln "#### [FUNCTION %a] Postconditions after join ####" Typ.Procname.pp pname ; + L.d_printfln "#### [FUNCTION %a] Postconditions after join ####" Procname.pp pname ; L.d_increase_indent () ; Propset.d Prop.prop_emp (Paths.PathSet.to_propset tenv (fst res)) ; L.d_decrease_indent () ; @@ -734,7 +734,7 @@ let execute_filter_prop summary exe_env tenv proc_cfg let pdesc = ProcCfg.Exceptional.proc_desc proc_cfg in let pname = Procdesc.get_proc_name pdesc in do_before_node 0 init_node ; - L.d_printfln "#### Start: RE-execution for %a ####" Typ.Procname.pp pname ; + L.d_printfln "#### Start: RE-execution for %a ####" Procname.pp pname ; L.d_indent 1 ; L.d_strln "Precond:" ; BiabductionSummary.Jprop.d_shallow precondition ; @@ -752,7 +752,7 @@ let execute_filter_prop summary exe_env tenv proc_cfg ignore (path_set_put_todo wl init_node init_edgeset) ; forward_tabulate summary exe_env tenv proc_cfg wl ; do_before_node 0 init_node ; - L.d_printfln ~color:Green "#### Finished: RE-execution for %a ####" Typ.Procname.pp pname ; + L.d_printfln ~color:Green "#### Finished: RE-execution for %a ####" Procname.pp pname ; L.d_increase_indent () ; L.d_strln "Precond:" ; Prop.d_prop (BiabductionSummary.Jprop.to_prop precondition) ; @@ -774,7 +774,7 @@ let execute_filter_prop summary exe_env tenv proc_cfg with RE_EXE_ERROR -> do_before_node 0 init_node ; Printer.force_delayed_prints () ; - L.d_printfln ~color:Red "#### [FUNCTION %a] ...ERROR" Typ.Procname.pp pname ; + L.d_printfln ~color:Red "#### [FUNCTION %a] ...ERROR" Procname.pp pname ; L.d_increase_indent () ; L.d_strln "when starting from pre:" ; Prop.d_prop (BiabductionSummary.Jprop.to_prop precondition) ; @@ -865,7 +865,7 @@ let perform_analysis_phase exe_env tenv (summary : Summary.t) (proc_cfg : ProcCf let source = (Procdesc.get_loc (ProcCfg.Exceptional.proc_desc proc_cfg)).file in let filename = DB.Results_dir.path_to_filename (DB.Results_dir.Abs_source_dir source) - [Typ.Procname.to_filename pname] + [Procname.to_filename pname] in if Config.write_dotty then DotBiabduction.emit_specs_to_file filename specs ; (specs, BiabductionSummary.RE_EXECUTION) @@ -880,7 +880,7 @@ let perform_analysis_phase exe_env tenv (summary : Summary.t) (proc_cfg : ProcCf let set_current_language proc_desc = - let language = Typ.Procname.get_language (Procdesc.get_proc_name proc_desc) in + let language = Procname.get_language (Procdesc.get_proc_name proc_desc) in Language.curr_language := language @@ -1123,8 +1123,7 @@ let perform_transition proc_cfg tenv proc_name summary = with exn when SymOp.exn_not_failure exn -> apply_start_node do_after_node ; BiabductionConfig.allow_leak := allow_leak ; - L.(debug Analysis Medium) - "Error in collect_preconditions for %a@." Typ.Procname.pp proc_name ; + L.(debug Analysis Medium) "Error in collect_preconditions for %a@." Procname.pp proc_name ; let error = Exceptions.recognize_exception exn in let err_str = "exception raised " ^ error.name.IssueType.unique_id in L.(debug Analysis Medium) "Error: %s %a@." err_str L.pp_ocaml_pos_opt error.ocaml_pos ; diff --git a/infer/src/bufferoverrun/absLoc.ml b/infer/src/bufferoverrun/absLoc.ml index 5be95437c..407d1cfba 100644 --- a/infer/src/bufferoverrun/absLoc.ml +++ b/infer/src/bufferoverrun/absLoc.ml @@ -66,7 +66,7 @@ module Allocsite = struct let is_unknown = function Unknown -> true | Symbol _ | Known _ | LiteralString _ -> false let make : - Typ.Procname.t + Procname.t -> node_hash:int -> inst_num:int -> dimension:int @@ -75,7 +75,7 @@ module Allocsite = struct -> t = fun proc_name ~node_hash ~inst_num ~dimension ~path ~represents_multiple_values -> Known - { proc_name= Typ.Procname.to_string proc_name + { proc_name= Procname.to_string proc_name ; node_hash ; inst_num ; dimension diff --git a/infer/src/bufferoverrun/absLoc.mli b/infer/src/bufferoverrun/absLoc.mli index 3c5464d08..dee392bc8 100644 --- a/infer/src/bufferoverrun/absLoc.mli +++ b/infer/src/bufferoverrun/absLoc.mli @@ -25,7 +25,7 @@ module Allocsite : sig val unknown : t val make : - Typ.Procname.t + Procname.t -> node_hash:int -> inst_num:int -> dimension:int diff --git a/infer/src/bufferoverrun/bounds.ml b/infer/src/bufferoverrun/bounds.ml index 658c57b3e..5c044957f 100644 --- a/infer/src/bufferoverrun/bounds.ml +++ b/infer/src/bufferoverrun/bounds.ml @@ -1236,7 +1236,7 @@ type ('c, 's, 't) valclass = Constant of 'c | Symbolic of 's | ValTop of 't module BoundTrace = struct type t = | Loop of Location.t - | Call of {callee_pname: Typ.Procname.t; callee_trace: t; location: Location.t} + | Call of {callee_pname: Procname.t; callee_trace: t; location: Location.t} | ModeledFunction of {pname: string; location: Location.t} [@@deriving compare] @@ -1257,7 +1257,7 @@ module BoundTrace = struct | ModeledFunction {pname; location} -> F.fprintf f "ModeledFunction `%s` (%a)" pname Location.pp location | Call {callee_pname; callee_trace; location} -> - F.fprintf f "%a -> Call `%a` (%a)" pp callee_trace Typ.Procname.pp callee_pname Location.pp + F.fprintf f "%a -> Call `%a` (%a)" pp callee_trace Procname.pp callee_pname Location.pp location @@ -1269,7 +1269,7 @@ module BoundTrace = struct let desc = F.asprintf "Loop at %a" Location.pp loop_head_loc in [Errlog.make_trace_element depth loop_head_loc desc []] | Call {callee_pname; location; callee_trace} -> - let desc = F.asprintf "call to %a" Typ.Procname.pp callee_pname in + let desc = F.asprintf "call to %a" Procname.pp callee_pname in Errlog.make_trace_element depth location desc [] :: make_err_trace ~depth:(depth + 1) callee_trace | ModeledFunction {pname; location} -> diff --git a/infer/src/bufferoverrun/bounds.mli b/infer/src/bufferoverrun/bounds.mli index 5a8c68e7c..92f40e348 100644 --- a/infer/src/bufferoverrun/bounds.mli +++ b/infer/src/bufferoverrun/bounds.mli @@ -177,7 +177,7 @@ module NonNegativeBound : sig val classify : t -> (Ints.NonNegativeInt.t, t, BoundTrace.t) valclass val subst : - Typ.Procname.t + Procname.t -> Location.t -> t -> Bound.eval_sym diff --git a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml index 88ae67d8b..78481fa25 100644 --- a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml +++ b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml @@ -27,7 +27,7 @@ end) type summary_and_formals = BufferOverrunAnalysisSummary.t * (Pvar.t * Typ.t) list -type get_proc_summary_and_formals = Typ.Procname.t -> summary_and_formals option +type get_proc_summary_and_formals = Procname.t -> summary_and_formals option type extras = {get_proc_summary_and_formals: get_proc_summary_and_formals; oenv: OndemandEnv.t} @@ -140,17 +140,13 @@ module TransferFunctions = struct let is_external pname = - match pname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_external java_pname - | _ -> - false + match pname with Procname.Java java_pname -> Procname.Java.is_external java_pname | _ -> false let is_non_static pname = match pname with - | Typ.Procname.Java java_pname -> - not (Typ.Procname.Java.is_static java_pname) + | Procname.Java java_pname -> + not (Procname.Java.is_static java_pname) | _ -> false @@ -159,7 +155,7 @@ module TransferFunctions = struct Typ.IntegerWidths.t -> Ident.t * Typ.t -> (Pvar.t * Typ.t) list - -> Typ.Procname.t + -> Procname.t -> (Exp.t * Typ.t) list -> Dom.Mem.t -> BufferOverrunAnalysisSummary.t @@ -186,18 +182,18 @@ module TransferFunctions = struct let is_java_enum_values ~caller_pname ~callee_pname = match - (Typ.Procname.get_class_type_name caller_pname, Typ.Procname.get_class_type_name callee_pname) + (Procname.get_class_type_name caller_pname, Procname.get_class_type_name callee_pname) with | Some caller_class_name, Some callee_class_name when Typ.equal_name caller_class_name callee_class_name -> - Typ.Procname.is_java_class_initializer caller_pname - && String.equal (Typ.Procname.get_method callee_pname) "values" + Procname.is_java_class_initializer caller_pname + && String.equal (Procname.get_method callee_pname) "values" | _, _ -> false let assign_java_enum_values id callee_pname mem = - match Typ.Procname.get_class_type_name callee_pname with + match Procname.get_class_type_name callee_pname with | Some (JavaClass class_name as typename) -> let class_var = Loc.of_var (Var.of_pvar (Pvar.mk_global class_name)) in let fn = Fieldname.make typename "$VALUES" in @@ -379,14 +375,14 @@ module TransferFunctions = struct callee_exit_mem location | None -> (* This may happen for procedures with a biabduction model too. *) - L.d_printfln_escaped "/!\\ Unknown call to %a" Typ.Procname.pp callee_pname ; + L.d_printfln_escaped "/!\\ Unknown call to %a" Procname.pp callee_pname ; if is_external callee_pname then ( L.(debug BufferOverrun Verbose) - "/!\\ External call to unknown %a \n\n" Typ.Procname.pp callee_pname ; + "/!\\ External call to unknown %a \n\n" Procname.pp callee_pname ; assign_symbolic_pname_value callee_pname ret location mem ) else if is_non_static callee_pname then ( L.(debug BufferOverrun Verbose) - "/!\\ Non-static call to unknown %a \n\n" Typ.Procname.pp callee_pname ; + "/!\\ Non-static call to unknown %a \n\n" Procname.pp callee_pname ; assign_symbolic_pname_value callee_pname ret location mem ) else Dom.Mem.add_unknown_from id ~callee_pname ~location mem ) ) | Call ((id, _), fun_exp, _, location, _) -> @@ -438,9 +434,9 @@ let compute_invariant_map : let cached_compute_invariant_map = (* Use a weak Hashtbl to prevent memory leaks (GC unnecessarily keeps invariant maps around) *) let module WeakInvMapHashTbl = Caml.Weak.Make (struct - type t = Typ.Procname.t * invariant_map option + type t = Procname.t * invariant_map option - let equal (pname1, _) (pname2, _) = Typ.Procname.equal pname1 pname2 + let equal (pname1, _) (pname2, _) = Procname.equal pname1 pname2 let hash (pname, _) = Hashtbl.hash pname end) in diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index 703689477..ab1adc4d1 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -111,7 +111,7 @@ let add_unreachable_code (cfg : CFG.t) (node : CFG.Node.t) instr rem_instrs (che {checks with unused_branches= unused_branch :: checks.unused_branches} (* special case for `exit` when we're at the end of a block / procedure *) | Sil.Call (_, Const (Cfun pname), _, _, _) - when String.equal (Typ.Procname.get_method pname) "exit" + when String.equal (Procname.get_method pname) "exit" && ExitStatement.is_end_of_block_or_procedure cfg node rem_instrs -> checks | _ -> @@ -235,7 +235,7 @@ let rec check_expr_for_integer_overflow integer_type_widths exp location mem con let instantiate_cond : Typ.IntegerWidths.t - -> Typ.Procname.t + -> Procname.t -> (Pvar.t * Typ.t) list -> (Exp.t * Typ.t) list -> Dom.Mem.t @@ -250,7 +250,7 @@ let instantiate_cond : type checks_summary = BufferOverrunCheckerSummary.t -type get_proc_summary = Typ.Procname.t -> ((Pvar.t * Typ.t) list * checks_summary) option +type get_proc_summary = Procname.t -> ((Pvar.t * Typ.t) list * checks_summary) option let check_instr : get_proc_summary diff --git a/infer/src/bufferoverrun/bufferOverrunDomain.ml b/infer/src/bufferoverrun/bufferOverrunDomain.ml index 07eece71b..601491437 100644 --- a/infer/src/bufferoverrun/bufferOverrunDomain.ml +++ b/infer/src/bufferoverrun/bufferOverrunDomain.ml @@ -79,7 +79,7 @@ module ModeledRange = struct end) let of_modeled_function pname location bound = - let pname = Typ.Procname.to_simplified_string pname in + let pname = Procname.to_simplified_string pname in NonBottom (Bounds.NonNegativeBound.of_modeled_function pname location bound) @@ -1902,8 +1902,8 @@ module MemReach = struct PowLoc.fold (fun l acc -> add_heap ?represents_multiple_values l v acc) locs m - let add_unknown_from : - Ident.t -> callee_pname:Typ.Procname.t option -> location:Location.t -> t -> t = + let add_unknown_from : Ident.t -> callee_pname:Procname.t option -> location:Location.t -> t -> t + = fun id ~callee_pname ~location m -> let val_unknown = Val.unknown_from ~callee_pname ~location in add_stack (Loc.of_id id) val_unknown m |> add_heap Loc.unknown val_unknown @@ -2266,7 +2266,7 @@ module Mem = struct map ~f:(MemReach.add_heap_set ?represents_multiple_values ploc v) - let add_unknown_from : Ident.t -> callee_pname:Typ.Procname.t -> location:Location.t -> t -> t = + let add_unknown_from : Ident.t -> callee_pname:Procname.t -> location:Location.t -> t -> t = fun id ~callee_pname ~location -> map ~f:(MemReach.add_unknown_from id ~callee_pname:(Some callee_pname) ~location) diff --git a/infer/src/bufferoverrun/bufferOverrunDomain.mli b/infer/src/bufferoverrun/bufferOverrunDomain.mli index 1800de989..e4bb3d775 100644 --- a/infer/src/bufferoverrun/bufferOverrunDomain.mli +++ b/infer/src/bufferoverrun/bufferOverrunDomain.mli @@ -36,7 +36,7 @@ module ModeledRange : sig val of_big_int : trace:Bounds.BoundTrace.t -> Z.t -> t - val of_modeled_function : Typ.Procname.t -> Location.t -> Bounds.Bound.t -> t + val of_modeled_function : Procname.t -> Location.t -> Bounds.Bound.t -> t end module Val : sig @@ -83,7 +83,7 @@ module Val : sig val unknown_locs : t - val unknown_from : callee_pname:Typ.Procname.t option -> location:Location.t -> t + val unknown_from : callee_pname:Procname.t option -> location:Location.t -> t (** Unknown return value of [callee_pname] *) val is_mone : t -> bool @@ -495,7 +495,7 @@ module Mem : sig val add_unknown : Ident.t -> location:Location.t -> t -> t (** Add an unknown value for stack variables *) - val add_unknown_from : Ident.t -> callee_pname:Typ.Procname.t -> location:Location.t -> t -> t + val add_unknown_from : Ident.t -> callee_pname:Procname.t -> location:Location.t -> t -> t (** Add an unknown return value of [callee_pname] for stack variables *) val remove_temps : Ident.t list -> t -> t diff --git a/infer/src/bufferoverrun/bufferOverrunModels.ml b/infer/src/bufferoverrun/bufferOverrunModels.ml index bfbab64ab..57be1d243 100644 --- a/infer/src/bufferoverrun/bufferOverrunModels.ml +++ b/infer/src/bufferoverrun/bufferOverrunModels.ml @@ -27,7 +27,7 @@ let no_check _model_env _mem cond_set = cond_set let no_model = let exec {pname; location} ~ret:(id, _) mem = - L.d_printfln_escaped "No model for %a" Typ.Procname.pp pname ; + L.d_printfln_escaped "No model for %a" Procname.pp pname ; Dom.Mem.add_unknown_from id ~callee_pname:pname ~location mem in {exec; check= no_check} diff --git a/infer/src/bufferoverrun/bufferOverrunProofObligations.ml b/infer/src/bufferoverrun/bufferOverrunProofObligations.ml index f821f0844..e1ff1ba06 100644 --- a/infer/src/bufferoverrun/bufferOverrunProofObligations.ml +++ b/infer/src/bufferoverrun/bufferOverrunProofObligations.ml @@ -17,7 +17,7 @@ module Sem = BufferOverrunSemantics module ValTrace = BufferOverrunTrace module ConditionTrace = struct - type intra_cond_trace = Intra | Inter of {call_site: Location.t; callee_pname: Typ.Procname.t} + type intra_cond_trace = Intra | Inter of {call_site: Location.t; callee_pname: Procname.t} [@@deriving compare] type 'cond_trace t0 = @@ -38,7 +38,7 @@ module ConditionTrace = struct if Config.bo_debug > 1 then match ct.cond_trace with | Inter {callee_pname; call_site} -> - let pname = Typ.Procname.to_string callee_pname in + let pname = Procname.to_string callee_pname in F.fprintf fmt " by call to %s at %a (%a)" pname Location.pp_file_pos call_site ValTrace.Issue.pp ct.val_traces | Intra -> @@ -49,7 +49,7 @@ module ConditionTrace = struct fun fmt ct -> match ct.cond_trace with | Inter {callee_pname} -> - F.fprintf fmt " by call to %a " MF.pp_monospaced (Typ.Procname.to_string callee_pname) + F.fprintf fmt " by call to %a " MF.pp_monospaced (Procname.to_string callee_pname) | _ -> () @@ -717,7 +717,7 @@ module ConditionWithTrace = struct L.(die InternalError) "Trying to substitute a non-symbolic condition %a from %a at %a. Why was it propagated in \ the first place?" - pp_summary cwt Typ.Procname.pp callee_pname Location.pp call_site ; + pp_summary cwt Procname.pp callee_pname Location.pp call_site ; match Dom.Reachability.subst cwt.reachability (eval_sym_trace ~mode:Sem.EvalPOReachability) diff --git a/infer/src/bufferoverrun/bufferOverrunProofObligations.mli b/infer/src/bufferoverrun/bufferOverrunProofObligations.mli index ba6cbce8f..5324b533f 100644 --- a/infer/src/bufferoverrun/bufferOverrunProofObligations.mli +++ b/infer/src/bufferoverrun/bufferOverrunProofObligations.mli @@ -70,7 +70,7 @@ module ConditionSet : sig val subst : summary_t -> (mode:BufferOverrunSemantics.eval_mode -> BufferOverrunDomain.eval_sym_trace) - -> Typ.Procname.t + -> Procname.t -> Location.t -> BufferOverrunDomain.LatestPrune.t -> checked_t diff --git a/infer/src/bufferoverrun/bufferOverrunSemantics.ml b/infer/src/bufferoverrun/bufferOverrunSemantics.ml index 55547937c..b2d605398 100644 --- a/infer/src/bufferoverrun/bufferOverrunSemantics.ml +++ b/infer/src/bufferoverrun/bufferOverrunSemantics.ml @@ -395,7 +395,7 @@ let rec eval_sympath_partial ~mode params p mem = | Symb.SymbolPath.Callsite {cs} -> ( match mode with | EvalNormal | EvalCost -> - L.d_printfln_escaped "Symbol for %a is not expected to be in parameters." Typ.Procname.pp + L.d_printfln_escaped "Symbol for %a is not expected to be in parameters." Procname.pp (CallSite.pname cs) ; Mem.find (Loc.of_allocsite (Allocsite.make_symbol p)) mem | EvalPOCond | EvalPOReachability -> diff --git a/infer/src/bufferoverrun/bufferOverrunTrace.ml b/infer/src/bufferoverrun/bufferOverrunTrace.ml index 81888b824..b00c1811d 100644 --- a/infer/src/bufferoverrun/bufferOverrunTrace.ml +++ b/infer/src/bufferoverrun/bufferOverrunTrace.ml @@ -12,7 +12,7 @@ module F = Format module BoTrace = struct type lib_fun = Snprintf | Strndup | Vsnprintf [@@deriving compare] - type final = UnknownFrom of Typ.Procname.t option [@@deriving compare] + type final = UnknownFrom of Procname.t option [@@deriving compare] type elem = | ArrayDeclaration @@ -56,7 +56,7 @@ module BoTrace = struct | None -> F.fprintf fmt "non-const function" | Some pname -> - Typ.Procname.pp fmt pname + Procname.pp fmt pname let pp_location = Location.pp_file_pos diff --git a/infer/src/bufferoverrun/bufferOverrunTrace.mli b/infer/src/bufferoverrun/bufferOverrunTrace.mli index 5e0d9041c..2f41ddc63 100644 --- a/infer/src/bufferoverrun/bufferOverrunTrace.mli +++ b/infer/src/bufferoverrun/bufferOverrunTrace.mli @@ -17,7 +17,7 @@ val strndup : lib_fun val vsnprintf : lib_fun (** Final unknown function in trace *) -type final = UnknownFrom of Typ.Procname.t option +type final = UnknownFrom of Procname.t option (** Trace elements *) type elem = diff --git a/infer/src/bufferoverrun/bufferOverrunUtils.ml b/infer/src/bufferoverrun/bufferOverrunUtils.ml index 04f47b009..c2b093af5 100644 --- a/infer/src/bufferoverrun/bufferOverrunUtils.ml +++ b/infer/src/bufferoverrun/bufferOverrunUtils.ml @@ -18,7 +18,7 @@ module TypModels = BufferOverrunTypModels module ModelEnv = struct type model_env = - { pname: Typ.Procname.t + { pname: Procname.t ; node_hash: int ; location: Location.t ; tenv: Tenv.t @@ -78,7 +78,7 @@ module Exec = struct let mem = let arr = let traces = Trace.(Set.singleton location ArrayDeclaration) in - match Typ.Procname.get_language pname with + match Procname.get_language pname with | Language.Clang -> let offset = Itv.zero in Dom.Val.of_c_array_alloc allocsite ~stride ~offset ~size ~traces diff --git a/infer/src/bufferoverrun/bufferOverrunUtils.mli b/infer/src/bufferoverrun/bufferOverrunUtils.mli index 4dbce6ec7..1eb2a4404 100644 --- a/infer/src/bufferoverrun/bufferOverrunUtils.mli +++ b/infer/src/bufferoverrun/bufferOverrunUtils.mli @@ -12,14 +12,14 @@ module PO = BufferOverrunProofObligations module ModelEnv : sig type model_env = - { pname: Typ.Procname.t + { pname: Procname.t ; node_hash: int ; location: Location.t ; tenv: Tenv.t ; integer_type_widths: Typ.IntegerWidths.t } val mk_model_env : - Typ.Procname.t -> node_hash:int -> Location.t -> Tenv.t -> Typ.IntegerWidths.t -> model_env + Procname.t -> node_hash:int -> Location.t -> Tenv.t -> Typ.IntegerWidths.t -> model_env end module Exec : sig diff --git a/infer/src/bufferoverrun/polynomials.ml b/infer/src/bufferoverrun/polynomials.ml index aa1919247..21e642244 100644 --- a/infer/src/bufferoverrun/polynomials.ml +++ b/infer/src/bufferoverrun/polynomials.ml @@ -67,7 +67,7 @@ module type NonNegativeSymbol = sig val mask_min_max_constant : t -> t val subst : - Typ.Procname.t + Procname.t -> Location.t -> t -> Bound.eval_sym @@ -454,7 +454,7 @@ module TopTrace = struct type t = | UnboundedLoop of {bound_trace: Bounds.BoundTrace.t} | UnboundedSymbol of {location: Location.t; symbol: S.t; bound_trace: Bounds.BoundTrace.t} - | Call of {location: Location.t; callee_pname: Typ.Procname.t; callee_trace: t} + | Call of {location: Location.t; callee_pname: Procname.t; callee_trace: t} [@@deriving compare] let rec length = function @@ -481,7 +481,7 @@ module TopTrace = struct F.fprintf f "%a -> UnboundedSymbol (%a): %a" Bounds.BoundTrace.pp bound_trace Location.pp location (S.pp ~hum:false) symbol | Call {callee_pname; callee_trace; location} -> - F.fprintf f "%a -> Call `%a` (%a)" pp callee_trace Typ.Procname.pp callee_pname Location.pp + F.fprintf f "%a -> Call `%a` (%a)" pp callee_trace Procname.pp callee_pname Location.pp location @@ -495,7 +495,7 @@ module TopTrace = struct Errlog.make_trace_element depth location desc [] :: Bounds.BoundTrace.make_err_trace ~depth bound_trace | Call {location; callee_pname; callee_trace} -> - let desc = F.asprintf "Call to %a" Typ.Procname.pp callee_pname in + let desc = F.asprintf "Call to %a" Procname.pp callee_pname in Errlog.make_trace_element depth location desc [] :: make_err_trace ~depth:(depth + 1) callee_trace end diff --git a/infer/src/bufferoverrun/polynomials.mli b/infer/src/bufferoverrun/polynomials.mli index 3f96fa6e8..c4d92a588 100644 --- a/infer/src/bufferoverrun/polynomials.mli +++ b/infer/src/bufferoverrun/polynomials.mli @@ -67,7 +67,7 @@ module NonNegativePolynomial : sig val min_default_left : t -> t -> t - val subst : Typ.Procname.t -> Location.t -> t -> Bound.eval_sym -> t + val subst : Procname.t -> Location.t -> t -> Bound.eval_sym -> t val degree : t -> Degree.t option diff --git a/infer/src/bufferoverrun/symb.ml b/infer/src/bufferoverrun/symb.ml index 278c0ffd1..23d410900 100644 --- a/infer/src/bufferoverrun/symb.ml +++ b/infer/src/bufferoverrun/symb.ml @@ -136,7 +136,7 @@ module SymbolPath = struct | Field {fn; prefix= p} -> BufferOverrunField.pp ~pp_lhs:(pp_partial_paren ~paren:true) ~sep:"." fmt p fn | Callsite {cs} -> - Typ.Procname.pp_simplified_string ~withclass:true fmt (CallSite.pname cs) + Procname.pp_simplified_string ~withclass:true fmt (CallSite.pname cs) | StarField {last_field; prefix} -> BufferOverrunField.pp ~pp_lhs:(pp_star ~paren:true) ~sep:"." fmt prefix last_field diff --git a/infer/src/checkers/LithoDomain.ml b/infer/src/checkers/LithoDomain.ml index b31f77fe1..fe528a83e 100644 --- a/infer/src/checkers/LithoDomain.ml +++ b/infer/src/checkers/LithoDomain.ml @@ -9,7 +9,7 @@ open! IStd module F = Format module LocalAccessPath = struct - type t = {access_path: AccessPath.t; parent: Typ.Procname.t} [@@deriving compare] + type t = {access_path: AccessPath.t; parent: Procname.t} [@@deriving compare] let make access_path parent = {access_path; parent} @@ -28,13 +28,11 @@ let suffixes = String.Set.of_list ["Attr"; "Dip"; "Px"; "Res"; "Sp"] module MethodCallPrefix = struct type t = - { prefix: string - ; procname: Typ.Procname.t [@compare.ignore] - ; location: Location.t [@compare.ignore] } + {prefix: string; procname: Procname.t [@compare.ignore]; location: Location.t [@compare.ignore]} [@@deriving compare] let make procname location = - let method_name = Typ.Procname.get_method procname in + let method_name = Procname.get_method procname in let prefix_opt = String.Set.find_map suffixes ~f:(fun suffix -> String.chop_suffix method_name ~suffix) in @@ -42,9 +40,9 @@ module MethodCallPrefix = struct {prefix; procname; location} - let pp fmt {procname} = Typ.Procname.pp fmt procname + let pp fmt {procname} = Procname.pp fmt procname - let procname_to_string {procname} = Typ.Procname.get_method procname + let procname_to_string {procname} = Procname.get_method procname end module CreatedLocation = struct diff --git a/infer/src/checkers/LithoDomain.mli b/infer/src/checkers/LithoDomain.mli index c5a36ecd3..59ae202f0 100644 --- a/infer/src/checkers/LithoDomain.mli +++ b/infer/src/checkers/LithoDomain.mli @@ -9,20 +9,20 @@ open! IStd (** Access path + its parent procedure *) module LocalAccessPath : sig - type t = private {access_path: AccessPath.t; parent: Typ.Procname.t} [@@deriving compare] + type t = private {access_path: AccessPath.t; parent: Procname.t} [@@deriving compare] - val make : AccessPath.t -> Typ.Procname.t -> t + val make : AccessPath.t -> Procname.t -> t - val make_from_access_expression : HilExp.AccessExpression.t -> Typ.Procname.t -> t + val make_from_access_expression : HilExp.AccessExpression.t -> Procname.t -> t end val suffixes : String.Set.t (** Called procedure & location *) module MethodCallPrefix : sig - type t = private {prefix: string; procname: Typ.Procname.t; location: Location.t} + type t = private {prefix: string; procname: Procname.t; location: Location.t} - val make : Typ.Procname.t -> Location.t -> t + val make : Procname.t -> Location.t -> t end module Mem : sig @@ -38,8 +38,8 @@ val subst : -> formals:(Pvar.t * Typ.t) list -> actuals:HilExp.t list -> ret_id_typ:AccessPath.base - -> caller_pname:Typ.Procname.t - -> callee_pname:Typ.Procname.t + -> caller_pname:Procname.t + -> callee_pname:Procname.t -> caller:t -> callee:Mem.t -> t @@ -47,7 +47,7 @@ val subst : (** type for saving in summary payload *) type summary = Mem.t -val init : Tenv.t -> Typ.Procname.t -> (Pvar.t * Typ.t) list -> t +val init : Tenv.t -> Procname.t -> (Pvar.t * Typ.t) list -> t val assign : lhs:LocalAccessPath.t -> rhs:LocalAccessPath.t -> t -> t diff --git a/infer/src/checkers/NullabilityPreanalysis.ml b/infer/src/checkers/NullabilityPreanalysis.ml index 9c7231e2d..113c3e292 100644 --- a/infer/src/checkers/NullabilityPreanalysis.ml +++ b/infer/src/checkers/NullabilityPreanalysis.ml @@ -94,7 +94,7 @@ let add_nonnull_to_fields fields tenv = let analysis cfg tenv = let initial = FieldsAssignedInConstructors.empty in let f proc_name pdesc domain = - if Procdesc.is_defined pdesc && Typ.Procname.is_constructor proc_name then + if Procdesc.is_defined pdesc && Procname.is_constructor proc_name then match FieldsAssignedInConstructorsChecker.compute_post ~initial (ProcData.make (Summary.OnDisk.reset pdesc) tenv (Ident.Hash.create 10)) @@ -105,5 +105,5 @@ let analysis cfg tenv = domain else domain in - let fields_assigned_in_constructor = Typ.Procname.Hash.fold f cfg initial in + let fields_assigned_in_constructor = Procname.Hash.fold f cfg initial in add_nonnull_to_fields fields_assigned_in_constructor tenv diff --git a/infer/src/checkers/RequiredProps.ml b/infer/src/checkers/RequiredProps.ml index d2210e4e1..15adf466f 100644 --- a/infer/src/checkers/RequiredProps.ml +++ b/infer/src/checkers/RequiredProps.ml @@ -83,7 +83,7 @@ let report_missing_required_prop summary prop parent_typename ~create_loc call_c :: make_single_trace create_loc create_message :: List.map call_chain ~f:(fun Domain.MethodCallPrefix.{procname; location} -> let call_msg = - F.asprintf "calls %a" (Typ.Procname.pp_simplified_string ~withclass:false) procname + F.asprintf "calls %a" (Procname.pp_simplified_string ~withclass:false) procname in Errlog.make_trace_element 0 location call_msg [] ) in @@ -111,8 +111,8 @@ let has_prop prop_set prop = (** return true if this function is part of the Litho framework code rather than client code *) let is_litho_function = function - | Typ.Procname.Java java_procname -> ( - match Typ.Procname.Java.get_package java_procname with + | Procname.Java java_procname -> ( + match Procname.Java.get_package java_procname with | Some "com.facebook.litho" -> true | _ -> @@ -123,9 +123,9 @@ let is_litho_function = function let is_component_builder procname tenv = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> PatternMatch.is_subtype_of_str tenv - (Typ.Procname.Java.get_class_type_name java_procname) + (Procname.Java.get_class_type_name java_procname) "com.facebook.litho.Component$Builder" | _ -> false @@ -133,16 +133,16 @@ let is_component_builder procname tenv = let is_component procname tenv = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> PatternMatch.is_subtype_of_str tenv - (Typ.Procname.Java.get_class_type_name java_procname) + (Procname.Java.get_class_type_name java_procname) "com.facebook.litho.Component" | _ -> false let is_component_build_method procname tenv = - match Typ.Procname.get_method procname with + match Procname.get_method procname with | "build" -> is_component_builder procname tenv | _ -> @@ -150,13 +150,13 @@ let is_component_build_method procname tenv = let is_component_create_method procname tenv = - match Typ.Procname.get_method procname with "create" -> is_component procname tenv | _ -> false + match Procname.get_method procname with "create" -> is_component procname tenv | _ -> false let get_component_create_typ_opt procname tenv = match procname with - | Typ.Procname.Java java_pname when is_component_create_method procname tenv -> - Some (Typ.Procname.Java.get_class_type_name java_pname) + | Procname.Java java_pname when is_component_create_method procname tenv -> + Some (Procname.Java.get_class_type_name java_pname) | _ -> None @@ -172,8 +172,8 @@ let satisfies_heuristic ~callee_pname ~callee_summary_opt tenv = || is_component_create_method callee_pname tenv || match callee_pname with - | Typ.Procname.Java java_callee_procname -> - not (Typ.Procname.Java.is_static java_callee_procname || build_exists_in_callees) + | Procname.Java java_callee_procname -> + not (Procname.Java.is_static java_callee_procname || build_exists_in_callees) | _ -> not build_exists_in_callees @@ -196,8 +196,7 @@ let report astate tenv summary = Domain.check_required_props ~check_on_string_set astate -type get_proc_summary_and_formals = - Typ.Procname.t -> (Domain.summary * (Pvar.t * Typ.t) list) option +type get_proc_summary_and_formals = Procname.t -> (Domain.summary * (Pvar.t * Typ.t) list) option module TransferFunctions = struct module CFG = ProcCfg.Normal diff --git a/infer/src/checkers/Sanitizer.ml b/infer/src/checkers/Sanitizer.ml index e715d3cf6..916ca3634 100644 --- a/infer/src/checkers/Sanitizer.ml +++ b/infer/src/checkers/Sanitizer.ml @@ -11,7 +11,7 @@ module F = Format module type S = sig type t [@@deriving compare] - val get : Typ.Procname.t -> Tenv.t -> t option + val get : Procname.t -> Tenv.t -> t option val pp : F.formatter -> t -> unit end diff --git a/infer/src/checkers/Sanitizer.mli b/infer/src/checkers/Sanitizer.mli index 0bfec2ed4..97db14172 100644 --- a/infer/src/checkers/Sanitizer.mli +++ b/infer/src/checkers/Sanitizer.mli @@ -12,7 +12,7 @@ module F = Format module type S = sig type t [@@deriving compare] - val get : Typ.Procname.t -> Tenv.t -> t option + val get : Procname.t -> Tenv.t -> t option (** Get the sanitizer that should be applied to the return value of given procedure, if any *) val pp : F.formatter -> t -> unit diff --git a/infer/src/checkers/SelfInBlock.ml b/infer/src/checkers/SelfInBlock.ml index 6b22c8ad2..2583f28e1 100644 --- a/infer/src/checkers/SelfInBlock.ml +++ b/infer/src/checkers/SelfInBlock.ml @@ -326,7 +326,7 @@ let checker {Callbacks.exe_env; summary} = let procname = Summary.get_proc_name summary in let tenv = Exe_env.get_tenv exe_env procname in let proc_data = ProcData.make summary tenv () in - ( if Typ.Procname.is_objc_block procname then + ( if Procname.is_objc_block procname then match Analyzer.compute_post proc_data ~initial with | Some domain -> report_mix_self_weakself_issues summary domain.vars ; diff --git a/infer/src/checkers/SimpleChecker.ml b/infer/src/checkers/SimpleChecker.ml index 8debec4d1..797ad5757 100644 --- a/infer/src/checkers/SimpleChecker.ml +++ b/infer/src/checkers/SimpleChecker.ml @@ -19,11 +19,11 @@ module type Spec = sig val initial : t (** implement the state the analysis should start from here *) - val exec_instr : t -> Sil.instr -> Procdesc.Node.nodekind -> Typ.Procname.t -> Tenv.t -> t + val exec_instr : t -> Sil.instr -> Procdesc.Node.nodekind -> Procname.t -> Tenv.t -> t (** implement how an instruction changes your state here. input is the previous state, current instruction, current node kind, current procedure and type environment. *) - val report : t -> Location.t -> Typ.Procname.t -> unit + val report : t -> Location.t -> Procname.t -> unit (** log errors here. input is a state, location where the state occurs in the source, and the current procedure. *) diff --git a/infer/src/checkers/SimpleChecker.mli b/infer/src/checkers/SimpleChecker.mli index 3444df45c..c7f5d2084 100644 --- a/infer/src/checkers/SimpleChecker.mli +++ b/infer/src/checkers/SimpleChecker.mli @@ -12,9 +12,9 @@ module type Spec = sig val initial : t - val exec_instr : t -> Sil.instr -> Procdesc.Node.nodekind -> Typ.Procname.t -> Tenv.t -> t + val exec_instr : t -> Sil.instr -> Procdesc.Node.nodekind -> Procname.t -> Tenv.t -> t - val report : t -> Location.t -> Typ.Procname.t -> unit + val report : t -> Location.t -> Procname.t -> unit val compare : t -> t -> int end diff --git a/infer/src/checkers/Sink.ml b/infer/src/checkers/Sink.ml index 11b3330ee..607bdc9c1 100644 --- a/infer/src/checkers/Sink.ml +++ b/infer/src/checkers/Sink.ml @@ -11,7 +11,7 @@ module F = Format module type Kind = sig include TraceElem.Kind - val get : Typ.Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) list + val get : Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) list end module type S = sig diff --git a/infer/src/checkers/Sink.mli b/infer/src/checkers/Sink.mli index bb1a2895f..0aff75652 100644 --- a/infer/src/checkers/Sink.mli +++ b/infer/src/checkers/Sink.mli @@ -10,7 +10,7 @@ open! IStd module type Kind = sig include TraceElem.Kind - val get : Typ.Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) list + val get : Procname.t -> HilExp.t list -> CallFlags.t -> Tenv.t -> (t * IntSet.t) list (** return Some kind if the given procname/actuals are a sink, None otherwise *) end diff --git a/infer/src/checkers/SinkTrace.ml b/infer/src/checkers/SinkTrace.ml index 192744299..afb1075da 100644 --- a/infer/src/checkers/SinkTrace.ml +++ b/infer/src/checkers/SinkTrace.ml @@ -14,9 +14,9 @@ module type S = sig type sink_path = Passthroughs.t * (Sink.t * Passthroughs.t) list - val get_reportable_sink_paths : t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path list + val get_reportable_sink_paths : t -> trace_of_pname:(Procname.t -> t) -> sink_path list - val get_reportable_sink_path : Sink.t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path option + val get_reportable_sink_path : Sink.t -> trace_of_pname:(Procname.t -> t) -> sink_path option val with_callsite : t -> CallSite.t -> t diff --git a/infer/src/checkers/SinkTrace.mli b/infer/src/checkers/SinkTrace.mli index 32d821839..0b0232f42 100644 --- a/infer/src/checkers/SinkTrace.mli +++ b/infer/src/checkers/SinkTrace.mli @@ -15,10 +15,10 @@ module type S = sig passthroughs for each callee *) type sink_path = Passthrough.Set.t * (Sink.t * Passthrough.Set.t) list - val get_reportable_sink_paths : t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path list + val get_reportable_sink_paths : t -> trace_of_pname:(Procname.t -> t) -> sink_path list (** get a path for each of the reportable flows to a sink in this trace *) - val get_reportable_sink_path : Sink.t -> trace_of_pname:(Typ.Procname.t -> t) -> sink_path option + val get_reportable_sink_path : Sink.t -> trace_of_pname:(Procname.t -> t) -> sink_path option (** get a report for a single sink *) val with_callsite : t -> CallSite.t -> t diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 46af067fd..4b3d57ae4 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -13,8 +13,8 @@ module GlobalVarSet = SiofTrace.GlobalVarSet let methods_whitelist = QualifiedCppName.Match.of_fuzzy_qual_names Config.siof_safe_methods -let is_whitelisted (pname : Typ.Procname.t) = - Typ.Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers methods_whitelist +let is_whitelisted (pname : Procname.t) = + Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers methods_whitelist type siof_model = @@ -53,7 +53,7 @@ let is_modelled = List.map models ~f:(fun {qual_name} -> qual_name) |> QualifiedCppName.Match.of_fuzzy_qual_names in fun pname -> - Typ.Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers models_matcher + Procname.get_qualifiers pname |> QualifiedCppName.Match.match_qualifiers models_matcher module Payload = SummaryPayload.Make (struct @@ -139,7 +139,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let exec_instr astate {ProcData.summary} _ (instr : Sil.instr) = match instr with | Store {e1= Lvar global; typ= Typ.{desc= Tptr _}; e2= Lvar _; loc} - when (Option.equal Typ.Procname.equal) + when (Option.equal Procname.equal) (Pvar.get_initializer_pname global) (Some (Summary.get_proc_name summary)) -> (* if we are just taking the reference of another global then we are not really accessing @@ -162,14 +162,13 @@ module TransferFunctions (CFG : ProcCfg.S) = struct if QualifiedCppName.Match.of_fuzzy_qual_names [qual_name] |> Fn.flip QualifiedCppName.Match.match_qualifiers - (Typ.Procname.get_qualifiers callee_pname) + (Procname.get_qualifiers callee_pname) then Some initialized_globals else None ) in Domain.join astate (NonBottom SiofTrace.bottom, Domain.VarNames.of_list init) | Call (_, Const (Cfun (ObjC_Cpp cpp_pname as callee_pname)), _ :: actuals_without_self, loc, _) - when Typ.Procname.is_constructor callee_pname && Typ.Procname.ObjC_Cpp.is_constexpr cpp_pname - -> + when Procname.is_constructor callee_pname && Procname.ObjC_Cpp.is_constexpr cpp_pname -> add_actuals_globals astate summary loc actuals_without_self | Call (_, Const (Cfun callee_pname), actuals, loc, _) -> let callee_astate = @@ -283,7 +282,7 @@ let checker {Callbacks.exe_env; summary; get_procs_in_file} : Summary.t = "__infer_translation_unit_init_streams") |> Pvar.get_initializer_pname ) in - get_procs_in_file pname |> List.exists ~f:(Typ.Procname.equal magic_iostream_marker) + get_procs_in_file pname |> List.exists ~f:(Procname.equal magic_iostream_marker) in includes_iostream (Procdesc.get_attributes proc_desc).ProcAttributes.translation_unit in @@ -299,11 +298,7 @@ let checker {Callbacks.exe_env; summary; get_procs_in_file} : Summary.t = specification if it's given to us. This also serves as an optimization as this skips the analysis of the function. *) if - match pname with - | ObjC_Cpp cpp_pname -> - Typ.Procname.ObjC_Cpp.is_constexpr cpp_pname - | _ -> - false + match pname with ObjC_Cpp cpp_pname -> Procname.ObjC_Cpp.is_constexpr cpp_pname | _ -> false then Payload.update_summary initial summary else match Analyzer.compute_post proc_data ~initial with @@ -312,7 +307,7 @@ let checker {Callbacks.exe_env; summary; get_procs_in_file} : Summary.t = | None -> summary in - ( match Typ.Procname.get_global_name_of_initializer pname with + ( match Procname.get_global_name_of_initializer pname with | Some gname -> siof_check gname updated_summary | None -> diff --git a/infer/src/checkers/SiofTrace.ml b/infer/src/checkers/SiofTrace.ml index 46de7b2b5..4f7e3dbd1 100644 --- a/infer/src/checkers/SiofTrace.ml +++ b/infer/src/checkers/SiofTrace.ml @@ -55,7 +55,7 @@ end include SinkTrace.Make (TraceElem) let make_access kind loc = - let site = CallSite.make Typ.Procname.empty_block loc in + let site = CallSite.make Procname.empty_block loc in {TraceElem.kind= (`Access, kind); site} @@ -66,7 +66,7 @@ let trace_of_error loc gname path = if is_intraprocedural_access sink then Format.asprintf "%a" Sink.pp sink else let callsite = Sink.call_site sink in - Format.asprintf "call to %a" Typ.Procname.pp (CallSite.pname callsite) + Format.asprintf "call to %a" Procname.pp (CallSite.pname callsite) in let sink_should_nest sink = not (is_intraprocedural_access sink) in let trace_elem_of_global = diff --git a/infer/src/checkers/Source.ml b/infer/src/checkers/Source.ml index 5119aa25b..8c4cbf7d4 100644 --- a/infer/src/checkers/Source.ml +++ b/infer/src/checkers/Source.ml @@ -17,11 +17,7 @@ module type Kind = sig include TraceElem.Kind val get : - caller_pname:Typ.Procname.t - -> Typ.Procname.t - -> HilExp.t list - -> Tenv.t - -> (t * int option) list + caller_pname:Procname.t -> Procname.t -> HilExp.t list -> Tenv.t -> (t * int option) list val get_tainted_formals : Procdesc.t -> Tenv.t -> (Mangled.t * Typ.t * t option) list end @@ -31,7 +27,7 @@ module type S = sig type spec = {source: t; index: int option} - val get : caller_pname:Typ.Procname.t -> CallSite.t -> HilExp.t list -> Tenv.t -> spec list + val get : caller_pname:Procname.t -> CallSite.t -> HilExp.t list -> Tenv.t -> spec list 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 9d198ed9e..e54a87cb7 100644 --- a/infer/src/checkers/Source.mli +++ b/infer/src/checkers/Source.mli @@ -14,11 +14,7 @@ module type Kind = sig include TraceElem.Kind val get : - caller_pname:Typ.Procname.t - -> Typ.Procname.t - -> HilExp.t list - -> Tenv.t - -> (t * int option) list + caller_pname:Procname.t -> Procname.t -> HilExp.t list -> Tenv.t -> (t * int option) list (** return Some (kind) if the procedure with the given actuals is a taint source, None otherwise *) val get_tainted_formals : Procdesc.t -> Tenv.t -> (Mangled.t * Typ.t * t option) list @@ -33,7 +29,7 @@ module type S = sig { source: t (** type of the returned source *) ; index: int option (** index of the returned source if Some; return value if None *) } - val get : caller_pname:Typ.Procname.t -> CallSite.t -> HilExp.t list -> Tenv.t -> spec list + val get : caller_pname:Procname.t -> CallSite.t -> HilExp.t list -> Tenv.t -> spec list (** return Some (taint spec) if the call site with the given actuals is a taint source, None otherwise *) diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index 835fa1c16..87822c973 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -69,7 +69,7 @@ module type S = sig reported paths to ones introduced by the call at [cur_site] *) val get_reportable_paths : - ?cur_site:CallSite.t -> t -> trace_of_pname:(Typ.Procname.t -> t) -> path list + ?cur_site:CallSite.t -> t -> trace_of_pname:(Procname.t -> t) -> path list (** 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] *) @@ -110,7 +110,7 @@ module type S = sig val pp : F.formatter -> t -> unit - val pp_path : Typ.Procname.t -> F.formatter -> path -> unit + val pp_path : Procname.t -> F.formatter -> path -> unit (** pretty-print a path in the context of the given procname *) end @@ -321,7 +321,7 @@ module Make (Spec : Spec) = struct let original_source = fst (List.hd_exn sources_passthroughs) in let final_sink = fst (List.hd_exn sinks_passthroughs) in F.fprintf fmt "Error: %a -> %a. Full trace:@.%a@.Current procedure %a %a@.%a" pp_path_source - original_source Sink.pp final_sink pp_sources sources_passthroughs Typ.Procname.pp cur_pname + original_source Sink.pp final_sink pp_sources sources_passthroughs Procname.pp cur_pname pp_passthroughs cur_passthroughs pp_sinks (List.rev sinks_passthroughs) @@ -383,17 +383,17 @@ module Make (Spec : Spec) = struct ?(desc_of_source = fun source -> let callsite = Source.call_site source in - Format.asprintf "return from %a" Typ.Procname.pp (CallSite.pname callsite)) + Format.asprintf "return from %a" 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" Typ.Procname.pp (CallSite.pname callsite)) + Format.asprintf "call to %a" 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" Typ.Procname.pp (CallSite.pname passthrough_site) in + let desc = F.asprintf "flow through %a" 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 *) diff --git a/infer/src/checkers/Trace.mli b/infer/src/checkers/Trace.mli index 225adae95..a72c3e6c6 100644 --- a/infer/src/checkers/Trace.mli +++ b/infer/src/checkers/Trace.mli @@ -78,7 +78,7 @@ module type S = sig reported paths to ones introduced by the call at [cur_site] *) val get_reportable_paths : - ?cur_site:CallSite.t -> t -> trace_of_pname:(Typ.Procname.t -> t) -> path list + ?cur_site:CallSite.t -> t -> trace_of_pname:(Procname.t -> t) -> path list (** 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] *) @@ -121,7 +121,7 @@ module type S = sig val pp : F.formatter -> t -> unit - val pp_path : Typ.Procname.t -> F.formatter -> path -> unit + val pp_path : Procname.t -> F.formatter -> path -> unit (** pretty-print a path in the context of the given procname *) end diff --git a/infer/src/checkers/androidFramework.ml b/infer/src/checkers/androidFramework.ml index e56268fea..bdce355aa 100644 --- a/infer/src/checkers/androidFramework.ml +++ b/infer/src/checkers/androidFramework.ml @@ -18,8 +18,8 @@ let drawable_prefix = "R$drawable" (** return true if [pname] is a special lifecycle cleanup method *) let is_destroy_method pname = match pname with - | Typ.Procname.Java pname_java -> - let method_name = Typ.Procname.Java.get_method pname_java in + | Procname.Java pname_java -> + let method_name = Procname.Java.get_method pname_java in String.equal method_name on_destroy || String.equal method_name on_destroy_view | _ -> false diff --git a/infer/src/checkers/androidFramework.mli b/infer/src/checkers/androidFramework.mli index 5aeff190f..a454401ea 100644 --- a/infer/src/checkers/androidFramework.mli +++ b/infer/src/checkers/androidFramework.mli @@ -19,5 +19,5 @@ val is_view : Tenv.t -> Typ.Name.t -> bool val is_fragment : Tenv.t -> Typ.Name.t -> bool -val is_destroy_method : Typ.Procname.t -> bool +val is_destroy_method : Procname.t -> bool (** return true if [procname] is a special lifecycle cleanup method *) diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index 0357127c4..d1dcb50e1 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -22,13 +22,11 @@ module Payload = SummaryPayload.Make (struct end) let is_modeled_expensive tenv = function - | Typ.Procname.Java proc_name_java as proc_name -> + | Procname.Java proc_name_java as proc_name -> (not (BuiltinDecl.is_declared proc_name)) && let is_subclass = - let classname = - Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name proc_name_java) - in + let classname = Typ.Name.Java.from_string (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 @@ -38,12 +36,12 @@ let is_modeled_expensive tenv = function let is_allocator tenv pname = match pname with - | Typ.Procname.Java pname_java -> + | Procname.Java pname_java -> let is_throwable () = - let class_name = Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name pname_java) in + let class_name = Typ.Name.Java.from_string (Procname.Java.get_class_name pname_java) in PatternMatch.is_throwable tenv class_name in - Typ.Procname.is_constructor pname + Procname.is_constructor pname && (not (BuiltinDecl.is_declared pname)) && not (is_throwable ()) | _ -> @@ -81,7 +79,7 @@ let update_trace loc trace = else Errlog.make_trace_element 0 loc "" [] :: trace -let string_of_pname = Typ.Procname.to_simplified_string ~withclass:true +let string_of_pname = Procname.to_simplified_string ~withclass:true let report_allocation_stack src_annot summary fst_call_loc trace stack_str constructor_pname call_loc = @@ -90,7 +88,7 @@ let report_allocation_stack src_annot summary fst_call_loc trace stack_str const let constr_str = string_of_pname constructor_pname in let description = Format.asprintf "Method %a annotated with %a allocates %a via %a" MF.pp_monospaced - (Typ.Procname.to_simplified_string pname) + (Procname.to_simplified_string pname) MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced constr_str MF.pp_monospaced (stack_str ^ "new " ^ constr_str) in @@ -108,7 +106,7 @@ let report_annotation_stack src_annot snk_annot src_summary loc trace stack_str let description = Format.asprintf "Method %a annotated with %a calls %a where %a is annotated with %a" MF.pp_monospaced - (Typ.Procname.to_simplified_string src_pname) + (Procname.to_simplified_string src_pname) MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced (stack_str ^ exp_pname_str) MF.pp_monospaced exp_pname_str MF.pp_monospaced ("@" ^ snk_annot) in @@ -148,8 +146,8 @@ let report_call_stack summary end_of_stack lookup_next_calls report call_site si let call_site = Domain.CallSites.min_elt call_sites in let p = CallSite.pname call_site in let loc = CallSite.loc call_site in - if Typ.Procname.Set.mem p visited then accu - else ((p, loc) :: unseen, Typ.Procname.Set.add p visited) + if Procname.Set.mem p visited then accu + else ((p, loc) :: unseen, Procname.Set.add p visited) with Caml.Not_found -> accu ) next_calls ([], visited_pnames) in @@ -162,7 +160,7 @@ let report_call_stack summary end_of_stack lookup_next_calls report call_site si 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 Typ.Procname.Set.empty (start_trace, "") (fst_callee_pname, fst_call_loc) + loop fst_call_loc Procname.Set.empty (start_trace, "") (fst_callee_pname, fst_call_loc) with Caml.Not_found -> () ) sink_map @@ -189,7 +187,7 @@ let report_src_snk_paths proc_data annot_map src_annot_list snk_annot = let annotation_of_str annot_str = {Annot.class_name= annot_str; parameters= []} module AnnotationSpec = struct - type predicate = Tenv.t -> Typ.Procname.t -> bool + type predicate = Tenv.t -> Procname.t -> bool type t = { description: string (** for debugging *) @@ -248,7 +246,7 @@ module CxxAnnotationSpecs = struct let chop_prefix s = String.chop_prefix s ~prefix:Config.clang_inner_destructor_prefix |> Option.value ~default:s in - let pname_str = Typ.Procname.to_string pname in + let pname_str = Procname.to_string pname in let i = Option.value (String.rindex pname_str ':') ~default:(-1) + 1 in let slen = String.length pname_str in String.sub pname_str ~pos:0 ~len:i @@ -257,7 +255,7 @@ module CxxAnnotationSpecs = struct let debug_pred ~spec_name ~desc pred pname = - L.d_printf "%s: Checking if `%a` is a %s... " spec_name Typ.Procname.pp pname desc ; + L.d_printf "%s: Checking if `%a` is a %s... " spec_name Procname.pp pname desc ; let r = pred pname in L.d_printf "%b %s.@." r desc ; r @@ -270,7 +268,7 @@ module CxxAnnotationSpecs = struct let spec_from_config spec_name spec_cfg source_overrides = let src = option_name ^ " -> " ^ spec_name in - let make_pname_pred entry ~src : Typ.Procname.t -> bool = + let make_pname_pred entry ~src : Procname.t -> bool = let symbols = U.yojson_lookup entry "symbols" ~src ~f:U.string_list_of_yojson ~default:[] in let symbol_regexps = U.yojson_lookup entry "symbol_regexps" ~src ~default:None ~f:(fun json ~src -> @@ -289,7 +287,7 @@ module CxxAnnotationSpecs = struct in let path_pred pname = List.exists ~f:(path_match (src_path_of pname)) paths in fun pname -> - let pname_string = Typ.Procname.to_string pname in + let pname_string = Procname.to_string pname in sym_pred pname_string || sym_regexp_pred pname_string || path_pred pname in let sources, sources_src = @@ -306,8 +304,8 @@ module CxxAnnotationSpecs = struct make_pname_pred sources ~src:sources_src pname && match pname with - | Typ.Procname.ObjC_Cpp cname -> - not (Typ.Procname.ObjC_Cpp.is_inner_destructor cname) + | Procname.ObjC_Cpp cname -> + not (Procname.ObjC_Cpp.is_inner_destructor cname) | _ -> true in @@ -423,10 +421,8 @@ module ExpensiveAnnotationSpec = struct if not (method_is_expensive tenv overridden_pname) then let description = Format.asprintf "Method %a overrides unannotated method %a and cannot be annotated with %a" - MF.pp_monospaced - (Typ.Procname.to_string proc_name) - MF.pp_monospaced - (Typ.Procname.to_string overridden_pname) + MF.pp_monospaced (Procname.to_string proc_name) MF.pp_monospaced + (Procname.to_string overridden_pname) MF.pp_monospaced ("@" ^ Annotations.expensive) in Reporting.log_error summary ~loc IssueType.checkers_expensive_overrides_unexpensive @@ -488,12 +484,12 @@ let annot_specs = let get_annot_specs pname = let language = match pname with - | Typ.Procname.Java _ -> + | Procname.Java _ -> Language.Java - | Typ.Procname.ObjC_Cpp _ | Typ.Procname.C _ | Typ.Procname.Block _ -> + | Procname.ObjC_Cpp _ | Procname.C _ | Procname.Block _ -> Language.Clang | _ -> - L.die InternalError "Cannot find language for proc %s" (Typ.Procname.to_string pname) + L.die InternalError "Cannot find language for proc %s" (Procname.to_string pname) in List.Assoc.find_exn ~equal:Language.equal annot_specs language @@ -513,8 +509,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let check_call tenv ~caller_pname ~callee_pname call_site astate specs = List.fold ~init:astate specs ~f:(fun astate (spec : AnnotationSpec.t) -> if is_sink tenv spec ~caller_pname ~callee_pname then ( - L.d_printfln "%s: Adding sink call `%a -> %a`" spec.description Typ.Procname.pp - caller_pname Typ.Procname.pp callee_pname ; + L.d_printfln "%s: Adding sink call `%a -> %a`" spec.description Procname.pp caller_pname + Procname.pp callee_pname ; Domain.add_call_site spec.sink_annotation callee_pname call_site astate ) else astate ) @@ -524,7 +520,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | None -> astate | Some callee_call_map -> - L.d_printf "Applying summary for `%a`@\n" Typ.Procname.pp callee_pname ; + L.d_printf "Applying summary for `%a`@\n" Procname.pp callee_pname ; let add_call_site annot sink calls astate = if Domain.CallSites.is_empty calls then astate else @@ -535,8 +531,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct List.fold ~init:astate specs ~f:(fun astate (spec : AnnotationSpec.t) -> if is_sink tenv spec ~caller_pname ~callee_pname:sink then ( L.d_printf "%s: Adding sink call from `%a`'s summary `%a -> %a`@\n" - spec.description Typ.Procname.pp callee_pname Typ.Procname.pp caller_pname - Typ.Procname.pp sink ; + spec.description Procname.pp callee_pname Procname.pp caller_pname Procname.pp + sink ; Domain.add_call_site annot sink call_site astate ) else astate ) in diff --git a/infer/src/checkers/annotationReachabilityDomain.ml b/infer/src/checkers/annotationReachabilityDomain.ml index 3c303896d..a2e991561 100644 --- a/infer/src/checkers/annotationReachabilityDomain.ml +++ b/infer/src/checkers/annotationReachabilityDomain.ml @@ -7,7 +7,7 @@ open! IStd module CallSites = AbstractDomain.FiniteSetOfPPSet (CallSite.Set) -module SinkMap = AbstractDomain.MapOfPPMap (Typ.Procname.Map) (CallSites) +module SinkMap = AbstractDomain.MapOfPPMap (Procname.Map) (CallSites) include AbstractDomain.Map (Annot) (SinkMap) let add_call_site annot sink call_site annot_map = diff --git a/infer/src/checkers/annotationReachabilityDomain.mli b/infer/src/checkers/annotationReachabilityDomain.mli index efcfa4476..b6e1d1532 100644 --- a/infer/src/checkers/annotationReachabilityDomain.mli +++ b/infer/src/checkers/annotationReachabilityDomain.mli @@ -9,8 +9,8 @@ open! IStd module CallSites : AbstractDomain.FiniteSetS with type elt = CallSite.t -module SinkMap : AbstractDomain.MapS with type key = Typ.Procname.t and type value = CallSites.t +module SinkMap : AbstractDomain.MapS with type key = Procname.t and type value = CallSites.t include AbstractDomain.MapS with type key = Annot.t and type value = SinkMap.t -val add_call_site : Annot.t -> Typ.Procname.t -> CallSite.t -> t -> t +val add_call_site : Annot.t -> Procname.t -> CallSite.t -> t -> t diff --git a/infer/src/checkers/annotations.mli b/infer/src/checkers/annotations.mli index 93769288a..5335e038d 100644 --- a/infer/src/checkers/annotations.mli +++ b/infer/src/checkers/annotations.mli @@ -119,8 +119,8 @@ val pdesc_has_return_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool (** return true if the given predicate evaluates to true on the annotation of [pdesc]'s return value *) val pname_has_return_annot : - Typ.Procname.t - -> attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) + Procname.t + -> attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> (Annot.Item.t -> bool) -> bool (** return true if the given predicate evaluates to true on the annotation of [pname]'s return diff --git a/infer/src/checkers/classLoads.ml b/infer/src/checkers/classLoads.ml index c1ea6166a..8da78d2dd 100644 --- a/infer/src/checkers/classLoads.ml +++ b/infer/src/checkers/classLoads.ml @@ -36,7 +36,7 @@ let rec load_class summary tenv loc astate class_name = let astate1 = ClassLoadsDomain.add_typename loc astate class_name in (* load classes referenced by the class initializer *) let astate2 = - let class_initializer = Typ.Procname.(Java (Java.get_class_initializer class_name)) in + let class_initializer = Procname.(Java (Java.get_class_initializer class_name)) in (* NB may recurse if we are in class init but the shortcircuiting above makes it a no-op *) do_call summary class_initializer loc astate1 in @@ -86,7 +86,7 @@ let rec add_loads_of_exp summary tenv loc (exp : Exp.t) astate = let exec_call summary tenv callee args loc astate = match args with - | [_; (Exp.Sizeof {typ}, _)] when Typ.Procname.equal callee BuiltinDecl.__instanceof -> + | [_; (Exp.Sizeof {typ}, _)] when Procname.equal callee BuiltinDecl.__instanceof -> (* this matches downcasts/instanceof and exception handlers *) load_type summary tenv loc typ astate | _ -> @@ -118,9 +118,9 @@ let report_loads summary astate = Reporting.log_warning summary ~loc ~ltr IssueType.class_load msg in let pname = Summary.get_proc_name summary in - Typ.Procname.get_class_name pname + Procname.get_class_name pname |> Option.iter ~f:(fun clazz -> - let method_strname = Typ.Procname.get_method pname in + let method_strname = Procname.get_method pname in let fullname = clazz ^ "." ^ method_strname in if String.Set.mem Config.class_loads_roots fullname then ClassLoadsDomain.iter report_load astate ) @@ -130,15 +130,15 @@ let analyze_procedure {Callbacks.exe_env; summary} = let proc_desc = Summary.get_proc_desc summary in let proc_name = Procdesc.get_proc_name proc_desc in let tenv = Exe_env.get_tenv exe_env proc_name in - L.debug Analysis Verbose "CL: ANALYZING %a@." Typ.Procname.pp proc_name ; + L.debug Analysis Verbose "CL: ANALYZING %a@." Procname.pp proc_name ; let loc = Procdesc.get_loc proc_desc in (* load the method's class *) let init = - Typ.Procname.get_class_type_name proc_name + Procname.get_class_type_name proc_name |> Option.fold ~init:ClassLoadsDomain.bottom ~f:(load_class summary tenv loc) in let post = Procdesc.fold_instrs proc_desc ~init ~f:(exec_instr summary tenv) in report_loads summary post ; let result = Payload.update_summary post summary in - L.debug Analysis Verbose "CL: FINISHED ANALYZING %a@." Typ.Procname.pp proc_name ; + L.debug Analysis Verbose "CL: FINISHED ANALYZING %a@." Procname.pp proc_name ; result diff --git a/infer/src/checkers/classLoadsDomain.ml b/infer/src/checkers/classLoadsDomain.ml index 1abb6fedf..339d60b26 100644 --- a/infer/src/checkers/classLoadsDomain.ml +++ b/infer/src/checkers/classLoadsDomain.ml @@ -45,7 +45,7 @@ let mem_typename name astate = let add_typename loc astate name = Typ.Name.name name |> add_string loc astate let integrate_summary callee_pname loc astate callee_summary = - L.debug Analysis Verbose "CL: ADDING SUMMARY OF %a@." Typ.Procname.pp callee_pname ; + L.debug Analysis Verbose "CL: ADDING SUMMARY OF %a@." Procname.pp callee_pname ; let callsite = CallSite.make callee_pname loc in let summary = with_callsite callee_summary callsite in union astate summary diff --git a/infer/src/checkers/classLoadsDomain.mli b/infer/src/checkers/classLoadsDomain.mli index 374a54116..14386484f 100644 --- a/infer/src/checkers/classLoadsDomain.mli +++ b/infer/src/checkers/classLoadsDomain.mli @@ -21,6 +21,6 @@ val mem_typename : Typ.Name.t -> t -> bool val add_typename : Location.t -> t -> Typ.Name.t -> t -val integrate_summary : Typ.Procname.t -> Location.t -> t -> summary -> t +val integrate_summary : Procname.t -> Location.t -> t -> summary -> t val iter : (Event.t -> unit) -> t -> unit diff --git a/infer/src/checkers/cost.ml b/infer/src/checkers/cost.ml index aec56f8a0..39e6b419c 100644 --- a/infer/src/checkers/cost.ml +++ b/infer/src/checkers/cost.ml @@ -493,8 +493,8 @@ module ConstraintSolver = struct let collect_constraints ~debug node_cfg = let equalities = Equalities.create () in Container.iter node_cfg ~fold:NodeCFG.fold_nodes ~f:(collect_on_node ~debug equalities) ; - debug.f "[ConstraintSolver] Procedure %a @@ %a@\n" Typ.Procname.pp - (Procdesc.get_proc_name node_cfg) Location.pp_file_pos (Procdesc.get_loc node_cfg) ; + debug.f "[ConstraintSolver] Procedure %a @@ %a@\n" Procname.pp (Procdesc.get_proc_name node_cfg) + Location.pp_file_pos (Procdesc.get_loc node_cfg) ; debug.f "[ConstraintSolver][EInit] %a@\n" Equalities.pp_equalities equalities ; Equalities.normalize_sums equalities ; debug.f "[ConstraintSolver][ENorm] %a@\n" Equalities.pp_equalities equalities ; @@ -524,7 +524,7 @@ type extras_WorstCaseCost = { inferbo_invariant_map: BufferOverrunAnalysis.invariant_map ; integer_type_widths: Typ.IntegerWidths.t ; get_node_nb_exec: Node.id -> BasicCost.t - ; get_callee_summary_and_formals: Typ.Procname.t -> callee_summary_and_formals option } + ; get_callee_summary_and_formals: Procname.t -> callee_summary_and_formals option } let instantiate_cost integer_type_widths ~inferbo_caller_mem ~callee_pname ~callee_formals ~params ~callee_cost ~loc = @@ -550,7 +550,7 @@ module InstrBasicCost = struct let is_allocation_function callee_pname = - List.exists allocation_functions ~f:(fun f -> Typ.Procname.equal callee_pname f) + List.exists allocation_functions ~f:(fun f -> Procname.equal callee_pname f) let get_instr_cost_record tenv extras instr_node instr = @@ -716,8 +716,7 @@ module Check = struct ~threshold ~is_on_ui_thread = let pname = Procdesc.get_proc_name proc_desc in let report_issue_type = - L.(debug Analysis Medium) - "@\n\n++++++ Checking error type for %a **** @\n" Typ.Procname.pp pname ; + L.(debug Analysis Medium) "@\n\n++++++ Checking error type for %a **** @\n" Procname.pp pname ; let is_on_cold_start = ExternalPerfData.in_profiler_data_map (Procdesc.get_proc_name proc_desc) in @@ -749,7 +748,7 @@ module Check = struct let report_top_and_bottom proc_desc summary ~name ~cost CostIssues.{zero_issue; infinite_issue} = let report issue suffix = let message = - F.asprintf "%s of the function %a %s" name Typ.Procname.pp + F.asprintf "%s of the function %a %s" name Procname.pp (Procdesc.get_proc_name proc_desc) suffix in @@ -764,7 +763,7 @@ module Check = struct let check_and_report ~is_on_ui_thread WorstCaseCost.{costs; reports} proc_desc summary = let pname = Procdesc.get_proc_name proc_desc in - if not (Typ.Procname.is_java_access_method pname) then ( + if not (Procname.is_java_access_method pname) then ( CostIssues.CostKindMap.iter2 CostIssues.enabled_cost_map reports ~f:(fun _kind (CostIssues.{name; threshold} as kind_spec) -> function | ThresholdReports.Threshold _ -> @@ -870,7 +869,7 @@ let checker {Callbacks.exe_env; summary} : Summary.t = let () = let exit_cost_record = astate.WorstCaseCost.costs in L.(debug Analysis Verbose) - "@\n[COST ANALYSIS] PROCEDURE '%a' |CFG| = %i FINAL COST = %a @\n" Typ.Procname.pp proc_name + "@\n[COST ANALYSIS] PROCEDURE '%a' |CFG| = %i FINAL COST = %a @\n" Procname.pp proc_name (Container.length ~fold:NodeCFG.fold_nodes node_cfg) CostDomain.VariantCostMap.pp exit_cost_record in diff --git a/infer/src/checkers/cost.mli b/infer/src/checkers/cost.mli index 191a4285a..4a0337f68 100644 --- a/infer/src/checkers/cost.mli +++ b/infer/src/checkers/cost.mli @@ -12,7 +12,7 @@ val checker : Callbacks.proc_callback_t val instantiate_cost : Typ.IntegerWidths.t -> inferbo_caller_mem:BufferOverrunDomain.Mem.t - -> callee_pname:Typ.Procname.t + -> callee_pname:Procname.t -> callee_formals:(Pvar.t * Typ.t) list -> params:(Exp.t * Typ.t) list -> callee_cost:CostDomain.BasicCost.t diff --git a/infer/src/checkers/dataflow.ml b/infer/src/checkers/dataflow.ml index b349f8853..65d9fcea7 100644 --- a/infer/src/checkers/dataflow.ml +++ b/infer/src/checkers/dataflow.ml @@ -27,7 +27,7 @@ module type DFStateType = sig val do_node : Tenv.t -> Procdesc.Node.t -> t -> t list * t list (** Perform a state transition on a node. *) - val proc_throws : Typ.Procname.t -> throws + val proc_throws : Procname.t -> throws (** Can proc throw an exception? *) end @@ -45,7 +45,7 @@ module type DF = sig end (** Determine if the node can throw an exception. *) -let node_throws pdesc node (proc_throws : Typ.Procname.t -> throws) : throws = +let node_throws pdesc node (proc_throws : Procname.t -> throws) : throws = let instr_throws instr = let is_return pvar = let ret_pvar = Procdesc.get_ret_var pdesc in @@ -57,7 +57,7 @@ let node_throws pdesc node (proc_throws : Typ.Procname.t -> throws) : throws = Throws | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) when BuiltinDecl.is_declared callee_pn -> - if Typ.Procname.equal callee_pn BuiltinDecl.__cast then DontKnow else DoesNotThrow + if Procname.equal callee_pn BuiltinDecl.__cast then DontKnow else DoesNotThrow | Sil.Call (_, Exp.Const (Const.Cfun callee_pn), _, _, _) -> proc_throws callee_pn | _ -> diff --git a/infer/src/checkers/dataflow.mli b/infer/src/checkers/dataflow.mli index ef715417b..fd1aa3d45 100644 --- a/infer/src/checkers/dataflow.mli +++ b/infer/src/checkers/dataflow.mli @@ -26,7 +26,7 @@ module type DFStateType = sig val do_node : Tenv.t -> Procdesc.Node.t -> t -> t list * t list (** Perform a state transition on a node. *) - val proc_throws : Typ.Procname.t -> throws + val proc_throws : Procname.t -> throws (** Can proc throw an exception? *) end diff --git a/infer/src/checkers/fragmentRetainsViewChecker.ml b/infer/src/checkers/fragmentRetainsViewChecker.ml index 5f41dc878..33e7a8d5c 100644 --- a/infer/src/checkers/fragmentRetainsViewChecker.ml +++ b/infer/src/checkers/fragmentRetainsViewChecker.ml @@ -25,10 +25,10 @@ let rec format_typ typ = let format_method pname = match pname with - | Typ.Procname.Java pname_java -> - Typ.Procname.Java.get_method pname_java + | Procname.Java pname_java -> + Procname.Java.get_method pname_java | _ -> - Typ.Procname.to_string pname + Procname.to_string pname let report_warning class_name fld fld_typ summary = @@ -50,7 +50,7 @@ let callback_fragment_retains_view_java java_pname {Callbacks.summary; exe_env} (* TODO: complain if onDestroyView is not defined, yet the Fragment has View fields *) (* TODO: handle fields nullified in callees in the same file *) let tenv = Exe_env.get_tenv exe_env (Summary.get_proc_name summary) in - let is_on_destroy_view = String.equal (Typ.Procname.Java.get_method java_pname) on_destroy_view in + let is_on_destroy_view = String.equal (Procname.Java.get_method java_pname) on_destroy_view in let fld_typ_is_view typ = match typ.Typ.desc with | Typ.Tptr ({desc= Tstruct tname}, _) -> @@ -64,7 +64,7 @@ let callback_fragment_retains_view_java java_pname {Callbacks.summary; exe_env} Typ.Name.equal fld_classname class_typename && fld_typ_is_view fld_typ in if is_on_destroy_view then - let class_name = Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_pname) in + let class_name = Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname) in match Tenv.lookup tenv class_name with | Some {fields} when AndroidFramework.is_fragment tenv class_name -> let declared_view_fields = List.filter ~f:(is_declared_view_typ class_name) fields in @@ -85,7 +85,7 @@ let callback_fragment_retains_view_java java_pname {Callbacks.summary; exe_env} let callback_fragment_retains_view ({Callbacks.summary} as args) : Summary.t = let proc_name = Summary.get_proc_name summary in ( match proc_name with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> callback_fragment_retains_view_java java_pname args | _ -> () ) ; diff --git a/infer/src/checkers/functionPointers.ml b/infer/src/checkers/functionPointers.ml index bc7a92b65..c6bde9bac 100644 --- a/infer/src/checkers/functionPointers.ml +++ b/infer/src/checkers/functionPointers.ml @@ -9,9 +9,9 @@ open! IStd module F = Format module Procname = struct - type t = Typ.Procname.t [@@deriving compare] + type t = Procname.t [@@deriving compare] - let pp = Typ.Procname.pp + let pp = Procname.pp end module ProcnameSet = AbstractDomain.FiniteSet (Procname) diff --git a/infer/src/checkers/hoisting.ml b/infer/src/checkers/hoisting.ml index 07d99dce0..36fa4a474 100644 --- a/infer/src/checkers/hoisting.ml +++ b/infer/src/checkers/hoisting.ml @@ -12,14 +12,14 @@ module BasicCost = CostDomain.BasicCost module Call = struct type t = { loc: Location.t - ; pname: Typ.Procname.t + ; pname: Procname.t ; node: Procdesc.Node.t ; params: (Exp.t * Typ.t) list ; ret: Ident.t * Typ.t } [@@deriving compare] let pp fmt {pname; loc} = - F.fprintf fmt "loop-invariant call to %a, at %a " Typ.Procname.pp pname Location.pp loc + F.fprintf fmt "loop-invariant call to %a, at %a " Procname.pp pname Location.pp loc end module LoopNodes = AbstractDomain.FiniteSet (Procdesc.Node) @@ -72,7 +72,7 @@ let get_hoist_inv_map tenv ~get_callee_purity reaching_defs_invariant_map loop_h let do_report extract_cost_if_expensive summary (Call.{pname; loc} as call) loop_head_loc = let exp_desc = - F.asprintf "The call to %a at %a is loop-invariant" Typ.Procname.pp pname Location.pp loc + F.asprintf "The call to %a at %a is loop-invariant" Procname.pp pname Location.pp loc in let loop_inv_trace_elem = Errlog.make_trace_element 0 loc exp_desc [] in let issue, cost_msg, ltr = diff --git a/infer/src/checkers/impurity.ml b/infer/src/checkers/impurity.ml index 63c7e7c1f..c168e9c3d 100644 --- a/infer/src/checkers/impurity.ml +++ b/infer/src/checkers/impurity.ml @@ -123,7 +123,7 @@ let report_errors summary modified_opt = let pdesc = Summary.get_proc_desc summary in let proc_name = Procdesc.get_proc_name pdesc in let pname_loc = Procdesc.get_loc pdesc in - let impure_fun_desc = F.asprintf "Impure function %a" Typ.Procname.pp proc_name in + let impure_fun_desc = F.asprintf "Impure function %a" Procname.pp proc_name in let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in ( match modified_opt with | None -> diff --git a/infer/src/checkers/inefficientKeysetIterator.ml b/infer/src/checkers/inefficientKeysetIterator.ml index 960fb27fc..fa5cb8419 100644 --- a/infer/src/checkers/inefficientKeysetIterator.ml +++ b/infer/src/checkers/inefficientKeysetIterator.ml @@ -19,8 +19,8 @@ let find_loaded_pvar id = function let find_first_arg_id ~fun_name ~class_name_f ~lhs_f = function | Sil.Call ((lhs_id, _), Exp.Const (Const.Cfun pname), (Exp.Var rhs_id, _) :: _, _, _) when lhs_f lhs_id - && String.equal fun_name (Typ.Procname.get_method pname) - && Typ.Procname.get_class_name pname |> Option.exists ~f:class_name_f -> + && String.equal fun_name (Procname.get_method pname) + && Procname.get_class_name pname |> Option.exists ~f:class_name_f -> Some rhs_id | _ -> None @@ -35,7 +35,7 @@ let implements_map tenv s = {v n$X = *&$bcvarY - _ = *n$X + _ = *n$X n$X+1 = fun_name(n$X,....) *&$irvarZ = n$X+1 v} *) diff --git a/infer/src/checkers/liveness.ml b/infer/src/checkers/liveness.ml index 6c89aa634..a30879376 100644 --- a/infer/src/checkers/liveness.ml +++ b/infer/src/checkers/liveness.ml @@ -37,7 +37,7 @@ let string_list_of_json ~option_name ~init = function module type LivenessConfig = sig - val is_blacklisted_destructor : Typ.Procname.t -> bool + val is_blacklisted_destructor : Procname.t -> bool end (** Use this config to get a reliable liveness pre-analysis that tells you which variables are live @@ -77,9 +77,9 @@ module CheckerMode : LivenessConfig = struct false - let is_blacklisted_destructor (callee_pname : Typ.Procname.t) = + let is_blacklisted_destructor (callee_pname : Procname.t) = match callee_pname with - | ObjC_Cpp cpp_pname when Typ.Procname.ObjC_Cpp.is_destructor cpp_pname -> + | ObjC_Cpp cpp_pname when Procname.ObjC_Cpp.is_destructor cpp_pname -> is_blacklisted_class_name cpp_pname.class_name || is_wrapper_of_blacklisted_class_name cpp_pname.class_name | _ -> @@ -111,8 +111,7 @@ module TransferFunctions (LConfig : LivenessConfig) (CFG : ProcCfg.S) = struct in let actuals = List.map actuals ~f:(fun (e, _) -> Exp.ignore_cast e) in match Exp.ignore_cast call_exp with - | Exp.Const (Cfun (Typ.Procname.ObjC_Cpp _ as pname)) when Typ.Procname.is_constructor pname - -> ( + | Exp.Const (Cfun (Procname.ObjC_Cpp _ as pname)) when Procname.is_constructor pname -> ( (* first actual passed to a C++ constructor is actually written, not read *) match actuals with | Exp.Lvar pvar :: exps -> @@ -141,7 +140,7 @@ module TransferFunctions (LConfig : LivenessConfig) (CFG : ProcCfg.S) = struct exp_add_live exp astate | Sil.Call ((ret_id, _), Const (Cfun callee_pname), _, _, _) when LConfig.is_blacklisted_destructor callee_pname -> - Logging.d_printfln_escaped "Blacklisted destructor %a, ignoring reads@\n" Typ.Procname.pp + Logging.d_printfln_escaped "Blacklisted destructor %a, ignoring reads@\n" Procname.pp callee_pname ; Domain.remove (Var.of_id ret_id) astate | Sil.Call ((ret_id, _), call_exp, actuals, _, {CallFlags.cf_assign_last_arg}) -> @@ -268,9 +267,9 @@ let checker {Callbacks.exe_env; summary} : Summary.t = log_report pvar typ loc | Sil.Call (_, e_fun, (arg, typ) :: _, loc, _) -> ( match (Exp.ignore_cast e_fun, Exp.ignore_cast arg) with - | Exp.Const (Cfun (Typ.Procname.ObjC_Cpp _ as pname)), Exp.Lvar pvar - when Typ.Procname.is_constructor pname - && should_report pvar typ live_vars captured_by_ref_vars -> + | Exp.Const (Cfun (Procname.ObjC_Cpp _ as pname)), Exp.Lvar pvar + when Procname.is_constructor pname && should_report pvar typ live_vars captured_by_ref_vars + -> log_report pvar typ loc | _, _ -> () ) diff --git a/infer/src/checkers/loopInvariant.ml b/infer/src/checkers/loopInvariant.ml index 07110ceab..efdfd2208 100644 --- a/infer/src/checkers/loopInvariant.ml +++ b/infer/src/checkers/loopInvariant.ml @@ -33,7 +33,7 @@ let get_purity tenv ~is_pure_by_default ~get_callee_purity callee_pname = | Some callee_purity -> callee_purity | None -> ( - debug "No model for %a \n" Typ.Procname.pp callee_pname ; + debug "No model for %a \n" Procname.pp callee_pname ; (* If there is no model, invoke purity analysis to see if function is pure *) match get_callee_purity callee_pname with | Some purity_summary -> diff --git a/infer/src/checkers/loopInvariant.mli b/infer/src/checkers/loopInvariant.mli index 1e46646cc..a6c25c245 100644 --- a/infer/src/checkers/loopInvariant.mli +++ b/infer/src/checkers/loopInvariant.mli @@ -28,15 +28,14 @@ val get_inv_vars_in_loop : -> ReachingDefs.invariant_map -> is_pure_by_default:bool -> get_callee_purity: - ( Typ.Procname.t - -> PurityDomain.ModifiedParamIndices.t AbstractDomain.Types.top_lifted option) + (Procname.t -> PurityDomain.ModifiedParamIndices.t AbstractDomain.Types.top_lifted option) -> Procdesc.Node.t -> LoopNodes.t -> VarSet.t val get_loop_inv_var_map : Tenv.t - -> (Typ.Procname.t -> PurityDomain.ModifiedParamIndices.t AbstractDomain.Types.top_lifted option) + -> (Procname.t -> PurityDomain.ModifiedParamIndices.t AbstractDomain.Types.top_lifted option) -> ReachingDefs.invariant_map -> LoopNodes.t LoopHeadToInvVars.t -> invariant_map diff --git a/infer/src/checkers/printfArgs.ml b/infer/src/checkers/printfArgs.ml index d9fe222f3..7e25ab606 100644 --- a/infer/src/checkers/printfArgs.ml +++ b/infer/src/checkers/printfArgs.ml @@ -29,9 +29,9 @@ let printf_like_functions = ; vararg_pos= Some 3 } ] -let printf_like_function (proc_name : Typ.Procname.t) : printf_signature option = +let printf_like_function (proc_name : Procname.t) : printf_signature option = List.find - ~f:(fun printf -> String.equal printf.unique_id (Typ.Procname.to_unique_id proc_name)) + ~f:(fun printf -> String.equal printf.unique_id (Procname.to_unique_id proc_name)) !printf_like_functions @@ -97,11 +97,11 @@ let rec format_string_type_names (fmt_string : string) (start : int) : string li with Caml.Not_found -> [] -let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) - (proc_name : Typ.Procname.t) (proc_desc : Procdesc.t) summary : unit = +let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc_name : Procname.t) + (proc_desc : Procdesc.t) summary : 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 = Typ.Procname.to_simplified_string instr_proc_name in + let instr_name = 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 -> @@ -160,9 +160,8 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) "Format string must be string literal" with e -> L.internal_error "%s Exception when analyzing %s: %s@." - IssueType.checkers_printf_args.unique_id - (Typ.Procname.to_string proc_name) - (Exn.to_string e) ) + IssueType.checkers_printf_args.unique_id (Procname.to_string proc_name) (Exn.to_string e) + ) | None -> () ) | _ -> diff --git a/infer/src/checkers/purity.ml b/infer/src/checkers/purity.ml index 4c5c446ac..1e699debb 100644 --- a/infer/src/checkers/purity.ml +++ b/infer/src/checkers/purity.ml @@ -23,7 +23,7 @@ end) type purity_extras = { inferbo_invariant_map: BufferOverrunAnalysis.invariant_map ; formals: Var.t list - ; get_callee_summary: Typ.Procname.t -> PurityDomain.summary option } + ; get_callee_summary: Procname.t -> PurityDomain.summary option } module TransferFunctions = struct module CFG = ProcCfg.Normal @@ -166,11 +166,11 @@ module TransferFunctions = struct | None -> ( match get_callee_summary called_pname with | Some callee_summary -> - debug "Reading from %a \n" Typ.Procname.pp called_pname ; + debug "Reading from %a \n" Procname.pp called_pname ; find_modified_if_impure inferbo_mem formals args callee_summary | None -> - if Typ.Procname.is_constructor called_pname then Domain.pure - else Domain.impure_global ) ) + if Procname.is_constructor called_pname then Domain.pure else Domain.impure_global ) + ) | Call (_, Indirect _, _, _, _) -> (* This should never happen in Java *) debug "Unexpected indirect call %a" HilInstr.pp instr ; @@ -186,17 +186,16 @@ module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions) let should_report pdesc = let proc_name = Procdesc.get_proc_name pdesc in - (not (Typ.Procname.is_constructor proc_name)) + (not (Procname.is_constructor proc_name)) && match proc_name with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> not - ( Typ.Procname.Java.is_class_initializer java_pname - || Typ.Procname.Java.is_access_method java_pname ) - | Typ.Procname.ObjC_Cpp name -> + (Procname.Java.is_class_initializer java_pname || Procname.Java.is_access_method java_pname) + | Procname.ObjC_Cpp name -> not - ( Typ.Procname.ObjC_Cpp.is_destructor name - || Typ.Procname.ObjC_Cpp.is_objc_constructor name.method_name ) + ( Procname.ObjC_Cpp.is_destructor name + || Procname.ObjC_Cpp.is_objc_constructor name.method_name ) | _ -> true @@ -208,11 +207,11 @@ let report_errors astate summary = | Some astate -> if should_report pdesc && PurityDomain.is_pure astate then let loc = Procdesc.get_loc pdesc in - let exp_desc = F.asprintf "Side-effect free function %a" Typ.Procname.pp proc_name in + let exp_desc = F.asprintf "Side-effect free function %a" Procname.pp proc_name in let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in Reporting.log_error summary ~loc ~ltr IssueType.pure_function exp_desc | None -> - L.internal_error "Analyzer failed to compute purity information for %a@." Typ.Procname.pp + L.internal_error "Analyzer failed to compute purity information for %a@." Procname.pp proc_name diff --git a/infer/src/checkers/purityModels.ml b/infer/src/checkers/purityModels.ml index 80f53f658..ac55c4276 100644 --- a/infer/src/checkers/purityModels.ml +++ b/infer/src/checkers/purityModels.ml @@ -43,7 +43,7 @@ module ProcName = struct ; -"__new_array" <>--> PurityDomain.pure ; -"__cast" <>--> PurityDomain.pure ; -"__variable_initialization" <>--> PurityDomain.pure - ; +(fun _ name -> BuiltinDecl.is_declared (Typ.Procname.from_string_c_fun name)) + ; +(fun _ name -> BuiltinDecl.is_declared (Procname.from_string_c_fun name)) <>--> PurityDomain.impure_global ; +PatternMatch.implements_android "text.TextUtils" &:: "isEmpty" <>--> PurityDomain.pure ; +PatternMatch.implements_android "view.ViewGroup" &:: "getChildAt" <>--> PurityDomain.pure diff --git a/infer/src/checkers/uninit.ml b/infer/src/checkers/uninit.ml index f28bc0f69..878277fd3 100644 --- a/infer/src/checkers/uninit.ml +++ b/infer/src/checkers/uninit.ml @@ -25,7 +25,7 @@ module Models = struct let initializing_all_args = [BuiltinDecl.__set_array_length] let is_initializing_all_args pname = - List.exists initializing_all_args ~f:(fun fname -> Typ.Procname.equal pname fname) + List.exists initializing_all_args ~f:(fun fname -> Procname.equal pname fname) end let should_report_on_type t = @@ -122,7 +122,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | _ -> false in - Typ.Procname.is_constructor call && is_dummy_constructor_of_struct + Procname.is_constructor call && is_dummy_constructor_of_struct let is_pointer_assignment tenv lhs rhs = @@ -225,7 +225,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let prepost = update_prepost lhs_access_expr rhs_expr in {astate with maybe_uninit_vars; prepost} | Call (_, Direct callee_pname, _, _, _) - when Typ.Procname.equal callee_pname BuiltinDecl.objc_cpp_throw -> + when Procname.equal callee_pname BuiltinDecl.objc_cpp_throw -> {astate with maybe_uninit_vars= MaybeUninitVars.empty} | Call (_, HilInstr.Direct call, [HilExp.AccessExpression (AddressOf (Base base))], _, _) when is_dummy_constructor_of_a_struct call -> @@ -270,7 +270,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct remove_initialized_params summary pname acc idx access_expr_to_remove false | _ -> MaybeUninitVars.remove access_expr_to_remove acc ) - | base when Option.exists pname_opt ~f:Typ.Procname.is_constructor -> + | base when Option.exists pname_opt ~f:Procname.is_constructor -> MaybeUninitVars.remove_all_fields tenv base (MaybeUninitVars.remove access_expr_to_remove acc) | _, {Typ.desc= Tptr _} -> ( diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 5e7a39d32..ddef6a2cd 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -374,8 +374,8 @@ let get_record_definition decl = let mk_objc_method class_typename method_name method_kind parameters = - Typ.Procname.ObjC_Cpp - (Typ.Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate parameters) + Procname.ObjC_Cpp + (Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate parameters) let rec get_mangled_method_name function_decl_info method_decl_info = @@ -579,9 +579,8 @@ and mk_c_function ?tenv name function_decl_info_opt parameters = Typ.NoTemplate in let mangled = file ^ mangled_name in - if String.is_empty mangled then - Typ.Procname.from_string_c_fun (QualifiedCppName.to_qual_string name) - else Typ.Procname.C (Typ.Procname.C.c name mangled parameters template_info) + if String.is_empty mangled then Procname.from_string_c_fun (QualifiedCppName.to_qual_string name) + else Procname.C (Procname.C.c name mangled parameters template_info) and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled parameters = @@ -589,11 +588,11 @@ and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled parameters = let method_kind = match meth_decl with | Some (Clang_ast_t.CXXConstructorDecl (_, _, _, _, {xmdi_is_constexpr})) -> - Typ.Procname.ObjC_Cpp.CPPConstructor {mangled; is_constexpr= xmdi_is_constexpr} + Procname.ObjC_Cpp.CPPConstructor {mangled; is_constexpr= xmdi_is_constexpr} | Some (Clang_ast_t.CXXDestructorDecl _) -> - Typ.Procname.ObjC_Cpp.CPPDestructor {mangled} + Procname.ObjC_Cpp.CPPDestructor {mangled} | _ -> - Typ.Procname.ObjC_Cpp.CPPMethod {mangled} + Procname.ObjC_Cpp.CPPMethod {mangled} in let template_info = match meth_decl with @@ -606,8 +605,8 @@ and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled parameters = | _ -> Typ.NoTemplate in - Typ.Procname.ObjC_Cpp - (Typ.Procname.ObjC_Cpp.make class_name method_name method_kind template_info parameters) + Procname.ObjC_Cpp + (Procname.ObjC_Cpp.make class_name method_name method_kind template_info parameters) and get_class_typename ?tenv method_decl_info = @@ -623,18 +622,18 @@ and get_class_typename ?tenv method_decl_info = and objc_method_procname ?tenv decl_info method_name mdi = let class_typename = get_class_typename ?tenv decl_info in let is_instance = mdi.Clang_ast_t.omdi_is_instance_method in - let method_kind = Typ.Procname.ObjC_Cpp.objc_method_kind_of_bool is_instance in + let method_kind = Procname.ObjC_Cpp.objc_method_kind_of_bool is_instance in mk_objc_method class_typename method_name method_kind and objc_block_procname outer_proc_opt parameters = - let outer_proc_string = Option.value_map ~f:Typ.Procname.to_string outer_proc_opt ~default:"" in + let outer_proc_string = Option.value_map ~f:Procname.to_string outer_proc_opt ~default:"" in let block_procname_with_index i = Printf.sprintf "%s%s%s%d" Config.anonymous_block_prefix outer_proc_string Config.anonymous_block_num_sep i in let name = block_procname_with_index (CFrontend_config.get_fresh_block_index ()) in - Typ.Procname.Block (Typ.Procname.Block.make name parameters) + Procname.Block (Procname.Block.make name parameters) and procname_from_decl ?tenv ?block_return_type ?outer_proc meth_decl = @@ -652,7 +651,7 @@ and procname_from_decl ?tenv ?block_return_type ?outer_proc meth_decl = let captured_vars_types = BuildMethodSignature.types_of_captured_vars qual_type_to_sil_type tenv meth_decl in - List.map ~f:Typ.Procname.Parameter.of_typ (captured_vars_types @ parameter_types) + List.map ~f:Procname.Parameter.of_typ (captured_vars_types @ parameter_types) | None -> [] in @@ -773,7 +772,7 @@ module CProcname = struct in objc_method_procname decl_info method_name mdi [] | BlockDecl _ -> - Typ.Procname.Block (Typ.Procname.Block.make Config.anonymous_block_prefix []) + Procname.Block (Procname.Block.make Config.anonymous_block_prefix []) | _ -> from_decl method_decl end diff --git a/infer/src/clang/CType_decl.mli b/infer/src/clang/CType_decl.mli index 850a3f3ef..7aac630ed 100644 --- a/infer/src/clang/CType_decl.mli +++ b/infer/src/clang/CType_decl.mli @@ -11,13 +11,13 @@ module CProcname : sig val from_decl : ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type - -> ?outer_proc:Typ.Procname.t + -> ?outer_proc:Procname.t -> Clang_ast_t.decl - -> Typ.Procname.t + -> Procname.t (** Given decl, return its procname. This function should be used for all procedures present in original AST *) - val from_decl_for_linters : Clang_ast_t.decl -> Typ.Procname.t + val from_decl_for_linters : Clang_ast_t.decl -> Procname.t (** This is used for bug hashing for linters. In ObjC the method names contain the parameter names, thus if people add new parameters, any bug about the method will be considered different which means reporting on unchanged code. So, in the ObjC method case, we create the @@ -25,12 +25,11 @@ module CProcname : sig (** WARNING: functions from this module should not be used if full decl is available in AST *) module NoAstDecl : sig - val c_function_of_string : Tenv.t -> string -> Typ.Procname.t + val c_function_of_string : Tenv.t -> string -> Procname.t - val cpp_method_of_string : Tenv.t -> Typ.Name.t -> string -> Typ.Procname.t + val cpp_method_of_string : Tenv.t -> Typ.Name.t -> string -> Procname.t - val objc_method_of_string_kind : - Typ.Name.t -> string -> Typ.Procname.ObjC_Cpp.kind -> Typ.Procname.t + val objc_method_of_string_kind : Typ.Name.t -> string -> Procname.ObjC_Cpp.kind -> Procname.t end end @@ -54,14 +53,14 @@ val method_signature_of_decl : Tenv.t -> Clang_ast_t.decl -> ?block_return_type:Clang_ast_t.qual_type - -> Typ.Procname.t + -> Procname.t -> CMethodSignature.t val method_signature_body_of_decl : Tenv.t -> Clang_ast_t.decl -> ?block_return_type:Clang_ast_t.qual_type - -> Typ.Procname.t + -> Procname.t -> CMethodSignature.t * Clang_ast_t.stmt option * [> `CXXConstructorInit of Clang_ast_t.cxx_ctor_initializer] list diff --git a/infer/src/clang/astToRangeMap.ml b/infer/src/clang/astToRangeMap.ml index 63b29ebad..261d3e6af 100644 --- a/infer/src/clang/astToRangeMap.ml +++ b/infer/src/clang/astToRangeMap.ml @@ -6,10 +6,10 @@ *) open! IStd -(* Builds a clang procedure, following the format required to match with profiler samples: -C Functions: name, mangled name optional -ObjC Methods: mangled_name -ObjC Blocks: mangled_name +(* Builds a clang procedure, following the format required to match with profiler samples: +C Functions: name, mangled name optional +ObjC Methods: mangled_name +ObjC Blocks: mangled_name C++ methods: mangled_name (For us mangled name is optional, but if it is not there then we can't match the method) *) let clang_proc_of_decl decl = let open Clang_ast_t in @@ -63,7 +63,7 @@ and process_proc_decl default_source_file ast_range decl = let range = CLocation.location_of_decl_info default_source_file di in let procname = CType_decl.CProcname.from_decl decl in let clang_proc = clang_proc_of_decl decl in - let ast_range' = Typ.Procname.Map.add procname (range, clang_proc) ast_range in + let ast_range' = Procname.Map.add procname (range, clang_proc) ast_range in match CAst_utils.get_method_body_opt decl with | Some stmt -> process_block_decls_in_stmts default_source_file ast_range' [stmt] @@ -81,7 +81,7 @@ let process_ast ast default_source_file = let open Clang_ast_t in match ast with | TranslationUnitDecl (_, decl_list, _, _) -> - List.fold decl_list ~init:Typ.Procname.Map.empty ~f:(fun map decl -> + List.fold decl_list ~init:Procname.Map.empty ~f:(fun map decl -> let info = Clang_ast_proj.get_decl_tuple decl in let source_range = info.di_source_range in if diff --git a/infer/src/clang/astToRangeMap.mli b/infer/src/clang/astToRangeMap.mli index d3c7bcc09..a48401d4b 100644 --- a/infer/src/clang/astToRangeMap.mli +++ b/infer/src/clang/astToRangeMap.mli @@ -9,4 +9,4 @@ open! IStd val process_ast : Clang_ast_t.decl -> SourceFile.t - -> ((Location.t * Location.t) * ClangProc.t option) Typ.Procname.Map.t + -> ((Location.t * Location.t) * ClangProc.t option) Procname.Map.t diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index 979072d67..2a2dfda0f 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -16,9 +16,9 @@ type qual_type_to_sil_type = Tenv.t -> Clang_ast_t.qual_type -> Typ.t type procname_from_decl = ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type - -> ?outer_proc:Typ.Procname.t + -> ?outer_proc:Procname.t -> Clang_ast_t.decl - -> Typ.Procname.t + -> Procname.t let sanitize_name s = Str.global_replace (Str.regexp "[/ ]") "_" s diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index d84ee6e2b..2d05eb7d9 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -66,9 +66,9 @@ type qual_type_to_sil_type = Tenv.t -> Clang_ast_t.qual_type -> Typ.t type procname_from_decl = ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type - -> ?outer_proc:Typ.Procname.t + -> ?outer_proc:Procname.t -> Clang_ast_t.decl - -> Typ.Procname.t + -> Procname.t val qual_type_of_decl_ptr : Clang_ast_t.pointer -> Clang_ast_t.qual_type diff --git a/infer/src/clang/cContext.ml b/infer/src/clang/cContext.ml index e9c09e139..f7b61a6a7 100644 --- a/infer/src/clang/cContext.ml +++ b/infer/src/clang/cContext.ml @@ -23,7 +23,7 @@ type t = ; immediate_curr_class: curr_class ; return_param_typ: Typ.t option ; outer_context: t option - ; mutable blocks_static_vars: (Pvar.t * Typ.t) list Typ.Procname.Map.t + ; mutable blocks_static_vars: (Pvar.t * Typ.t) list Procname.Map.t ; label_map: str_node_map ; vars_to_destroy: Clang_ast_t.decl list StmtMap.t ; temporary_names: (Clang_ast_t.pointer, Pvar.t * Typ.t) Hashtbl.t } @@ -37,7 +37,7 @@ let create_context translation_unit_context tenv cfg procdesc immediate_curr_cla ; immediate_curr_class ; return_param_typ ; outer_context - ; blocks_static_vars= Typ.Procname.Map.empty + ; blocks_static_vars= Procname.Map.empty ; label_map= Hashtbl.create 17 ; vars_to_destroy ; temporary_names= Hashtbl.create 0 } @@ -48,7 +48,7 @@ let rec is_objc_method context = | Some outer_context -> is_objc_method outer_context | None -> - context.procdesc |> Procdesc.get_proc_name |> Typ.Procname.is_objc_method + context.procdesc |> Procdesc.get_proc_name |> Procname.is_objc_method let rec is_objc_class_method context = @@ -110,7 +110,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 = Typ.Procname.Map.find block_name outer_context.blocks_static_vars in + let static_vars = Procname.Map.find block_name outer_context.blocks_static_vars in if List.mem ~equal:(fun (var1, _) (var2, _) -> Pvar.equal var1 var2) @@ -121,7 +121,7 @@ let add_block_static_var context block_name static_var_typ = in if not duplicate then let blocks_static_vars = - Typ.Procname.Map.add block_name new_static_vars outer_context.blocks_static_vars + Procname.Map.add block_name new_static_vars outer_context.blocks_static_vars in outer_context.blocks_static_vars <- blocks_static_vars | _ -> diff --git a/infer/src/clang/cContext.mli b/infer/src/clang/cContext.mli index bf6843eb2..5729abcb0 100644 --- a/infer/src/clang/cContext.mli +++ b/infer/src/clang/cContext.mli @@ -25,7 +25,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 Typ.Procname.Map.t + ; mutable blocks_static_vars: (Pvar.t * Typ.t) list Procname.Map.t ; label_map: str_node_map ; vars_to_destroy: Clang_ast_t.decl list StmtMap.t (** mapping from a statement to a list of variables, that go out of scope after the end of @@ -53,6 +53,6 @@ val create_context : -> Clang_ast_t.decl list StmtMap.t -> t -val add_block_static_var : t -> Typ.Procname.t -> Pvar.t * Typ.t -> unit +val add_block_static_var : t -> Procname.t -> Pvar.t * Typ.t -> unit -val get_outer_procname : t -> Typ.Procname.t +val get_outer_procname : t -> Procname.t diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 6e8a8f1ec..123fb1fc1 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -21,24 +21,24 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron let add_method ?(is_destructor_wrapper = false) trans_unit_ctx tenv cfg class_decl_opt procname body ms has_return_param outer_context_opt extra_instrs = L.(debug Capture Verbose) - "@\n@\n>>---------- ADDING METHOD: '%a' ---------<<@\n@\n" Typ.Procname.pp procname ; + "@\n@\n>>---------- ADDING METHOD: '%a' ---------<<@\n@\n" Procname.pp procname ; incr CFrontend_config.procedures_attempted ; let recover () = incr CFrontend_config.procedures_failed ; - Typ.Procname.Hash.remove cfg procname ; + Procname.Hash.remove cfg procname ; let method_kind = ms.CMethodSignature.method_kind in CMethod_trans.create_external_procdesc trans_unit_ctx cfg procname method_kind None in let pp_context fmt () = - F.fprintf fmt "Aborting translation of method '%a' in file '%a'" Typ.Procname.pp procname + F.fprintf fmt "Aborting translation of method '%a' in file '%a'" Procname.pp procname SourceFile.pp trans_unit_ctx.CFrontend_config.source_file in let f () = - match Typ.Procname.Hash.find cfg procname with + match Procname.Hash.find cfg procname with | procdesc when Procdesc.is_defined procdesc && not (model_exists procname) -> ( L.(debug Capture Verbose) "@\n@\n>>---------- Start translating body of function: '%s' ---------<<@\n@." - (Typ.Procname.to_string procname) ; + (Procname.to_string procname) ; let vars_to_destroy = CScope.Variables.compute_vars_to_destroy_map body in let context = CContext.create_context trans_unit_ctx tenv cfg procdesc class_decl_opt has_return_param @@ -123,10 +123,10 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron add_method trans_unit_ctx tenv cfg curr_class procname body ms return_param_typ_opt None extra_instrs ~is_destructor_wrapper:true ; let new_method_name = - Config.clang_inner_destructor_prefix ^ Typ.Procname.get_method procname + Config.clang_inner_destructor_prefix ^ Procname.get_method procname in let ms' = - {ms with name= Typ.Procname.objc_cpp_replace_method_name procname new_method_name} + {ms with name= Procname.objc_cpp_replace_method_name procname new_method_name} in let procname' = ms'.CMethodSignature.name in (ms', procname') ) diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index 411114fce..de1899533 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -29,9 +29,7 @@ let append_no_duplicates_annotations = Staged.unstage (IList.append_no_duplicates ~cmp) -let append_no_duplicates_methods = - Staged.unstage (IList.append_no_duplicates ~cmp:Typ.Procname.compare) - +let append_no_duplicates_methods = Staged.unstage (IList.append_no_duplicates ~cmp:Procname.compare) let add_no_duplicates_fields field_tuple l = let rec replace_field field_tuple l found = @@ -155,8 +153,7 @@ let mk_sil_var trans_unit_ctx named_decl_info decl_info_qual_type_opt procname o if var_decl_info.Clang_ast_t.vdi_is_static_local then Some (fun name_string _ -> - Mangled.from_string (F.asprintf "%a.%s" Typ.Procname.pp outer_procname name_string) - ) + Mangled.from_string (F.asprintf "%a.%s" Procname.pp outer_procname name_string) ) else None in mk_sil_global_var trans_unit_ctx ?mk_name decl_info named_decl_info var_decl_info qt diff --git a/infer/src/clang/cGeneral_utils.mli b/infer/src/clang/cGeneral_utils.mli index a83fcf04d..64c9ed749 100644 --- a/infer/src/clang/cGeneral_utils.mli +++ b/infer/src/clang/cGeneral_utils.mli @@ -15,7 +15,7 @@ val add_no_duplicates_fields : Struct.field -> Struct.field list -> Struct.field val append_no_duplicates_fields : Struct.field list -> Struct.field list -> Struct.field list -val append_no_duplicates_methods : Typ.Procname.t list -> Typ.Procname.t list -> Typ.Procname.t list +val append_no_duplicates_methods : Procname.t list -> Procname.t list -> Procname.t list val swap_elements_list : 'a list -> 'a list @@ -42,8 +42,8 @@ val mk_sil_var : CFrontend_config.translation_unit_context -> Clang_ast_t.named_decl_info -> var_info option - -> Typ.Procname.t - -> Typ.Procname.t + -> Procname.t + -> Procname.t -> Pvar.t val is_cpp_translation : CFrontend_config.translation_unit_context -> bool diff --git a/infer/src/clang/cMethodSignature.ml b/infer/src/clang/cMethodSignature.ml index 697b84605..b32b2db64 100644 --- a/infer/src/clang/cMethodSignature.ml +++ b/infer/src/clang/cMethodSignature.ml @@ -19,7 +19,7 @@ let mk_param_type ?(is_pointer_to_const = false) ?(annot = Annot.Item.empty) nam type t = - { name: Typ.Procname.t + { name: Procname.t ; access: Clang_ast_t.access_specifier ; class_param: param_type option ; params: param_type list @@ -73,7 +73,7 @@ let mk name class_param params ret_type ?(has_added_return_param = false) attrib let pp fmt ms = let pp_param fmt {name; typ} = F.fprintf fmt "%a, %a" Mangled.pp name (Typ.pp Pp.text) typ in Format.fprintf fmt "Method %a [%a]->%a %a" - (Pp.of_string ~f:Typ.Procname.to_string) + (Pp.of_string ~f:Procname.to_string) ms.name (Pp.comma_seq pp_param) ms.params (Typ.pp Pp.text) (fst ms.ret_type) (Pp.of_string ~f:Clang_ast_j.string_of_source_range) ms.loc diff --git a/infer/src/clang/cMethodSignature.mli b/infer/src/clang/cMethodSignature.mli index b63f62cd8..7a9a2e8d5 100644 --- a/infer/src/clang/cMethodSignature.mli +++ b/infer/src/clang/cMethodSignature.mli @@ -13,7 +13,7 @@ open! IStd type param_type = {name: Mangled.t; typ: Typ.t; is_pointer_to_const: bool; annot: Annot.Item.t} type t = - { name: Typ.Procname.t + { name: Procname.t ; access: Clang_ast_t.access_specifier ; class_param: param_type option ; params: param_type list @@ -36,7 +36,7 @@ val is_getter : t -> bool val is_setter : t -> bool val mk : - Typ.Procname.t + Procname.t -> param_type option -> param_type list -> Typ.t * Annot.Item.t diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index e8b66f6b9..846cdabfe 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -41,7 +41,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 = ms.CMethodSignature.name in - let new_procname = Typ.Procname.replace_class procname class_typename in + let new_procname = Procname.replace_class procname class_typename in Some new_procname | None -> Some ms.CMethodSignature.name ) @@ -82,8 +82,8 @@ let get_class_name_method_call_from_clang tenv obj_c_message_expr_info = match method_signature_of_pointer tenv pointer with | Some ms -> ( match ms.CMethodSignature.name with - | Typ.Procname.ObjC_Cpp objc_cpp -> - Some (Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp) + | Procname.ObjC_Cpp objc_cpp -> + Some (Procname.ObjC_Cpp.get_class_type_name objc_cpp) | _ -> None ) | None -> @@ -123,12 +123,11 @@ let get_objc_method_data obj_c_message_expr_info = let should_create_procdesc cfg procname defined set_objc_accessor_attr = - match Typ.Procname.Hash.find cfg procname with + match Procname.Hash.find cfg procname with | previous_procdesc -> let is_defined_previous = Procdesc.is_defined previous_procdesc in if (defined || set_objc_accessor_attr) && not is_defined_previous then ( - Typ.Procname.Hash.remove cfg procname ; - true ) + Procname.Hash.remove cfg procname ; true ) else false | exception Caml.Not_found -> true @@ -224,7 +223,7 @@ let create_local_procdesc ?(set_objc_accessor_attr = false) trans_unit_ctx cfg t let const_formals = get_const_params_indices ~shift:(List.length captured_mangled) all_params in let source_range = ms.CMethodSignature.loc in L.(debug Capture Verbose) - "@\nCreating a new procdesc for function: '%a'@\n@." Typ.Procname.pp proc_name ; + "@\nCreating a new procdesc for function: '%a'@\n@." Procname.pp proc_name ; L.(debug Capture Verbose) "@\nms = %a@\n@." CMethodSignature.pp ms ; let loc_start = CLocation.location_of_source_range trans_unit_ctx.CFrontend_config.source_file source_range @@ -273,7 +272,7 @@ let create_local_procdesc ?(set_objc_accessor_attr = false) trans_unit_ctx cfg t (** Create a procdesc for objc methods whose signature cannot be found. *) let create_external_procdesc trans_unit_ctx cfg proc_name clang_method_kind type_opt = - if not (Typ.Procname.Hash.mem cfg proc_name) then + if not (Procname.Hash.mem cfg proc_name) then let ret_type, formals = match type_opt with | Some (ret_type, arg_types) -> diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index ae385e366..9b836d37e 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -31,7 +31,7 @@ val create_local_procdesc : val create_external_procdesc : CFrontend_config.translation_unit_context -> Cfg.t - -> Typ.Procname.t + -> Procname.t -> ClangMethodKind.t -> (Typ.t * Typ.t list) option -> unit @@ -47,11 +47,11 @@ val get_class_name_method_call_from_clang : val method_signature_of_pointer : Tenv.t -> Clang_ast_t.pointer -> CMethodSignature.t option -val get_method_name_from_clang : Tenv.t -> CMethodSignature.t option -> Typ.Procname.t option +val get_method_name_from_clang : Tenv.t -> CMethodSignature.t option -> Procname.t option val create_procdesc_with_pointer : - CContext.t -> Clang_ast_t.pointer -> Typ.Name.t option -> string -> Typ.Procname.t + CContext.t -> Clang_ast_t.pointer -> Typ.Name.t option -> string -> Procname.t -val get_procname_from_cpp_lambda : CContext.t -> Clang_ast_t.decl -> Typ.Procname.t +val get_procname_from_cpp_lambda : CContext.t -> Clang_ast_t.decl -> Procname.t val get_captures_from_cpp_lambda : Clang_ast_t.decl -> Clang_ast_t.lambda_capture_info list diff --git a/infer/src/clang/cModule_type.ml b/infer/src/clang/cModule_type.ml index 9a05edc3c..ae524d650 100644 --- a/infer/src/clang/cModule_type.ml +++ b/infer/src/clang/cModule_type.ml @@ -7,7 +7,7 @@ open! IStd -type block_data = CContext.t * Clang_ast_t.qual_type * Typ.Procname.t * (Pvar.t * Typ.t) list +type block_data = CContext.t * Clang_ast_t.qual_type * Procname.t * (Pvar.t * Typ.t) list type instr_type = [`ClangStmt of Clang_ast_t.stmt | `CXXConstructorInit of Clang_ast_t.cxx_ctor_initializer] diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index ecfb93e7e..febdac2b3 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -28,7 +28,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s CMethod_trans.get_objc_method_data obj_c_message_expr_info in let is_instance = mc_type <> CMethod_trans.MCStatic in - let objc_method_kind = Typ.Procname.ObjC_Cpp.objc_method_kind_of_bool is_instance in + let objc_method_kind = Procname.ObjC_Cpp.objc_method_kind_of_bool is_instance in let method_kind = if is_instance then ClangMethodKind.OBJC_INSTANCE else ClangMethodKind.OBJC_CLASS in @@ -54,8 +54,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s in let predefined_ms_opt = match proc_name with - | Typ.Procname.ObjC_Cpp objc_cpp -> - let class_name = Typ.Procname.ObjC_Cpp.get_class_type_name objc_cpp in + | Procname.ObjC_Cpp objc_cpp -> + let class_name = Procname.ObjC_Cpp.get_class_type_name objc_cpp in CTrans_models.get_predefined_model_method_signature class_name selector CType_decl.CProcname.NoAstDecl.objc_method_of_string_kind | _ -> @@ -481,9 +481,9 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let function_attr_opt = Option.bind decl_opt ~f:get_annotate_attr_arg in match function_attr_opt with | Some attr when CTrans_models.is_modeled_attribute attr -> - Some (Typ.Procname.from_string_c_fun attr) + Some (Procname.from_string_c_fun attr) | _ when CTrans_models.is_modeled_builtin name -> - Some (Typ.Procname.from_string_c_fun (CFrontend_config.infer ^ name)) + Some (Procname.from_string_c_fun (CFrontend_config.infer ^ name)) | _ when String.equal name CFrontend_config.malloc && CGeneral_utils.is_objc_extension trans_unit_ctx -> @@ -634,10 +634,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | Some ms -> let procname = ms.CMethodSignature.name in let new_method_name = - Config.clang_inner_destructor_prefix ^ Typ.Procname.get_method procname + Config.clang_inner_destructor_prefix ^ Procname.get_method procname in let ms' = - {ms with name= Typ.Procname.objc_cpp_replace_method_name procname new_method_name} + {ms with name= Procname.objc_cpp_replace_method_name procname new_method_name} in ignore (CMethod_trans.create_local_procdesc context.translation_unit_context context.cfg @@ -2568,8 +2568,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s check_destructor_translation destr_trans_result ; let is_destructor = match procname with - | Typ.Procname.ObjC_Cpp cpp_pname -> - Typ.Procname.ObjC_Cpp.is_destructor cpp_pname + | Procname.ObjC_Cpp cpp_pname -> + Procname.ObjC_Cpp.is_destructor cpp_pname | _ -> false in @@ -3066,13 +3066,13 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s and gccAsmStmt_trans trans_state stmt_info stmts = - let pname = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_gcc_asm_stmt in + let pname = Procname.from_string_c_fun CFrontend_config.infer_skip_gcc_asm_stmt in call_function_with_args Procdesc.Node.GCCAsmStmt pname trans_state stmt_info (Typ.mk Tvoid) stmts and genericSelectionExprUnknown_trans trans_state stmt_info stmts = - let pname = Typ.Procname.from_string_c_fun CFrontend_config.infer_generic_selection_expr in + let pname = Procname.from_string_c_fun CFrontend_config.infer_generic_selection_expr in call_function_with_args Procdesc.Node.GenericSelectionExpr pname trans_state stmt_info (Typ.mk Tvoid) stmts @@ -3083,7 +3083,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s and cxxPseudoDestructorExpr_trans () = - let fun_name = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_fun in + let fun_name = Procname.from_string_c_fun CFrontend_config.infer_skip_fun in mk_trans_result (Exp.Const (Const.Cfun fun_name), Typ.mk Tvoid) empty_control @@ -3143,7 +3143,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s stmt_info in let typ = CType_decl.qual_type_to_sil_type tenv expr_info.Clang_ast_t.ei_qual_type in - let fun_name = Typ.Procname.from_string_c_fun CFrontend_config.infer_skip_fun in + let fun_name = 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 @@ -3807,8 +3807,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let procname = Procdesc.get_proc_name context.CContext.procdesc in let is_destructor = match procname with - | Typ.Procname.ObjC_Cpp cpp_pname -> - Typ.Procname.ObjC_Cpp.is_destructor cpp_pname + | Procname.ObjC_Cpp cpp_pname -> + Procname.ObjC_Cpp.is_destructor cpp_pname | _ -> false in diff --git a/infer/src/clang/cTrans_models.ml b/infer/src/clang/cTrans_models.ml index a6818c163..8263ee951 100644 --- a/infer/src/clang/cTrans_models.ml +++ b/infer/src/clang/cTrans_models.ml @@ -15,21 +15,21 @@ let is_modelled_static_function name = let class_equal class_typename class_name = String.equal (Typ.Name.name class_typename) class_name let is_builtin_expect pname = - String.equal (Typ.Procname.to_string pname) CFrontend_config.builtin_expect + String.equal (Procname.to_string pname) CFrontend_config.builtin_expect let is_builtin_object_size pname = - String.equal (Typ.Procname.to_string pname) CFrontend_config.builtin_object_size + String.equal (Procname.to_string pname) CFrontend_config.builtin_object_size let is_std_addressof pname = (* since std_addressof is a template function, matching it requires QualifiedCppName *) QualifiedCppName.Match.match_qualifiers CFrontend_config.std_addressof - (Typ.Procname.get_qualifiers pname) + (Procname.get_qualifiers pname) let is_replace_with_deref_first_arg pname = - String.equal (Typ.Procname.to_string pname) CFrontend_config.replace_with_deref_first_arg_attr + String.equal (Procname.to_string pname) CFrontend_config.replace_with_deref_first_arg_attr let is_modeled_builtin funct = String.equal funct CFrontend_config.builtin_memset_chk @@ -55,10 +55,10 @@ let is_handleFailureInMethod funct = (** If the function is a builtin model, return the model, otherwise return the function *) let is_assert_log pname = match pname with - | 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) + | Procname.ObjC_Cpp _ -> + is_assert_log_method (Procname.to_string pname) + | Procname.C _ -> + is_assert_log_s (Procname.to_string pname) | _ -> false @@ -94,7 +94,7 @@ let get_predefined_ms_stringWithUTF8String class_name method_name mk_procname = in let param_name = Mangled.from_string "x" in let params = [CMethodSignature.mk_param_type param_name char_star_type] in - get_predefined_ms_method condition class_name method_name Typ.Procname.ObjC_Cpp.ObjCClassMethod + get_predefined_ms_method condition class_name method_name Procname.ObjC_Cpp.ObjCClassMethod mk_procname params (id_type, Annot.Item.empty) [] None @@ -104,7 +104,7 @@ let get_predefined_ms_is_kind_of_class class_name method_name mk_procname = let name = Mangled.from_string CFrontend_config.self in let params = [CMethodSignature.mk_param_type name class_type] in let bool_type = CType_to_sil_type.type_of_builtin_type_kind `Bool in - get_predefined_ms_method condition class_name method_name Typ.Procname.ObjC_Cpp.ObjCInstanceMethod + get_predefined_ms_method condition class_name method_name Procname.ObjC_Cpp.ObjCInstanceMethod mk_procname params (bool_type, Annot.Item.empty) [] (Some BuiltinDecl.__instanceof) diff --git a/infer/src/clang/cTrans_models.mli b/infer/src/clang/cTrans_models.mli index 91b2d7aa7..1a5bf6797 100644 --- a/infer/src/clang/cTrans_models.mli +++ b/infer/src/clang/cTrans_models.mli @@ -9,15 +9,15 @@ open! IStd val is_modelled_static_function : string -> bool -val is_builtin_expect : Typ.Procname.t -> bool +val is_builtin_expect : Procname.t -> bool -val is_builtin_object_size : Typ.Procname.t -> bool +val is_builtin_object_size : Procname.t -> bool -val is_std_addressof : Typ.Procname.t -> bool +val is_std_addressof : Procname.t -> bool -val is_replace_with_deref_first_arg : Typ.Procname.t -> bool +val is_replace_with_deref_first_arg : Procname.t -> bool -val is_assert_log : Typ.Procname.t -> bool +val is_assert_log : Procname.t -> bool val is_handleFailureInMethod : string -> bool @@ -28,5 +28,5 @@ val is_modeled_attribute : string -> bool val get_predefined_model_method_signature : Typ.Name.t -> string - -> (Typ.Name.t -> string -> Typ.Procname.ObjC_Cpp.kind -> Typ.Procname.t) + -> (Typ.Name.t -> string -> Procname.ObjC_Cpp.kind -> Procname.t) -> CMethodSignature.t option diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index 5f3f332f6..8dcdf2918 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -147,7 +147,7 @@ type control = type trans_result = { control: control ; return: Exp.t * Typ.t - ; method_name: Typ.Procname.t option + ; method_name: Procname.t option ; is_cpp_call_virtual: bool } let empty_control = {root_nodes= []; leaf_nodes= []; instrs= []; initd_exps= []} @@ -329,7 +329,7 @@ let objc_new_trans trans_state ~alloc_builtin loc stmt_info cls_name function_ty let method_kind = ClangMethodKind.OBJC_INSTANCE in let pname = CType_decl.CProcname.NoAstDecl.objc_method_of_string_kind cls_name CFrontend_config.init - Typ.Procname.ObjC_Cpp.ObjCInstanceMethod + Procname.ObjC_Cpp.ObjCInstanceMethod in CMethod_trans.create_external_procdesc trans_state.context.CContext.translation_unit_context trans_state.context.CContext.cfg pname method_kind None ; diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index 4c68d0b9a..5925da2bb 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -46,7 +46,7 @@ type control = type trans_result = { control: control ; return: Exp.t * Typ.t (** value returned by the translated statement *) - ; method_name: Typ.Procname.t option + ; method_name: Procname.t option (** in the specific case of translating a method call in C++, we get the method name called at the same time we get the [this] object that contains the method. The [this] instance object is returned as the [return] field, while the method to call is filled in here. @@ -100,7 +100,7 @@ val builtin_trans : -> Clang_ast_t.source_range -> Location.t -> trans_result list - -> Typ.Procname.t + -> Procname.t -> trans_result option val cxx_method_builtin_trans : @@ -108,7 +108,7 @@ val cxx_method_builtin_trans : -> Clang_ast_t.source_range -> Location.t -> trans_result list - -> Typ.Procname.t + -> Procname.t -> trans_result option val new_or_alloc_trans : @@ -230,7 +230,7 @@ module Self : sig val add_self_parameter_for_super_instance : Clang_ast_t.stmt_info -> CContext.t - -> Typ.Procname.t + -> Procname.t -> Location.t -> Clang_ast_t.obj_c_message_expr_info -> trans_result option diff --git a/infer/src/clang/cVar_decl.mli b/infer/src/clang/cVar_decl.mli index dac301b00..46e4509d2 100644 --- a/infer/src/clang/cVar_decl.mli +++ b/infer/src/clang/cVar_decl.mli @@ -11,17 +11,17 @@ open! IStd (** 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 -> Typ.Procname.t -> Pvar.t +val sil_var_of_decl : CContext.t -> Clang_ast_t.decl -> Procname.t -> Pvar.t val sil_var_of_decl_ref : - CContext.t -> Clang_ast_t.source_range -> Clang_ast_t.decl_ref -> Typ.Procname.t -> Pvar.t + CContext.t -> Clang_ast_t.source_range -> Clang_ast_t.decl_ref -> Procname.t -> Pvar.t val add_var_to_locals : Procdesc.t -> Clang_ast_t.decl -> Typ.t -> Pvar.t -> unit val sil_var_of_captured_var : CContext.t -> Clang_ast_t.source_range - -> Typ.Procname.t + -> Procname.t -> Clang_ast_t.decl_ref -> (Pvar.t * Typ.typ) option diff --git a/infer/src/clang/objcMethod_decl.mli b/infer/src/clang/objcMethod_decl.mli index e62ba47b5..fc4774774 100644 --- a/infer/src/clang/objcMethod_decl.mli +++ b/infer/src/clang/objcMethod_decl.mli @@ -8,6 +8,6 @@ open! IStd val get_methods : - CAst_utils.procname_from_decl -> Tenv.t -> Clang_ast_t.decl list -> Typ.Procname.t list + CAst_utils.procname_from_decl -> Tenv.t -> Clang_ast_t.decl list -> Procname.t list -val add_missing_methods : Tenv.t -> Typ.name -> Typ.Procname.t list -> unit +val add_missing_methods : Tenv.t -> Typ.name -> Procname.t list -> unit diff --git a/infer/src/concurrency/ConcurrencyModels.ml b/infer/src/concurrency/ConcurrencyModels.ml index 2093dfc59..9d3661f50 100644 --- a/infer/src/concurrency/ConcurrencyModels.ml +++ b/infer/src/concurrency/ConcurrencyModels.ml @@ -22,21 +22,21 @@ type lock_effect = type thread = BackgroundThread | MainThread | MainThreadIfTrue | UnknownThread let is_thread_utils_type java_pname = - let pn = Typ.Procname.Java.get_class_name java_pname in + let pn = Procname.Java.get_class_name java_pname in String.is_suffix ~suffix:"ThreadUtils" pn || String.is_suffix ~suffix:"ThreadUtil" pn let is_thread_utils_method method_name_str = function - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> is_thread_utils_type java_pname - && String.equal (Typ.Procname.Java.get_method java_pname) method_name_str + && String.equal (Procname.Java.get_method java_pname) method_name_str | _ -> false let get_thread_assert_effect = function - | Typ.Procname.Java java_pname when is_thread_utils_type java_pname -> ( - match Typ.Procname.Java.get_method java_pname with + | Procname.Java java_pname when is_thread_utils_type java_pname -> ( + match Procname.Java.get_method java_pname with | "assertMainThread" | "assertOnUiThread" | "checkOnMainThread" | "checkIsOnMainThread" -> MainThread | "isMainThread" | "isOnMainThread" | "isUiThread" -> @@ -53,7 +53,7 @@ let get_thread_assert_effect = function module Clang : sig - val get_lock_effect : Typ.Procname.t -> HilExp.t list -> lock_effect + val get_lock_effect : Procname.t -> HilExp.t list -> lock_effect val lock_types_matcher : QualifiedCppName.Match.quals_matcher @@ -115,7 +115,7 @@ end = struct let mk_matcher methods = let matcher = QualifiedCppName.Match.of_fuzzy_qual_names methods in - fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Typ.Procname.get_qualifiers pname) + fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Procname.get_qualifiers pname) let is_lock, is_unlock, is_trylock, is_std_lock = @@ -214,7 +214,7 @@ end = struct let get_lock_effect pname actuals = let log_parse_error error = - L.debug Analysis Verbose "%s pname:%a actuals:%a@." error Typ.Procname.pp pname + L.debug Analysis Verbose "%s pname:%a actuals:%a@." error Procname.pp pname (PrettyPrintable.pp_collection ~pp_item:HilExp.pp) actuals in @@ -247,7 +247,7 @@ end = struct end module Java : sig - val get_lock_effect : Typ.Procname.t -> Typ.Procname.Java.t -> HilExp.t list -> lock_effect + val get_lock_effect : Procname.t -> Procname.Java.t -> HilExp.t list -> lock_effect end = struct let std_locks = [ "java.util.concurrent.locks.Lock" @@ -275,8 +275,8 @@ end = struct let fst_arg = match actuals with x :: _ -> [x] | _ -> [] in if is_thread_utils_method "assertHoldsLock" pname then Lock fst_arg else - let classname = Typ.Procname.Java.get_class_name java_pname in - let methodname = Typ.Procname.Java.get_method java_pname in + let classname = Procname.Java.get_class_name java_pname in + let methodname = Procname.Java.get_method java_pname in if is_lock classname methodname then Lock fst_arg else if is_unlock classname methodname then Unlock fst_arg else if is_trylock classname methodname then LockedIfTrue fst_arg @@ -285,13 +285,13 @@ end let get_lock_effect pname actuals = let fst_arg = match actuals with x :: _ -> [x] | _ -> [] in - if Typ.Procname.equal pname BuiltinDecl.__set_locked_attribute then Lock fst_arg - else if Typ.Procname.equal pname BuiltinDecl.__delete_locked_attribute then Unlock fst_arg + if Procname.equal pname BuiltinDecl.__set_locked_attribute then Lock fst_arg + else if Procname.equal pname BuiltinDecl.__delete_locked_attribute then Unlock fst_arg else match pname with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> Java.get_lock_effect pname java_pname actuals - | Typ.Procname.(ObjC_Cpp _ | C _) -> + | Procname.(ObjC_Cpp _ | C _) -> Clang.get_lock_effect pname actuals | _ -> NoEffect @@ -299,8 +299,8 @@ let get_lock_effect pname actuals = let get_current_class_and_annotated_superclasses is_annot tenv pname = match pname with - | Typ.Procname.Java java_pname -> - let current_class = Typ.Procname.Java.get_class_type_name java_pname in + | Procname.Java java_pname -> + let current_class = Procname.Java.get_class_type_name java_pname in let annotated_classes = PatternMatch.find_superclasses_with_attributes is_annot tenv current_class in @@ -357,7 +357,7 @@ let is_modeled_ui_method = fun tenv pname -> MethodMatcher.of_list matchers tenv pname [] -type annotation_trail = DirectlyAnnotated | Override of Typ.Procname.t | SuperClass of Typ.name +type annotation_trail = DirectlyAnnotated | Override of Procname.t | SuperClass of Typ.name [@@deriving compare] let find_override_or_superclass_annotated ~attrs_of_pname is_annot tenv proc_name = @@ -380,7 +380,7 @@ let find_override_or_superclass_annotated ~attrs_of_pname is_annot tenv proc_nam List.find_map tstruct.supers ~f:find_override_or_superclass_aux ) in if is_annotated proc_name then Some DirectlyAnnotated - else Typ.Procname.get_class_type_name proc_name |> Option.bind ~f:find_override_or_superclass_aux + else Procname.get_class_type_name proc_name |> Option.bind ~f:find_override_or_superclass_aux let annotated_as ~attrs_of_pname predicate tenv pname = diff --git a/infer/src/concurrency/ConcurrencyModels.mli b/infer/src/concurrency/ConcurrencyModels.mli index 5e35e44f9..13d6d2b12 100644 --- a/infer/src/concurrency/ConcurrencyModels.mli +++ b/infer/src/concurrency/ConcurrencyModels.mli @@ -22,19 +22,19 @@ type lock_effect = type thread = BackgroundThread | MainThread | MainThreadIfTrue | UnknownThread -val is_thread_utils_method : string -> Typ.Procname.t -> bool +val is_thread_utils_method : string -> Procname.t -> bool (** return true if the given method name is a utility class for checking what thread we're on TODO: clean this up so it takes only a procname *) -val get_lock_effect : Typ.Procname.t -> HilExp.t list -> lock_effect +val get_lock_effect : Procname.t -> HilExp.t list -> lock_effect (** describe how this procedure behaves with respect to locking *) -val get_thread_assert_effect : Typ.Procname.t -> thread +val get_thread_assert_effect : Procname.t -> thread (** In Java, certain methods can be used to assert execution on a specific kind of thread, or return a boolean equivalent to such a fact. *) val get_current_class_and_annotated_superclasses : - (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> (Typ.name * Typ.name list) option + (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> (Typ.name * Typ.name list) option val cpp_lock_types_matcher : QualifiedCppName.Match.quals_matcher @@ -43,7 +43,7 @@ val is_recursive_lock_type : Typ.name -> bool (** Type documenting why a method is considered as annotated with a certain annotation *) type annotation_trail = | DirectlyAnnotated (** the method is directly annotated as such *) - | Override of Typ.Procname.t (** it overrides a method annotated in a super class *) + | Override of Procname.t (** it overrides a method annotated in a super class *) | SuperClass of Typ.name (** the method's class or a super class of that is annotated as such *) [@@deriving compare] @@ -51,17 +51,17 @@ val find_override_or_superclass_annotated : attrs_of_pname:(BuiltinDecl.t -> ProcAttributes.t option) -> (Annot.Item.t -> bool) -> Tenv.t - -> Typ.Procname.t + -> Procname.t -> annotation_trail option (** check if a method's transitive annotations satisfy the given predicate *) val annotated_as_worker_thread : - attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> Tenv.t -> Typ.Procname.t -> bool + attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> Tenv.t -> Procname.t -> bool val runs_on_ui_thread : - attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> Tenv.t -> Typ.Procname.t -> bool + attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> Tenv.t -> Procname.t -> bool (** is method not transitively annotated [@WorkerThread] and is modeled or annotated [@UIThread] or equivalent? *) -val is_modeled_ui_method : Tenv.t -> Typ.Procname.t -> bool +val is_modeled_ui_method : Tenv.t -> Procname.t -> bool (** is method a known Android UI thread callback (eg [Activity.onCreate]) *) diff --git a/infer/src/concurrency/ExplicitTrace.ml b/infer/src/concurrency/ExplicitTrace.ml index 7c4c41275..d93430472 100644 --- a/infer/src/concurrency/ExplicitTrace.ml +++ b/infer/src/concurrency/ExplicitTrace.ml @@ -26,7 +26,7 @@ module DefaultCallPrinter : CallPrinter = struct type t = CallSite.t let pp fmt callsite = - F.fprintf fmt "Method call: %a" (MF.wrap_monospaced Typ.Procname.pp) (CallSite.pname callsite) + F.fprintf fmt "Method call: %a" (MF.wrap_monospaced Procname.pp) (CallSite.pname callsite) end type 'a comparator = 'a -> Location.t -> 'a -> Location.t -> int diff --git a/infer/src/concurrency/MethodMatcher.ml b/infer/src/concurrency/MethodMatcher.ml index 5c30da7d2..777b1c0ac 100644 --- a/infer/src/concurrency/MethodMatcher.ml +++ b/infer/src/concurrency/MethodMatcher.ml @@ -13,8 +13,8 @@ let template_arg = Str.regexp "<[^<>]*>" let rec strip_template_args str = if (not (String.contains str '<')) - || String.equal str Typ.Procname.Java.constructor_method_name - || String.equal str Typ.Procname.Java.class_initializer_method_name + || String.equal str Procname.Java.constructor_method_name + || String.equal str Procname.Java.class_initializer_method_name then str else let result = Str.global_replace template_arg "" str in @@ -43,21 +43,21 @@ let call_matches ~search_superclasses ~method_prefix ~actuals_pred clazz methods Typ.Name.to_string tname |> strip_template_args |> String.equal target in fun tenv pname -> - Typ.Procname.get_class_type_name pname + Procname.get_class_type_name pname |> Option.exists ~f:(PatternMatch.supertype_exists tenv is_target) else fun _tenv pname -> - Typ.Procname.get_class_name pname |> Option.map ~f:strip_template_args + Procname.get_class_name pname |> Option.map ~f:strip_template_args |> Option.exists ~f:(String.equal clazz) in (fun tenv pn actuals -> actuals_pred actuals && - let mthd = Typ.Procname.get_method pn |> strip_template_args in + let mthd = Procname.get_method pn |> strip_template_args in List.exists methods ~f:(method_matcher mthd) && class_matcher tenv pn ) |> Staged.stage -type t = Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +type t = Tenv.t -> Procname.t -> HilExp.t list -> bool type record = { search_superclasses: bool diff --git a/infer/src/concurrency/MethodMatcher.mli b/infer/src/concurrency/MethodMatcher.mli index 3d4fdab13..3c00df6db 100644 --- a/infer/src/concurrency/MethodMatcher.mli +++ b/infer/src/concurrency/MethodMatcher.mli @@ -9,7 +9,7 @@ open! IStd (** pattern matcher for Java/C++ methods NB matching is modulo template arguments in C++ classes and functions *) -type t = Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +type t = Tenv.t -> Procname.t -> HilExp.t list -> bool type record = { search_superclasses: bool diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 2a03a31da..c56a35d25 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -246,7 +246,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct (Summary.get_proc_desc summary) astate | _ -> L.internal_error "Call to %a is marked as a container write, but has no receiver" - Typ.Procname.pp callee_pname ; + Procname.pp callee_pname ; None ) @@ -439,7 +439,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct |> IOption.if_none_eval ~f:(do_proc_call ret_base callee_pname actuals call_flags loc proc_data astate) | Call (_, Indirect _, _, _, _) -> - if Typ.Procname.is_java (Summary.get_proc_name summary) then + if Procname.is_java (Summary.get_proc_name summary) then L.(die InternalError) "Unexpected indirect call instruction %a" HilInstr.pp instr else astate | Assign (lhs_access_expr, rhs_exp, loc) -> @@ -463,7 +463,7 @@ let analyze_procedure {Callbacks.exe_env; summary} = let open ConcurrencyModels in let method_annotation = (Procdesc.get_attributes proc_desc).method_annotation in let is_initializer tenv proc_name = - Typ.Procname.is_constructor proc_name || FbThreadSafety.is_custom_init tenv proc_name + Procname.is_constructor proc_name || FbThreadSafety.is_custom_init tenv proc_name in let open RacerDDomain in if should_analyze_proc tenv proc_name then @@ -628,7 +628,7 @@ let get_reporting_explanation_cpp = (IssueType.lock_consistency_violation, "") (** Explain why we are reporting this access *) let get_reporting_explanation report_kind tenv pname thread = - if Typ.Procname.is_java pname then get_reporting_explanation_java report_kind tenv pname thread + if Procname.is_java pname then get_reporting_explanation_java report_kind tenv pname thread else get_reporting_explanation_cpp @@ -636,7 +636,7 @@ let pp_container_access fmt (access_exp, access_pname) = F.fprintf fmt "container %a via call to %s" (MF.wrap_monospaced RacerDDomain.pp_exp) access_exp - (MF.monospaced_to_string (Typ.Procname.get_method access_pname)) + (MF.monospaced_to_string (Procname.get_method access_pname)) let pp_access fmt (t : RacerDDomain.TraceElem.t) = @@ -682,7 +682,7 @@ type reported_access = { threads: RacerDDomain.ThreadsDomain.t ; snapshot: RacerDDomain.AccessSnapshot.t ; tenv: Tenv.t - ; procname: Typ.Procname.t } + ; procname: Procname.t } let report_thread_safety_violation ~issue_log ~make_description ~report_kind ({threads; snapshot; tenv; procname= pname} : reported_access) = @@ -705,14 +705,14 @@ let report_thread_safety_violation ~issue_log ~make_description ~report_kind let report_unannotated_interface_violation ~issue_log reported_pname reported_access = match reported_pname with - | Typ.Procname.Java java_pname -> - let class_name = Typ.Procname.Java.get_class_name java_pname in + | Procname.Java java_pname -> + let class_name = Procname.Java.get_class_name java_pname in let make_description _ _ _ _ = F.asprintf "Unprotected call to method %a of un-annotated interface %a. Consider annotating the \ class with %a, adding a lock, or using an interface that is known to be thread-safe." - (MF.wrap_monospaced Typ.Procname.pp) - reported_pname MF.pp_monospaced class_name MF.pp_monospaced "@ThreadSafe" + (MF.wrap_monospaced Procname.pp) reported_pname MF.pp_monospaced class_name + MF.pp_monospaced "@ThreadSafe" in report_thread_safety_violation ~issue_log ~make_description ~report_kind:UnannotatedInterface reported_access @@ -723,8 +723,7 @@ let report_unannotated_interface_violation ~issue_log reported_pname reported_ac let make_unprotected_write_description pname final_sink_site initial_sink_site final_sink = Format.asprintf "Unprotected write. Non-private method %a%s %s %a outside of synchronization." - (MF.wrap_monospaced Typ.Procname.pp) - pname + (MF.wrap_monospaced Procname.pp) pname (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (if RacerDDomain.TraceElem.is_container_write final_sink then "mutates" else "writes to field") pp_access final_sink @@ -733,8 +732,7 @@ let make_unprotected_write_description pname final_sink_site initial_sink_site f let make_guardedby_violation_description pname final_sink_site initial_sink_site final_sink = Format.asprintf "GuardedBy violation. Non-private method %a%s accesses %a outside of synchronization." - (MF.wrap_monospaced Typ.Procname.pp) - pname + (MF.wrap_monospaced Procname.pp) pname (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") pp_access final_sink @@ -742,7 +740,7 @@ let make_guardedby_violation_description pname final_sink_site initial_sink_site let make_read_write_race_description ~read_is_sync (conflict : reported_access) pname final_sink_site initial_sink_site final_sink = let pp_conflict fmt {procname} = - F.pp_print_string fmt (Typ.Procname.to_simplified_string ~withclass:true procname) + F.pp_print_string fmt (Procname.to_simplified_string ~withclass:true procname) in let conflicts_description = Format.asprintf "Potentially races with%s write in method %a" @@ -750,8 +748,7 @@ let make_read_write_race_description ~read_is_sync (conflict : reported_access) (MF.wrap_monospaced pp_conflict) conflict in Format.asprintf "Read/Write race. Non-private method %a%s reads%s from %a. %s." - (MF.wrap_monospaced Typ.Procname.pp) - pname + (MF.wrap_monospaced Procname.pp) pname (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (if read_is_sync then " with synchronization" else " without synchronization") pp_access final_sink conflicts_description @@ -763,15 +760,15 @@ let make_read_write_race_description ~read_is_sync (conflict : reported_access) report one of each kind of access *) type reported = { reported_sites: CallSite.Set.t - ; reported_writes: Typ.Procname.Set.t - ; reported_reads: Typ.Procname.Set.t - ; reported_unannotated_calls: Typ.Procname.Set.t } + ; reported_writes: Procname.Set.t + ; reported_reads: Procname.Set.t + ; reported_unannotated_calls: Procname.Set.t } let empty_reported = let reported_sites = CallSite.Set.empty in - let reported_writes = Typ.Procname.Set.empty in - let reported_reads = Typ.Procname.Set.empty in - let reported_unannotated_calls = Typ.Procname.Set.empty in + let reported_writes = Procname.Set.empty in + let reported_reads = Procname.Set.empty in + let reported_unannotated_calls = Procname.Set.empty in {reported_sites; reported_reads; reported_writes; reported_unannotated_calls} @@ -814,7 +811,7 @@ end = struct end module Key = struct - type t = Location of PathModuloThis.t | Container of PathModuloThis.t | Call of Typ.Procname.t + type t = Location of PathModuloThis.t | Container of PathModuloThis.t | Call of Procname.t [@@deriving compare] let of_access (access : RacerDDomain.Access.t) = @@ -854,7 +851,7 @@ let should_report_on_proc tenv procdesc = requested via @ThreadSafe in java *) RacerDModels.is_thread_safe_method proc_name tenv || Procdesc.get_access procdesc <> PredSymb.Private - && (not (Typ.Procname.Java.is_autogen_method java_pname)) + && (not (Procname.Java.is_autogen_method java_pname)) && not (Annotations.pdesc_return_annot_ends_with procdesc Annotations.visibleForTesting) | ObjC_Cpp {kind; class_name} -> ( match kind with @@ -863,7 +860,7 @@ let should_report_on_proc tenv procdesc = | ObjCClassMethod | ObjCInstanceMethod | ObjCInternalMethod -> Tenv.lookup tenv class_name |> Option.exists ~f:(fun {Struct.exported_objc_methods} -> - List.mem ~equal:Typ.Procname.equal exported_objc_methods proc_name ) ) + List.mem ~equal:Procname.equal exported_objc_methods proc_name ) ) && let matcher = ConcurrencyModels.cpp_lock_types_matcher in Option.exists (Tenv.lookup tenv class_name) ~f:(fun class_str -> @@ -891,7 +888,7 @@ let should_report_guardedby_violation classname_str ({snapshot; tenv; procname} in (not snapshot.lock) && RacerDDomain.TraceElem.is_write snapshot.access - && Typ.Procname.is_java procname + && Procname.is_java procname && (* restrict check to access paths of length one *) match @@ -953,11 +950,11 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM || match snapshot.access.TraceElem.elem with | Access.Write _ | Access.ContainerWrite _ -> - Typ.Procname.Set.mem pname reported_writes + Procname.Set.mem pname reported_writes | Access.Read _ | Access.ContainerRead _ -> - Typ.Procname.Set.mem pname reported_reads + Procname.Set.mem pname reported_reads | Access.InterfaceCall _ -> - Typ.Procname.Set.mem pname reported_unannotated_calls + Procname.Set.mem pname reported_unannotated_calls else false in let update_reported ({snapshot; procname= pname} : reported_access) reported = @@ -966,14 +963,14 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM let reported_sites = CallSite.Set.add call_site reported.reported_sites in match snapshot.access.TraceElem.elem with | Access.Write _ | Access.ContainerWrite _ -> - let reported_writes = Typ.Procname.Set.add pname reported.reported_writes in + let reported_writes = Procname.Set.add pname reported.reported_writes in {reported with reported_writes; reported_sites} | Access.Read _ | Access.ContainerRead _ -> - let reported_reads = Typ.Procname.Set.add pname reported.reported_reads in + let reported_reads = Procname.Set.add pname reported.reported_reads in {reported with reported_reads; reported_sites} | Access.InterfaceCall _ -> let reported_unannotated_calls = - Typ.Procname.Set.add pname reported.reported_unannotated_calls + Procname.Set.add pname reported.reported_unannotated_calls in {reported with reported_unannotated_calls; reported_sites} else reported @@ -1006,7 +1003,7 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM report_unannotated_interface_violation ~acc reported_pname reported_access | Access.InterfaceCall _ -> acc - | (Access.Write _ | ContainerWrite _) when Typ.Procname.is_java pname -> + | (Access.Write _ | ContainerWrite _) when Procname.is_java pname -> let conflict = if ThreadsDomain.is_any threads then (* unprotected write in method that may run in parallel with itself. warn *) @@ -1036,7 +1033,7 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM let is_conflict {snapshot; threads= other_threads} = TraceElem.is_write snapshot.access && - if Typ.Procname.is_java pname then + if Procname.is_java pname then ThreadsDomain.is_any threads || ThreadsDomain.is_any other_threads else not (AccessSnapshot.is_unprotected snapshot) in @@ -1087,7 +1084,7 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM let report grouped_accesses (reported, issue_log) = (* reset the reported reads and writes for each memory location *) let reported = - {reported with reported_writes= Typ.Procname.Set.empty; reported_reads= Typ.Procname.Set.empty} + {reported with reported_writes= Procname.Set.empty; reported_reads= Procname.Set.empty} in report_guardedby_violations_on_location grouped_accesses (reported, issue_log) |> report_accesses_on_location grouped_accesses @@ -1117,7 +1114,7 @@ let aggregate_by_class file_env = List.fold file_env ~init:String.Map.empty ~f:(fun acc ((tenv, summary) as proc) -> let pdesc = Summary.get_proc_desc summary in if should_report_on_proc tenv pdesc then - Procdesc.get_proc_name pdesc |> Typ.Procname.get_class_name + Procdesc.get_proc_name pdesc |> Procname.get_class_name |> Option.fold ~init:acc ~f:(fun acc classname -> String.Map.add_multi acc ~key:classname ~data:proc ) else acc ) diff --git a/infer/src/concurrency/RacerDDomain.ml b/infer/src/concurrency/RacerDDomain.ml index 982eb8472..790cc8dfa 100644 --- a/infer/src/concurrency/RacerDDomain.ml +++ b/infer/src/concurrency/RacerDDomain.ml @@ -33,9 +33,9 @@ module Access = struct type t = | Read of {exp: AccessExpression.t} | Write of {exp: AccessExpression.t} - | ContainerRead of {exp: AccessExpression.t; pname: Typ.Procname.t} - | ContainerWrite of {exp: AccessExpression.t; pname: Typ.Procname.t} - | InterfaceCall of Typ.Procname.t + | ContainerRead of {exp: AccessExpression.t; pname: Procname.t} + | ContainerWrite of {exp: AccessExpression.t; pname: Procname.t} + | InterfaceCall of Procname.t [@@deriving compare] let make_field_access exp ~is_write = if is_write then Write {exp} else Read {exp} @@ -89,11 +89,11 @@ module Access = struct | Write {exp} -> F.fprintf fmt "Write to %a" AccessExpression.pp exp | ContainerRead {exp; pname} -> - F.fprintf fmt "Read of container %a via %a" AccessExpression.pp exp Typ.Procname.pp pname + F.fprintf fmt "Read of container %a via %a" AccessExpression.pp exp Procname.pp pname | ContainerWrite {exp; pname} -> - F.fprintf fmt "Write to container %a via %a" AccessExpression.pp exp Typ.Procname.pp pname + F.fprintf fmt "Write to container %a via %a" AccessExpression.pp exp Procname.pp pname | InterfaceCall pname -> - F.fprintf fmt "Call to un-annotated interface method %a" Typ.Procname.pp pname + F.fprintf fmt "Call to un-annotated interface method %a" Procname.pp pname let mono_lang_pp = MF.wrap_monospaced pp_exp @@ -103,18 +103,18 @@ module Access = struct F.fprintf fmt "access to %a" mono_lang_pp exp | ContainerRead {exp; pname} -> F.fprintf fmt "Read of container %a via call to %s" mono_lang_pp exp - (MF.monospaced_to_string (Typ.Procname.get_method pname)) + (MF.monospaced_to_string (Procname.get_method pname)) | ContainerWrite {exp; pname} -> F.fprintf fmt "Write to container %a via call to %s" mono_lang_pp exp - (MF.monospaced_to_string (Typ.Procname.get_method pname)) + (MF.monospaced_to_string (Procname.get_method pname)) | InterfaceCall pname -> - F.fprintf fmt "Call to un-annotated interface method %a" Typ.Procname.pp pname + F.fprintf fmt "Call to un-annotated interface method %a" Procname.pp pname end module CallPrinter = struct type t = CallSite.t - let pp fmt cs = F.fprintf fmt "call to %a" Typ.Procname.pp (CallSite.pname cs) + let pp fmt cs = F.fprintf fmt "call to %a" Procname.pp (CallSite.pname cs) end module TraceElem = struct diff --git a/infer/src/concurrency/RacerDDomain.mli b/infer/src/concurrency/RacerDDomain.mli index d13da4e57..9122a5b87 100644 --- a/infer/src/concurrency/RacerDDomain.mli +++ b/infer/src/concurrency/RacerDDomain.mli @@ -16,11 +16,10 @@ module Access : sig type t = | Read of {exp: AccessExpression.t} (** Field or array read *) | Write of {exp: AccessExpression.t} (** Field or array write *) - | ContainerRead of {exp: AccessExpression.t; pname: Typ.Procname.t} - (** Read of container object *) - | ContainerWrite of {exp: AccessExpression.t; pname: Typ.Procname.t} + | ContainerRead of {exp: AccessExpression.t; pname: Procname.t} (** Read of container object *) + | ContainerWrite of {exp: AccessExpression.t; pname: Procname.t} (** Write to container object *) - | InterfaceCall of Typ.Procname.t + | InterfaceCall of Procname.t (** Call to method of interface not annotated with [@ThreadSafe] *) [@@deriving compare] @@ -39,8 +38,7 @@ module TraceElem : sig val map : f:(AccessExpression.t -> AccessExpression.t) -> t -> t - val make_container_access : - AccessExpression.t -> Typ.Procname.t -> is_write:bool -> Location.t -> t + val make_container_access : AccessExpression.t -> Procname.t -> is_write:bool -> Location.t -> t val make_field_access : AccessExpression.t -> is_write:bool -> Location.t -> t end @@ -224,4 +222,4 @@ include AbstractDomain.WithBottom with type t := t val pp_summary : F.formatter -> summary -> unit -val add_unannotated_call_access : Typ.Procname.t -> Location.t -> Procdesc.t -> t -> t +val add_unannotated_call_access : Procname.t -> Location.t -> Procdesc.t -> t -> t diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index 785ce14fd..dff536764 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -98,7 +98,7 @@ let is_cpp_container_read = in let matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["std::map::find"] in fun pname -> - let pname_qualifiers = Typ.Procname.get_qualifiers pname in + let pname_qualifiers = Procname.get_qualifiers pname in QualifiedCppName.Match.match_qualifiers matcher pname_qualifiers || is_container_operator pname_qualifiers @@ -107,23 +107,23 @@ let is_cpp_container_write = let matcher = QualifiedCppName.Match.of_fuzzy_qual_names ["std::map::operator[]"; "std::map::erase"] in - fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Typ.Procname.get_qualifiers pname) + fun pname -> QualifiedCppName.Match.match_qualifiers matcher (Procname.get_qualifiers pname) let get_container_access pn tenv = match pn with - | Typ.Procname.Java _ when is_java_container_write tenv pn [] -> + | Procname.Java _ when is_java_container_write tenv pn [] -> Some ContainerWrite - | Typ.Procname.Java _ when is_java_container_read tenv pn [] -> + | Procname.Java _ when is_java_container_read tenv pn [] -> Some ContainerRead - | Typ.Procname.Java _ -> + | Procname.Java _ -> None (* The following order matters: we want to check if pname is a container write before we check if pname is a container read. This is due to a different treatment between std::map::operator[] and all other operator[]. *) - | (Typ.Procname.ObjC_Cpp _ | C _) when is_cpp_container_write pn -> + | (Procname.ObjC_Cpp _ | C _) when is_cpp_container_write pn -> Some ContainerWrite - | (Typ.Procname.ObjC_Cpp _ | C _) when is_cpp_container_read pn -> + | (Procname.ObjC_Cpp _ | C _) when is_cpp_container_read pn -> Some ContainerRead | _ -> None @@ -148,10 +148,10 @@ let should_skip = ; "std::vector" ]) in function - | Typ.Procname.ObjC_Cpp cpp_pname as pname -> - Typ.Procname.ObjC_Cpp.is_destructor cpp_pname + | Procname.ObjC_Cpp cpp_pname as pname -> + Procname.ObjC_Cpp.is_destructor cpp_pname || QualifiedCppName.Match.match_qualifiers (Lazy.force matcher) - (Typ.Procname.get_qualifiers pname) + (Procname.get_qualifiers pname) | _ -> false @@ -161,10 +161,8 @@ let has_return_annot predicate pn = Annotations.pname_has_return_annot pn ~attrs let is_functional pname = let is_annotated_functional = has_return_annot Annotations.ia_is_functional in let is_modeled_functional = function - | Typ.Procname.Java java_pname -> ( - match - (Typ.Procname.Java.get_class_name java_pname, Typ.Procname.Java.get_method java_pname) - with + | Procname.Java java_pname -> ( + match (Procname.Java.get_class_name java_pname, 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 *) @@ -189,23 +187,21 @@ let nsobject = Typ.Name.Objc.from_qual_name (QualifiedCppName.of_qual_string "NS let acquires_ownership pname tenv = let is_nsobject_init = function - | Typ.Procname.ObjC_Cpp - {kind= Typ.Procname.ObjC_Cpp.ObjCInstanceMethod; method_name= "init"; class_name} -> + | Procname.ObjC_Cpp {kind= Procname.ObjC_Cpp.ObjCInstanceMethod; method_name= "init"; class_name} + -> Typ.Name.equal class_name nsobject | _ -> false in let is_allocation pn = - Typ.Procname.equal pn BuiltinDecl.__new - || Typ.Procname.equal pn BuiltinDecl.__new_array + Procname.equal pn BuiltinDecl.__new + || Procname.equal pn BuiltinDecl.__new_array || is_nsobject_init pn in (* identify library functions that maintain ownership invariants behind the scenes *) let is_owned_in_library = function - | Typ.Procname.Java java_pname -> ( - match - (Typ.Procname.Java.get_class_name java_pname, Typ.Procname.Java.get_method java_pname) - with + | Procname.Java java_pname -> ( + match (Procname.Java.get_class_name java_pname, Procname.Java.get_method java_pname) with | "javax.inject.Provider", "get" -> (* in dependency injection, the library allocates fresh values behind the scenes *) true @@ -241,10 +237,8 @@ let acquires_ownership pname tenv = (* return true if the given procname boxes a primitive type into a reference type *) let is_box = function - | Typ.Procname.Java java_pname -> ( - match - (Typ.Procname.Java.get_class_name java_pname, Typ.Procname.Java.get_method java_pname) - with + | Procname.Java java_pname -> ( + match (Procname.Java.get_class_name java_pname, Procname.Java.get_method java_pname) with | ( ( "java.lang.Boolean" | "java.lang.Byte" | "java.lang.Char" @@ -322,9 +316,9 @@ let is_assumed_thread_safe tenv pname = let should_analyze_proc tenv pn = (not ( match pn with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_class_initializer java_pname - || Typ.Name.Java.is_external (Typ.Procname.Java.get_class_type_name java_pname) + | Procname.Java java_pname -> + Procname.Java.is_class_initializer java_pname + || Typ.Name.Java.is_external (Procname.Java.get_class_type_name java_pname) (* third party code may be hard to change, not useful to report races there *) | _ -> false )) @@ -371,9 +365,7 @@ let is_safe_access (access : 'a HilExp.Access.t) prefix_exp tenv = let is_builder_class tname = String.is_suffix ~suffix:"$Builder" (Typ.Name.to_string tname) -let is_builder_method java_pname = - is_builder_class (Typ.Procname.Java.get_class_type_name java_pname) - +let is_builder_method java_pname = is_builder_class (Procname.Java.get_class_type_name java_pname) let should_flag_interface_call tenv exps call_flags pname = let thread_safe_or_thread_confined annot = @@ -381,7 +373,7 @@ let should_flag_interface_call tenv exps call_flags pname = in (* is this function in library code from the JDK core libraries or Android? *) let is_java_library java_pname = - Typ.Procname.Java.get_package java_pname + Procname.Java.get_package java_pname |> Option.exists ~f:(fun package_name -> String.is_prefix ~prefix:"java." package_name || String.is_prefix ~prefix:"android." package_name @@ -399,11 +391,11 @@ let should_flag_interface_call tenv exps call_flags pname = in let implements_threadsafe_interface java_pname tenv = (* generated classes implementing this interface are always threadsafe *) - Typ.Procname.Java.get_class_type_name java_pname + Procname.Java.get_class_type_name java_pname |> fun tname -> PatternMatch.is_subtype_of_str tenv tname "android.os.IInterface" in match pname with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> call_flags.CallFlags.cf_interface && (not (is_java_library java_pname)) && (not (is_builder_method java_pname)) @@ -421,8 +413,8 @@ let should_flag_interface_call tenv exps call_flags pname = let is_synchronized_container callee_pname (access_exp : HilExp.AccessExpression.t) tenv = let is_threadsafe_collection pn tenv = match pn with - | Typ.Procname.Java java_pname -> - let typename = Typ.Procname.Java.get_class_type_name java_pname in + | Procname.Java java_pname -> + let typename = Procname.Java.get_class_type_name java_pname in let aux tn _ = match Typ.Name.name tn with | "java.util.concurrent.ConcurrentMap" @@ -454,7 +446,7 @@ let is_synchronized_container callee_pname (access_exp : HilExp.AccessExpression |> List.rev_filter ~f:Access.is_field_or_array_access with | Access.FieldAccess base_field :: Access.FieldAccess container_field :: _ - when Typ.Procname.is_java callee_pname -> + when Procname.is_java callee_pname -> let base_typename = Fieldname.get_class_name base_field in is_annotated_synchronized base_typename container_field tenv | [Access.FieldAccess container_field] -> ( @@ -482,8 +474,8 @@ let is_abstract_getthis_like callee = let creates_builder callee = - (match callee with Typ.Procname.Java jpname -> Typ.Procname.Java.is_static jpname | _ -> false) - && String.equal "create" (Typ.Procname.get_method callee) + (match callee with Procname.Java jpname -> Procname.Java.is_static jpname | _ -> false) + && String.equal "create" (Procname.get_method callee) && attrs_of_pname callee |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> match attrs.ret_type with @@ -495,8 +487,8 @@ let creates_builder callee = let is_builder_passthrough callee = match callee with - | Typ.Procname.Java java_pname -> - (not (Typ.Procname.Java.is_static java_pname)) + | Procname.Java java_pname -> + (not (Procname.Java.is_static java_pname)) && is_builder_method java_pname && attrs_of_pname callee |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> diff --git a/infer/src/concurrency/RacerDModels.mli b/infer/src/concurrency/RacerDModels.mli index 1a9b85259..5c454b98e 100644 --- a/infer/src/concurrency/RacerDModels.mli +++ b/infer/src/concurrency/RacerDModels.mli @@ -9,55 +9,55 @@ open! IStd type container_access = ContainerRead | ContainerWrite -val get_container_access : Typ.Procname.t -> Tenv.t -> container_access option +val get_container_access : Procname.t -> Tenv.t -> container_access option (** return Some (access) if this procedure accesses the contents of a container (e.g., Map.get) *) -val has_return_annot : (Annot.Item.t -> bool) -> Typ.Procname.t -> bool +val has_return_annot : (Annot.Item.t -> bool) -> Procname.t -> bool -val is_functional : Typ.Procname.t -> bool +val is_functional : Procname.t -> bool -val acquires_ownership : Typ.Procname.t -> Tenv.t -> bool +val acquires_ownership : Procname.t -> Tenv.t -> bool -val is_box : Typ.Procname.t -> bool +val is_box : Procname.t -> bool (** return true if the given procname boxes a primitive type into a reference type *) -val is_thread_confined_method : Tenv.t -> Typ.Procname.t -> bool +val is_thread_confined_method : Tenv.t -> Procname.t -> bool (** Methods in [@ThreadConfined] classes and methods annotated with [@ThreadConfined] are assumed to all run on the same thread. For the moment we won't warn on accesses resulting from use of such methods at all. In future we should account for races between these methods and methods from completely different classes that don't necessarily run on the same thread as the confined object. *) -val should_analyze_proc : Tenv.t -> Typ.Procname.t -> bool +val should_analyze_proc : Tenv.t -> Procname.t -> bool (** return true if we should compute a summary for the procedure. if this returns false, we won't analyze the procedure or report any warnings on it. note: in the future, we will want to analyze the procedures in all of these cases in order to find more bugs. this is just a temporary measure to avoid obvious false positives *) val get_current_class_and_threadsafe_superclasses : - Tenv.t -> Typ.Procname.t -> (Typ.name * Typ.name list) option + Tenv.t -> Procname.t -> (Typ.name * Typ.name list) option -val is_thread_safe_method : Typ.Procname.t -> Tenv.t -> bool +val is_thread_safe_method : Procname.t -> Tenv.t -> bool (** returns true if method or overriden method in superclass is [@ThreadSafe], [@ThreadSafe(enableChecks = true)], or is defined as an alias of [@ThreadSafe] in a .inferconfig file. *) -val is_marked_thread_safe : Typ.Procname.t -> Tenv.t -> bool +val is_marked_thread_safe : Procname.t -> Tenv.t -> bool val is_safe_access : 'a HilExp.Access.t -> HilExp.AccessExpression.t -> Tenv.t -> bool (** check if an access to a field is thread-confined, or whether the field is volatile *) -val should_flag_interface_call : Tenv.t -> HilExp.t list -> CallFlags.t -> Typ.Procname.t -> bool +val should_flag_interface_call : Tenv.t -> HilExp.t list -> CallFlags.t -> Procname.t -> bool (** should an interface call be flagged as potentially non-thread safe? *) -val is_synchronized_container : Typ.Procname.t -> HilExp.AccessExpression.t -> Tenv.t -> bool +val is_synchronized_container : Procname.t -> HilExp.AccessExpression.t -> Tenv.t -> bool (** is a call on an access expression to a method of a synchronized container? *) -val is_abstract_getthis_like : Typ.Procname.t -> bool +val is_abstract_getthis_like : Procname.t -> bool (** is the callee an abstract method with one argument where argument type is equal to return type *) -val creates_builder : Typ.Procname.t -> bool +val creates_builder : Procname.t -> bool (** is the callee a static java method returning a [Builder] object? *) -val is_builder_passthrough : Typ.Procname.t -> bool +val is_builder_passthrough : Procname.t -> bool (** is the callee a non-static [Builder] method returning the same type as its receiver *) diff --git a/infer/src/concurrency/StarvationModels.ml b/infer/src/concurrency/StarvationModels.ml index 674c15618..771b586f8 100644 --- a/infer/src/concurrency/StarvationModels.ml +++ b/infer/src/concurrency/StarvationModels.ml @@ -11,11 +11,11 @@ module F = Format let is_synchronized_library_call = let targets = ["java.lang.StringBuffer"; "java.util.Hashtable"; "java.util.Vector"] in fun tenv pn -> - (not (Typ.Procname.is_constructor pn)) + (not (Procname.is_constructor pn)) && match pn with - | Typ.Procname.Java java_pname -> - let classname = Typ.Procname.Java.get_class_type_name java_pname in + | Procname.Java java_pname -> + let classname = Procname.Java.get_class_type_name java_pname in List.exists targets ~f:(PatternMatch.is_subtype_of_str tenv classname) | _ -> false @@ -182,7 +182,7 @@ let strict_mode_matcher = (* all public constructors of Socket with two or more arguments call connect *) ; { dont_search_superclasses with classname= "java.net.Socket" - ; methods= [Typ.Procname.Java.constructor_method_name] + ; methods= [Procname.Java.constructor_method_name] ; actuals_pred= (function [] | [_] -> false | _ -> true) } ; {dont_search_superclasses with classname= "java.net.DatagramSocket"; methods= ["connect"]} ; { dont_search_superclasses with @@ -298,9 +298,9 @@ let rec get_executor_thread_annotation_constraint tenv (receiver : HilExp.Access let get_run_method_from_runnable tenv runnable = let run_like_methods = ["run"; "call"] in let is_run_method = function - | Typ.Procname.Java pname when Typ.Procname.Java.(not (is_static pname)) -> + | Procname.Java pname when Procname.Java.(not (is_static pname)) -> (* confusingly, the parameter list in (non-static?) Java procnames does not contain [this] *) - Typ.Procname.Java.( + Procname.Java.( List.is_empty (get_parameters pname) && let methodname = get_method pname in @@ -329,8 +329,8 @@ let get_returned_executor ~attrs_of_pname tenv callee actuals = false ) ) in match (callee, actuals) with - | Typ.Procname.Java java_pname, [] -> ( - match Typ.Procname.Java.get_method java_pname with + | Procname.Java java_pname, [] -> ( + match Procname.Java.get_method java_pname with | ("getForegroundExecutor" | "getBackgroundExecutor") when Lazy.force type_check -> Some ForNonUIThread | "getUiThreadExecutorService" when Lazy.force type_check -> @@ -355,7 +355,7 @@ let is_handler_constructor = of_record { default with classname= "android.os.Handler" - ; methods= [Typ.Procname.Java.constructor_method_name] + ; methods= [Procname.Java.constructor_method_name] ; actuals_pred= (fun actuals -> not (List.is_empty actuals)) } @@ -365,7 +365,7 @@ let is_thread_constructor = { default with classname= "java.lang.Thread" ; search_superclasses= false - ; methods= [Typ.Procname.Java.constructor_method_name] } + ; methods= [Procname.Java.constructor_method_name] } let is_assume_true = diff --git a/infer/src/concurrency/StarvationModels.mli b/infer/src/concurrency/StarvationModels.mli index 623398c3a..40cb1077b 100644 --- a/infer/src/concurrency/StarvationModels.mli +++ b/infer/src/concurrency/StarvationModels.mli @@ -12,29 +12,29 @@ type severity = Low | Medium | High [@@deriving compare] val pp_severity : F.formatter -> severity -> unit -val may_block : Tenv.t -> Typ.Procname.t -> HilExp.t list -> severity option +val may_block : Tenv.t -> Procname.t -> HilExp.t list -> severity option (** is the method call potentially blocking, given the actuals passed? *) -val is_strict_mode_violation : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_strict_mode_violation : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_monitor_wait : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_monitor_wait : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_synchronized_library_call : Tenv.t -> Typ.Procname.t -> bool +val is_synchronized_library_call : Tenv.t -> Procname.t -> bool (** does the method call lock-then-unlock the underlying object? legacy Java containers like Vector do this, and can interact with explicit locking *) -val should_skip_analysis : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val should_skip_analysis : Tenv.t -> Procname.t -> HilExp.t list -> bool (** should we treat a method call as skip (eg library methods in guava) to avoid FPs? *) val is_annotated_nonblocking : - attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> Tenv.t -> Typ.Procname.t -> bool + attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> Tenv.t -> Procname.t -> bool (** is procedure transitively annotated [@Nonblocking] *) val is_annotated_lockless : - attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> Tenv.t -> Typ.Procname.t -> bool + attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> Tenv.t -> Procname.t -> bool (** is procedure transitively annotated [@Lockless] *) -val schedules_work : Tenv.t -> Typ.Procname.t -> bool +val schedules_work : Tenv.t -> Procname.t -> bool (** call known to schedule runnable first argument to some executor/handler or subclass *) (** an instance field holding a reference to an executor may be annotated as running on UI/non-UI @@ -47,32 +47,32 @@ val get_executor_thread_annotation_constraint : (** given an executor receiver, get its thread constraint, if any. [None] means lookup somehow failed, whereas [Some UnknownThread] means the receiver is an unannotated executor. *) -val get_run_method_from_runnable : Tenv.t -> HilExp.AccessExpression.t -> Typ.Procname.t option +val get_run_method_from_runnable : Tenv.t -> HilExp.AccessExpression.t -> Procname.t option (** given a receiver, find the [run()] method in the appropriate class *) val get_returned_executor : - attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) + attrs_of_pname:(Procname.t -> ProcAttributes.t option) -> Tenv.t - -> Typ.Procname.t + -> Procname.t -> HilExp.t list -> scheduler_thread_constraint option (** does the function return an executor and of which thread? *) -val schedules_work_on_ui_thread : Tenv.t -> Typ.Procname.t -> bool +val schedules_work_on_ui_thread : Tenv.t -> Procname.t -> bool (** method call known to directly schedule work on UI thread *) -val schedules_work_on_bg_thread : Tenv.t -> Typ.Procname.t -> bool +val schedules_work_on_bg_thread : Tenv.t -> Procname.t -> bool (** method call known to directly schedule work on BG thread *) -val is_getMainLooper : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_getMainLooper : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_handler_constructor : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_handler_constructor : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_thread_constructor : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_thread_constructor : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_future_get : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_future_get : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_future_is_done : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_future_is_done : Tenv.t -> Procname.t -> HilExp.t list -> bool -val is_assume_true : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool +val is_assume_true : Tenv.t -> Procname.t -> HilExp.t list -> bool (** is the callee equivalent to assuming its first argument true *) diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 35702fa12..6801ea24c 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -10,7 +10,7 @@ module L = Logging module MF = MarkupFormatter module Domain = StarvationDomain -let pname_pp = MF.wrap_monospaced Typ.Procname.pp +let pname_pp = MF.wrap_monospaced Procname.pp let attrs_of_pname = Summary.OnDisk.proc_resolve_attributes @@ -37,7 +37,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct type extras = FormalMap.t let log_parse_error error pname actuals = - L.debug Analysis Verbose "%s pname:%a actuals:%a@." error Typ.Procname.pp pname + L.debug Analysis Verbose "%s pname:%a actuals:%a@." error Procname.pp pname (PrettyPrintable.pp_collection ~pp_item:HilExp.pp) actuals @@ -238,7 +238,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let open StarvationModels in let get_lock_path = get_lock_path extras in let procname = Summary.get_proc_name summary in - let is_java = Typ.Procname.is_java procname in + let is_java = Procname.is_java procname in let do_lock locks loc astate = List.filter_map ~f:get_lock_path locks |> Domain.acquire ~tenv astate ~procname ~loc in @@ -310,8 +310,8 @@ module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.N let set_class_init_attributes procname (astate : Domain.t) = let open Domain in let attributes = - Typ.Procname.get_class_type_name procname - |> Option.map ~f:(fun tname -> Typ.Procname.(Java (Java.get_class_initializer tname))) + Procname.get_class_type_name procname + |> Option.map ~f:(fun tname -> Procname.(Java (Java.get_class_initializer tname))) |> Option.bind ~f:Payload.read_toplevel_procedure |> Option.value_map ~default:AttributeDomain.top ~f:(fun summary -> summary.attributes) in @@ -337,13 +337,13 @@ let set_constructor_attributes tenv procname (astate : Domain.t) = AttributeDomain.(fold (fun exp attr acc -> add (make_local exp) attr acc) attributes empty) in let attributes = - Typ.Procname.get_class_type_name procname + Procname.get_class_type_name procname (* retrieve its definition *) |> Option.bind ~f:(Tenv.lookup tenv) (* get the list of methods in the class *) |> Option.value_map ~default:[] ~f:(fun (tstruct : Struct.t) -> tstruct.methods) (* keep only the constructors *) - |> List.filter ~f:Typ.Procname.(function Java jname -> Java.is_constructor jname | _ -> false) + |> List.filter ~f:Procname.(function Java jname -> Java.is_constructor jname | _ -> false) (* get the summaries of the constructors *) |> List.filter_map ~f:Payload.read_toplevel_procedure (* make instances of [this] local to the current procedure and select only the attributes *) @@ -357,15 +357,15 @@ let set_constructor_attributes tenv procname (astate : Domain.t) = let set_initial_attributes tenv procname astate = match procname with - | Typ.Procname.Java java_pname when Typ.Procname.Java.is_class_initializer java_pname -> + | Procname.Java java_pname when Procname.Java.is_class_initializer java_pname -> (* we are analyzing the class initializer, don't go through on-demand again *) astate - | Typ.Procname.Java java_pname - when Typ.Procname.Java.(is_constructor java_pname || is_static java_pname) -> + | Procname.Java java_pname when Procname.Java.(is_constructor java_pname || is_static java_pname) + -> (* analyzing a constructor or static method, so we need the attributes established by the class initializer *) set_class_init_attributes procname astate - | Typ.Procname.Java _ -> + | Procname.Java _ -> (* we are analyzing an instance method, so we need constructor-established attributes which will include those by the class initializer *) set_constructor_attributes tenv procname astate @@ -386,9 +386,9 @@ let analyze_procedure {Callbacks.exe_env; summary} = if Procdesc.is_java_synchronized proc_desc then let lock = match procname with - | Typ.Procname.Java java_pname when Typ.Procname.Java.is_static java_pname -> + | Procname.Java java_pname when Procname.Java.is_static java_pname -> (* this is crafted so as to match synchronized(CLASSNAME.class) constructs *) - Typ.Procname.Java.get_class_type_name java_pname + Procname.Java.get_class_type_name java_pname |> Typ.Name.name |> Ident.string_to_name |> lock_of_class |> Option.some | _ -> FormalMap.get_formal_base 0 formals |> Option.map ~f:(fun base -> (base, [])) @@ -458,7 +458,7 @@ end = struct IssueType.lockless_violation - type report_t = {problem: problem; pname: Typ.Procname.t; ltr: Errlog.loc_trace; message: string} + type report_t = {problem: problem; pname: Procname.t; ltr: Errlog.loc_trace; message: string} type t = report_t list Location.Map.t SourceFile.Map.t @@ -603,10 +603,10 @@ let should_report pdesc = Procdesc.get_access pdesc <> PredSymb.Private && match Procdesc.get_proc_name pdesc with - | Typ.Procname.Java java_pname -> - (not (Typ.Procname.Java.is_autogen_method java_pname)) - && not (Typ.Procname.Java.is_class_initializer java_pname) - | Typ.Procname.ObjC_Cpp _ -> + | Procname.Java java_pname -> + (not (Procname.Java.is_autogen_method java_pname)) + && not (Procname.Java.is_class_initializer java_pname) + | Procname.ObjC_Cpp _ -> true | _ -> false @@ -695,7 +695,7 @@ let report_on_pair ((tenv, summary) as env) (pair : Domain.CriticalPair.t) repor let pname = Summary.get_proc_name summary in let event = pair.elem.event in let should_report_starvation = - CriticalPair.is_uithread pair && not (Typ.Procname.is_constructor pname) + CriticalPair.is_uithread pair && not (Procname.is_constructor pname) in let make_trace_and_loc () = let loc = CriticalPair.get_loc pair in @@ -800,7 +800,7 @@ let iter_summary ~f exe_env (summary : Summary.t) = module WorkHashSet = struct module T = struct - type t = Typ.Procname.t * Domain.CriticalPair.t + type t = Procname.t * Domain.CriticalPair.t (* [compare] for critical pairs ignore various fields, so using a generated equality here would break the polymorphic hash function. We use [phys_equal] instead and rely on the clients to @@ -828,7 +828,7 @@ let report exe_env work_set = match pair.elem.event with | LockAcquire lock -> let should_report_starvation = - CriticalPair.is_uithread pair && not (Typ.Procname.is_constructor procname) + CriticalPair.is_uithread pair && not (Procname.is_constructor procname) in WorkHashSet.fold (fun (other_procname, (other_pair : CriticalPair.t)) () acc -> diff --git a/infer/src/concurrency/starvationDomain.ml b/infer/src/concurrency/starvationDomain.ml index ee18f38a8..476ce5043 100644 --- a/infer/src/concurrency/starvationDomain.ml +++ b/infer/src/concurrency/starvationDomain.ml @@ -9,7 +9,7 @@ module F = Format module L = Logging module MF = MarkupFormatter -let pname_pp = MF.wrap_monospaced Typ.Procname.pp +let pname_pp = MF.wrap_monospaced Procname.pp module ThreadDomain = struct type t = UnknownThread | UIThread | BGThread | AnyThread [@@deriving compare, equal] @@ -165,8 +165,7 @@ end (** A lock acquisition with source location and procname in which it occurs. The location & procname are *ignored* for comparisons, and are only for reporting. *) module Acquisition = struct - type t = - {lock: Lock.t; loc: Location.t [@compare.ignore]; procname: Typ.Procname.t [@compare.ignore]} + type t = {lock: Lock.t; loc: Location.t [@compare.ignore]; procname: Procname.t [@compare.ignore]} [@@deriving compare] let pp fmt {lock} = Lock.pp_locks fmt lock @@ -180,7 +179,7 @@ module Acquisition = struct Errlog.make_trace_element 0 acquisition.loc description [] - let make_dummy lock = {lock; loc= Location.dummy; procname= Typ.Procname.Linters_dummy_method} + let make_dummy lock = {lock; loc= Location.dummy; procname= Procname.Linters_dummy_method} end (** Set of acquisitions; due to order over acquisitions, each lock appears at most once. *) @@ -194,7 +193,7 @@ end module LockState : sig include AbstractDomain.WithTop - val acquire : procname:Typ.Procname.t -> loc:Location.t -> Lock.t -> t -> t + val acquire : procname:Procname.t -> loc:Location.t -> Lock.t -> t -> t val release : Lock.t -> t -> t @@ -342,8 +341,7 @@ module CriticalPair = struct let initial_loc = get_loc t in Acquisitions.fold (fun {procname= acq_procname; loc= acq_loc} acc -> - if - Typ.Procname.equal procname acq_procname && Int.is_negative (Location.compare acq_loc acc) + if Procname.equal procname acq_procname && Int.is_negative (Location.compare acq_loc acc) then acq_loc else acc ) acquisitions initial_loc @@ -355,11 +353,11 @@ module CriticalPair = struct if include_acquisitions then Acquisitions.fold (fun ({procname} as acq : Acquisition.t) acc -> - Typ.Procname.Map.update procname + Procname.Map.update procname (function None -> Some [acq] | Some acqs -> Some (acq :: acqs)) acc ) - acquisitions Typ.Procname.Map.empty - else Typ.Procname.Map.empty + acquisitions Procname.Map.empty + else Procname.Map.empty in let header_step = let description = F.asprintf "%s%a" header pname_pp top_pname in @@ -370,7 +368,7 @@ module CriticalPair = struct let make_call_stack_step fake_first_call call_site = let procname = CallSite.pname call_site in let trace = - Typ.Procname.Map.find_opt procname acquisitions_map + Procname.Map.find_opt procname acquisitions_map |> Option.value ~default:[] (* many acquisitions can be on same line (eg, std::lock) so use stable sort to produce a deterministic trace *) @@ -458,7 +456,7 @@ module Attribute = struct | ThreadGuard | FutureDoneGuard of HilExp.AccessExpression.t | FutureDoneState of bool - | Runnable of Typ.Procname.t + | Runnable of Procname.t | WorkScheduler of StarvationModels.scheduler_thread_constraint | Looper of StarvationModels.scheduler_thread_constraint [@@deriving equal] @@ -483,7 +481,7 @@ module Attribute = struct | FutureDoneState state -> F.fprintf fmt "FutureDoneState(%b)" state | Runnable runproc -> - F.fprintf fmt "Runnable(%a)" Typ.Procname.pp runproc + F.fprintf fmt "Runnable(%a)" Procname.pp runproc | WorkScheduler c -> F.fprintf fmt "WorkScheduler(%a)" pp_constr c | Looper c -> @@ -519,10 +517,10 @@ module AttributeDomain = struct end module ScheduledWorkItem = struct - type t = {procname: Typ.Procname.t; loc: Location.t; thread: ThreadDomain.t} [@@deriving compare] + type t = {procname: Procname.t; loc: Location.t; thread: ThreadDomain.t} [@@deriving compare] let pp fmt {procname; loc; thread} = - F.fprintf fmt "{procname= %a; loc= %a; thread= %a}" Typ.Procname.pp procname Location.pp loc + F.fprintf fmt "{procname= %a; loc= %a; thread= %a}" Procname.pp procname Location.pp loc ThreadDomain.pp thread end @@ -731,10 +729,10 @@ let summary_of_astate : Procdesc.t -> t -> summary = let attributes = let var_predicate = match proc_name with - | Typ.Procname.Java jname when Typ.Procname.Java.is_class_initializer jname -> + | Procname.Java jname when Procname.Java.is_class_initializer jname -> (* only keep static attributes for the class initializer *) fun v -> Var.is_global v - | Typ.Procname.Java jname when Typ.Procname.Java.is_constructor jname -> + | Procname.Java jname when Procname.Java.is_constructor jname -> (* only keep static attributes or ones that have [this] as their root *) fun v -> Var.is_this v || Var.is_global v | _ -> diff --git a/infer/src/concurrency/starvationDomain.mli b/infer/src/concurrency/starvationDomain.mli index 5d63b9e54..a0148f94b 100644 --- a/infer/src/concurrency/starvationDomain.mli +++ b/infer/src/concurrency/starvationDomain.mli @@ -54,7 +54,7 @@ module LockState : AbstractDomain.WithTop (** a lock acquisition with location information *) module Acquisition : sig type t = private - {lock: Lock.t; loc: Location.t [@compare.ignore]; procname: Typ.Procname.t [@compare.ignore]} + {lock: Lock.t; loc: Location.t [@compare.ignore]; procname: Procname.t [@compare.ignore]} [@@deriving compare] end @@ -84,14 +84,14 @@ module CriticalPair : sig val get_loc : t -> Location.t (** outermost callsite location *) - val get_earliest_lock_or_call_loc : procname:Typ.Procname.t -> t -> Location.t + val get_earliest_lock_or_call_loc : procname:Procname.t -> t -> Location.t (** outermost callsite location OR lock acquisition *) val may_deadlock : t -> t -> bool (** two pairs can run in parallel and satisfy the conditions for deadlock *) val make_trace : - ?header:string -> ?include_acquisitions:bool -> Typ.Procname.t -> t -> Errlog.loc_trace + ?header:string -> ?include_acquisitions:bool -> Procname.t -> t -> Errlog.loc_trace val is_uithread : t -> bool (** is pair about an event on the UI thread *) @@ -111,7 +111,7 @@ module Attribute : sig | ThreadGuard (** is boolean equivalent to whether on UI thread *) | FutureDoneGuard of HilExp.AccessExpression.t (** boolean equivalent to [Future.isDone()] *) | FutureDoneState of bool (** is a [Future] ready for non-blocking consumption *) - | Runnable of Typ.Procname.t (** is a Runnable/Callable with given "run" procname *) + | Runnable of Procname.t (** is a Runnable/Callable with given "run" procname *) | WorkScheduler of StarvationModels.scheduler_thread_constraint (** exp is something that schedules work on the given thread *) | Looper of StarvationModels.scheduler_thread_constraint (** Android looper on given thread *) @@ -136,7 +136,7 @@ end (** A record of scheduled parallel work: the method scheduled to run, where, and on what thread. *) module ScheduledWorkItem : sig - type t = {procname: Typ.Procname.t; loc: Location.t; thread: ThreadDomain.t} + type t = {procname: Procname.t; loc: Location.t; thread: ThreadDomain.t} include PrettyPrintable.PrintableOrderedType with type t := t end @@ -153,23 +153,23 @@ type t = include AbstractDomain.WithBottom with type t := t -val acquire : ?tenv:Tenv.t -> t -> procname:Typ.Procname.t -> loc:Location.t -> Lock.t list -> t +val acquire : ?tenv:Tenv.t -> t -> procname:Procname.t -> loc:Location.t -> Lock.t list -> t (** simultaneously acquire a number of locks, no-op if list is empty *) val release : t -> Lock.t list -> t (** simultaneously release a number of locks, no-op if list is empty *) -val blocking_call : callee:Typ.Procname.t -> StarvationModels.severity -> loc:Location.t -> t -> t +val blocking_call : callee:Procname.t -> StarvationModels.severity -> loc:Location.t -> t -> t val wait_on_monitor : loc:Location.t -> HilExp.t list -> t -> t -val future_get : callee:Typ.Procname.t -> loc:Location.t -> HilExp.t list -> t -> t +val future_get : callee:Procname.t -> loc:Location.t -> HilExp.t list -> t -> t -val strict_mode_call : callee:Typ.Procname.t -> loc:Location.t -> t -> t +val strict_mode_call : callee:Procname.t -> loc:Location.t -> t -> t val add_guard : acquire_now:bool - -> procname:Typ.Procname.t + -> procname:Procname.t -> loc:Location.t -> Tenv.t -> t @@ -178,7 +178,7 @@ val add_guard : -> t (** Install a mapping from the guard expression to the lock provided, and optionally lock it. *) -val lock_guard : procname:Typ.Procname.t -> loc:Location.t -> Tenv.t -> t -> HilExp.t -> t +val lock_guard : procname:Procname.t -> loc:Location.t -> Tenv.t -> t -> HilExp.t -> t (** Acquire the lock the guard was constructed with. *) val remove_guard : t -> HilExp.t -> t @@ -188,7 +188,7 @@ val unlock_guard : t -> HilExp.t -> t (** Release the lock the guard was constructed with. *) val schedule_work : - Location.t -> StarvationModels.scheduler_thread_constraint -> t -> Typ.Procname.t -> t + Location.t -> StarvationModels.scheduler_thread_constraint -> t -> Procname.t -> t (** record the fact that a method is scheduled to run on a certain thread/executor *) type summary = diff --git a/infer/src/infer.ml b/infer/src/infer.ml index bfc4affb0..5e955b5f0 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -188,10 +188,10 @@ let () = DB.Results_dir.init ~debug:true source_file ; (* collect the CFGs for all the procedures in [source_file] *) let proc_names = SourceFiles.proc_names_of_source source_file in - let cfgs = Typ.Procname.Hash.create (List.length proc_names) in + let cfgs = Procname.Hash.create (List.length proc_names) in List.iter proc_names ~f:(fun proc_name -> Procdesc.load proc_name - |> Option.iter ~f:(fun cfg -> Typ.Procname.Hash.add cfgs proc_name cfg) ) ; + |> Option.iter ~f:(fun cfg -> Procname.Hash.add cfgs proc_name cfg) ) ; (* emit the dot file in captured/... *) DotCfg.emit_frontend_cfg source_file cfgs ) ; L.result "CFGs written in %s/*/%s@." Config.captured_dir Config.dotty_frontend_output ) diff --git a/infer/src/java/JProcname.ml b/infer/src/java/JProcname.ml index 546e273f1..06e2c060e 100644 --- a/infer/src/java/JProcname.ml +++ b/infer/src/java/JProcname.ml @@ -267,14 +267,13 @@ let create_procname ~classname ~methodname ~signature ~use_signature = let java_type_args = List.map ~f:JNI.to_java_type args in let java_type_ret_typ = if - String.equal methodname Typ.Procname.Java.constructor_method_name - || String.equal methodname Typ.Procname.Java.class_initializer_method_name + String.equal methodname Procname.Java.constructor_method_name + || String.equal methodname Procname.Java.class_initializer_method_name then None else Some (JNI.to_java_type ret_typ) in - Typ.Procname.Java - (Typ.Procname.Java.make name java_type_ret_typ methodname java_type_args - Typ.Procname.Java.Non_Static) + Procname.Java + (Procname.Java.make name java_type_ret_typ methodname java_type_args Procname.Java.Non_Static) let make_void_signature_procname ~classname ~methodname = diff --git a/infer/src/java/JProcname.mli b/infer/src/java/JProcname.mli index 2e49f7bcd..e6bc5e9e8 100644 --- a/infer/src/java/JProcname.mli +++ b/infer/src/java/JProcname.mli @@ -33,13 +33,13 @@ module JNI : sig val parse_method_str : string -> t list * t - val to_java_type : t -> Typ.Procname.Java.java_type + val to_java_type : t -> Procname.Java.java_type val pp : Format.formatter -> t -> unit end end val create_procname : - classname:string -> methodname:string -> signature:string -> use_signature:bool -> Typ.Procname.t + classname:string -> methodname:string -> signature:string -> use_signature:bool -> Procname.t -val make_void_signature_procname : classname:string -> methodname:string -> Typ.Procname.t +val make_void_signature_procname : classname:string -> methodname:string -> Procname.t diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index 3029ce4b0..c0906ffea 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -38,7 +38,7 @@ let add_models jar_filename = else L.(die InternalError) "Java model file not found" -let is_model procname = String.Set.mem !models_specs_filenames (Typ.Procname.to_filename procname) +let is_model procname = String.Set.mem !models_specs_filenames (Procname.to_filename procname) let split_classpath = String.split ~on:JFile.sep @@ -245,7 +245,7 @@ type program = { classpath: classpath ; models: classmap ; mutable classmap: classmap - ; callees: callee_status Typ.Procname.Hash.t } + ; callees: callee_status Procname.Hash.t } let get_classmap program = program.classmap @@ -259,16 +259,16 @@ let add_class cn jclass program = program.classmap <- JBasics.ClassMap.add cn jclass program.classmap -let set_callee_translated program pname = Typ.Procname.Hash.replace program.callees pname Translated +let set_callee_translated program pname = Procname.Hash.replace program.callees pname Translated let add_missing_callee program pname cn ms = - if not (Typ.Procname.Hash.mem program.callees pname) then - Typ.Procname.Hash.add program.callees pname (Missing (cn, ms)) + if not (Procname.Hash.mem program.callees pname) then + Procname.Hash.add program.callees pname (Missing (cn, ms)) let iter_missing_callees program ~f = let select proc_name = function Translated -> () | Missing (cn, ms) -> f proc_name cn ms in - Typ.Procname.Hash.iter select program.callees + Procname.Hash.iter select program.callees let cleanup program = Javalib.close_class_path program.classpath.channel @@ -309,7 +309,7 @@ let load_program classpath classes = { classpath= {path= classpath; channel= Javalib.class_path classpath} ; models ; classmap= JBasics.ClassMap.empty - ; callees= Typ.Procname.Hash.create 128 } + ; callees= Procname.Hash.create 128 } in JBasics.ClassSet.iter (fun cn -> ignore (lookup_node cn program)) classes ; L.(debug Capture Medium) "done@." ; diff --git a/infer/src/java/jClasspath.mli b/infer/src/java/jClasspath.mli index 5198a5505..559e64a2f 100644 --- a/infer/src/java/jClasspath.mli +++ b/infer/src/java/jClasspath.mli @@ -13,7 +13,7 @@ val add_models : string -> unit (** Adds the set of procnames for the models of Java libraries so that methods with similar names are skipped during the capture *) -val is_model : Typ.Procname.t -> bool +val is_model : Procname.t -> bool (** Check if there is a model for the given procname *) (** map entry for source files with potential basename collision within the same compiler call *) @@ -46,11 +46,11 @@ val lookup_node : JBasics.class_name -> program -> JCode.jcode Javalib.interface (** retrieve a Java node from the classname *) val add_missing_callee : - program -> Typ.Procname.t -> JBasics.class_name -> JBasics.method_signature -> unit + program -> Procname.t -> JBasics.class_name -> JBasics.method_signature -> unit (** add the class name of method signature to the list of callees *) -val set_callee_translated : program -> Typ.Procname.t -> unit +val set_callee_translated : program -> Procname.t -> unit (** set that the CFG for the procedure has been created *) val iter_missing_callees : - program -> f:(Typ.Procname.t -> JBasics.class_name -> JBasics.method_signature -> unit) -> unit + program -> f:(Procname.t -> JBasics.class_name -> JBasics.method_signature -> unit) -> unit diff --git a/infer/src/java/jContext.ml b/infer/src/java/jContext.ml index 1626cb46f..6d3d29b73 100644 --- a/infer/src/java/jContext.ml +++ b/infer/src/java/jContext.ml @@ -101,9 +101,9 @@ let is_goto_jump context pc = with Caml.Not_found -> false -let exn_node_table = Typ.Procname.Hash.create 100 +let exn_node_table = Procname.Hash.create 100 -let reset_exn_node_table () = Typ.Procname.Hash.clear exn_node_table +let reset_exn_node_table () = Procname.Hash.clear exn_node_table let add_exn_node procname (exn_node : Procdesc.Node.t) = - Typ.Procname.Hash.add exn_node_table procname exn_node + Procname.Hash.add exn_node_table procname exn_node diff --git a/infer/src/java/jContext.mli b/infer/src/java/jContext.mli index 40a3ae3c7..5d24f84f0 100644 --- a/infer/src/java/jContext.mli +++ b/infer/src/java/jContext.mli @@ -69,5 +69,5 @@ val reset_pvar_type : t -> unit val reset_exn_node_table : unit -> unit (** resets the hashtable mapping methods to their exception nodes *) -val add_exn_node : Typ.Procname.t -> Procdesc.Node.t -> unit +val add_exn_node : Procname.t -> Procdesc.Node.t -> unit (** adds the exception node for a given method *) diff --git a/infer/src/java/jFrontend.ml b/infer/src/java/jFrontend.ml index 84c3af68b..cb855eaf7 100644 --- a/infer/src/java/jFrontend.ml +++ b/infer/src/java/jFrontend.ml @@ -143,7 +143,7 @@ let create_icfg source_file linereader program tenv icfg cn node = JClasspath.set_callee_translated program proc_name ; if JClasspath.is_model proc_name then (* do not translate the method if there is a model for it *) - L.debug Capture Verbose "Skipping method with a model: %a@." Typ.Procname.pp proc_name + L.debug Capture Verbose "Skipping method with a model: %a@." Procname.pp proc_name else try (* each procedure has different scope: start names from id 0 *) @@ -157,7 +157,7 @@ let create_icfg source_file linereader program tenv icfg cn node = add_cmethod source_file program linereader icfg cm proc_name with JBasics.Class_structure_error error -> L.internal_error "create_icfg raised JBasics.Class_structure_error %s on %a@." error - Typ.Procname.pp proc_name + 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 c01eb1c86..c64b54683 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -90,7 +90,7 @@ let do_all_files sources program = Config.skip_analysis_in_path in is_path_matching (SourceFile.to_rel_path source_file) - || Inferconfig.skip_translation_matcher source_file Typ.Procname.empty_block + || Inferconfig.skip_translation_matcher source_file Procname.empty_block in let translate_source_file basename (package_opt, _) source_file = if not (skip source_file) then diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 337ee32af..a73818ca0 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -18,14 +18,14 @@ exception Frontend_error of string (** Fix the line associated to a method definition. Since Sawja often reports a method off by a few lines, we search backwards for a line where the method name is. *) let fix_method_definition_line linereader proc_name loc = - let proc_name_java = match proc_name with Typ.Procname.Java p -> p | _ -> assert false in + let proc_name_java = match proc_name with Procname.Java p -> p | _ -> assert false in let method_name = - if Typ.Procname.is_constructor proc_name then + if 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 (Typ.Procname.Java.get_simple_class_name proc_name_java) - else Typ.Procname.Java.get_method proc_name_java + inner_class_name (Procname.Java.get_simple_class_name proc_name_java) + else Procname.Java.get_method proc_name_java in let regex = Str.regexp (Str.quote method_name) in let method_is_defined_here linenum = @@ -104,9 +104,9 @@ let formals_from_signature program tenv cn ms kind = in let init_arg_list = match kind with - | Typ.Procname.Java.Static -> + | Procname.Java.Static -> [] - | Typ.Procname.Java.Non_Static -> + | Procname.Java.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)) @@ -452,7 +452,7 @@ let create_cm_procdesc source_file program linereader icfg cm proc_name = Some (procdesc, start_node, exit_node, exn_node, jbir_code) with JBir.Subroutine -> L.internal_error "create_procdesc raised JBir.Subroutine when translating %a in %a@." - Typ.Procname.pp proc_name SourceFile.pp source_file ; + Procname.pp proc_name SourceFile.pp source_file ; None @@ -656,7 +656,7 @@ let method_invocation (context : JContext.t) loc pc var_opt cn ms sil_obj_opt ex ~init expr_list in let callee_procname = - let proc = Typ.Procname.from_string_c_fun (JBasics.ms_name ms) in + let proc = 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 @@ -697,8 +697,8 @@ let method_invocation (context : JContext.t) loc pc var_opt cn ms sil_obj_opt ex call_ret_instrs sil_var in let is_close = function - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_close java_pname + | Procname.Java java_pname -> + Procname.Java.is_close java_pname | _ -> false in @@ -721,7 +721,7 @@ let method_invocation (context : JContext.t) loc pc var_opt cn ms sil_obj_opt ex call_instrs | ((_, {Typ.desc= Typ.Tptr ({desc= Tstruct typename}, _)}) as exp) :: _ (* add a file attribute when calling the constructor of a subtype of Closeable *) - when Typ.Procname.is_constructor callee_procname + when Procname.is_constructor callee_procname && AndroidFramework.is_autocloseable tenv typename && not (PatternMatch.supertype_exists tenv is_non_resource_closeable typename) -> let set_file_attr = @@ -846,7 +846,7 @@ let instruction (context : JContext.t) pc instr : translation = Instr (create_node node_kind (instrs @ [deref_instr; instr])) in let create_node_kind procname = - let procname_string = Typ.Procname.to_string procname in + let procname_string = Procname.to_string procname in Procdesc.Node.Stmt_node (Call procname_string) in try @@ -982,7 +982,7 @@ let 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 - Typ.Procname.Java.Non_Static + Procname.Java.Non_Static in let pvar = JContext.set_pvar context var class_type in let set_instr = @@ -1024,7 +1024,7 @@ let instruction (context : JContext.t) pc instr : translation = in let callee_procname, call_instrs = method_invocation context loc pc var_opt cn ms sil_obj_opt args I_Static - Typ.Procname.Java.Static + Procname.Java.Static in let node_kind = create_node_kind callee_procname in let call_node = create_node node_kind (instrs @ call_instrs) in @@ -1035,7 +1035,7 @@ let 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 - Typ.Procname.Java.Non_Static + Procname.Java.Non_Static in let node_kind = create_node_kind callee_procname in let call_node = create_node node_kind (instrs @ call_instrs) in @@ -1073,7 +1073,7 @@ let instruction (context : JContext.t) pc instr : translation = let callee_procname, call_instrs = method_invocation context loc pc var_opt cn ms (Some (sil_obj_expr, sil_obj_type)) - args I_Special Typ.Procname.Java.Non_Static + args I_Special Procname.Java.Non_Static in let node_kind = create_node_kind callee_procname in let call_node = create_node node_kind (instrs @ call_instrs) in diff --git a/infer/src/java/jTrans.mli b/infer/src/java/jTrans.mli index 4b8d024db..8fe9563c1 100644 --- a/infer/src/java/jTrans.mli +++ b/infer/src/java/jTrans.mli @@ -24,7 +24,7 @@ val create_callee_attributes : -> JClasspath.program -> JBasics.class_name -> JBasics.method_signature - -> Typ.Procname.t + -> Procname.t -> ProcAttributes.t option val create_am_procdesc : @@ -32,7 +32,7 @@ val create_am_procdesc : -> JClasspath.program -> JContext.icfg -> Javalib.abstract_method - -> Typ.Procname.t + -> Procname.t -> Procdesc.t (** Create the procedure description for an abstract method *) @@ -41,7 +41,7 @@ val create_native_procdesc : -> JClasspath.program -> JContext.icfg -> JCode.jcode Javalib.concrete_method - -> Typ.Procname.t + -> Procname.t -> Procdesc.t (** Create the procedure description for a concrete method *) @@ -51,7 +51,7 @@ val create_empty_procdesc : -> Printer.LineReader.t -> JContext.icfg -> JCode.jcode Javalib.concrete_method - -> Typ.Procname.t + -> Procname.t -> Procdesc.t val create_cm_procdesc : @@ -60,7 +60,7 @@ val create_cm_procdesc : -> Printer.LineReader.t -> JContext.icfg -> JCode.jcode Javalib.concrete_method - -> Typ.Procname.t + -> Procname.t -> (Procdesc.t * Procdesc.Node.t * Procdesc.Node.t * Procdesc.Node.t * JBir.t) option (** [create_procdesc source_file program linereader icfg cm proc_name] creates a procedure description for the concrete method cm and adds it to cfg *) diff --git a/infer/src/java/jTransType.ml b/infer/src/java/jTransType.ml index 28a571819..b98339a78 100644 --- a/infer/src/java/jTransType.ml +++ b/infer/src/java/jTransType.ml @@ -197,7 +197,7 @@ let method_signature_names ms = let get_method_kind m = - if Javalib.is_static_method m then Typ.Procname.Java.Static else Typ.Procname.Java.Non_Static + if Javalib.is_static_method m then Procname.Java.Static else Procname.Java.Non_Static let create_fieldname cn fs = @@ -282,9 +282,9 @@ let rec get_method_procname program tenv cn ms method_kind = let return_type_name, method_name, args_type_name = method_signature_names ms in let class_name = Typ.Name.Java.from_string (JBasics.cn_name cn) in let proc_name_java = - Typ.Procname.Java.make class_name return_type_name method_name args_type_name method_kind + Procname.Java.make class_name return_type_name method_name args_type_name method_kind in - Typ.Procname.Java proc_name_java + Procname.Java proc_name_java (* create a mangled procname from an abstract or concrete method *) diff --git a/infer/src/java/jTransType.mli b/infer/src/java/jTransType.mli index f9727d0a4..075371e33 100644 --- a/infer/src/java/jTransType.mli +++ b/infer/src/java/jTransType.mli @@ -13,19 +13,19 @@ open Sawja_pack val create_fieldname : JBasics.class_name -> JBasics.field_signature -> Fieldname.t (** translate the name of the field *) -val get_method_kind : JCode.jcode Javalib.jmethod -> Typ.Procname.Java.kind +val get_method_kind : JCode.jcode Javalib.jmethod -> Procname.Java.kind val get_method_procname : JClasspath.program -> Tenv.t -> JBasics.class_name -> JBasics.method_signature - -> Typ.Procname.Java.kind - -> Typ.Procname.t + -> Procname.Java.kind + -> Procname.t (** returns a procedure name based on the class name and the method's signature *) val translate_method_name : - JClasspath.program -> Tenv.t -> JCode.jcode Javalib.jmethod -> Typ.Procname.t + JClasspath.program -> Tenv.t -> JCode.jcode Javalib.jmethod -> Procname.t (** translate the SIL procedure name of the Java method *) val get_class_struct_typ : JClasspath.program -> Tenv.t -> JBasics.class_name -> Struct.t diff --git a/infer/src/labs/00_dummy_checker/ResourceLeaks.ml b/infer/src/labs/00_dummy_checker/ResourceLeaks.ml index 5c56a82d0..880c8f49b 100644 --- a/infer/src/labs/00_dummy_checker/ResourceLeaks.ml +++ b/infer/src/labs/00_dummy_checker/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let _acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let _releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -94,5 +94,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary post summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/01_integer_domain/ResourceLeaks.ml b/infer/src/labs/01_integer_domain/ResourceLeaks.ml index 544c06770..8d51fd9cb 100644 --- a/infer/src/labs/01_integer_domain/ResourceLeaks.ml +++ b/infer/src/labs/01_integer_domain/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -101,5 +101,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary post summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/02_domain_join/ResourceLeaks.ml b/infer/src/labs/02_domain_join/ResourceLeaks.ml index 544c06770..8d51fd9cb 100644 --- a/infer/src/labs/02_domain_join/ResourceLeaks.ml +++ b/infer/src/labs/02_domain_join/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -101,5 +101,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary post summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/03_domain_top/ResourceLeaks.ml b/infer/src/labs/03_domain_top/ResourceLeaks.ml index 544c06770..8d51fd9cb 100644 --- a/infer/src/labs/03_domain_top/ResourceLeaks.ml +++ b/infer/src/labs/03_domain_top/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -101,5 +101,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary post summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/04_interprocedural/ResourceLeaks.ml b/infer/src/labs/04_interprocedural/ResourceLeaks.ml index b0e8d9dad..0d02c5b3e 100644 --- a/infer/src/labs/04_interprocedural/ResourceLeaks.ml +++ b/infer/src/labs/04_interprocedural/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -115,5 +115,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary post summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml b/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml index d4f54aea1..5e2d94eaf 100644 --- a/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml +++ b/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -123,5 +123,5 @@ let checker {Callbacks.summary; proc_desc; tenv} : Summary.t = Payload.update_summary (ResourceLeakDomain.Summary.make formal_map post) summary | None -> L.(die InternalError) - "Analyzer failed to compute post for %a" Typ.Procname.pp + "Analyzer failed to compute post for %a" Procname.pp (Procdesc.get_proc_name proc_data.pdesc) diff --git a/infer/src/labs/ResourceLeaks.ml b/infer/src/labs/ResourceLeaks.ml index 31fbab304..21219081c 100644 --- a/infer/src/labs/ResourceLeaks.ml +++ b/infer/src/labs/ResourceLeaks.ml @@ -35,21 +35,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_closeable_procname tenv procname = match procname with - | Typ.Procname.Java java_procname -> + | Procname.Java java_procname -> is_closeable_typename tenv - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_procname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname)) | _ -> false let _acquires_resource tenv procname = (* We assume all constructors of a subclass of Closeable acquire a resource *) - Typ.Procname.is_constructor procname && is_closeable_procname tenv procname + Procname.is_constructor procname && is_closeable_procname tenv procname let _releases_resource tenv procname = (* We assume the close method of a Closeable releases all of its resources *) - String.equal "close" (Typ.Procname.get_method procname) && is_closeable_procname tenv procname + String.equal "close" (Procname.get_method procname) && is_closeable_procname tenv procname (** Take an abstract state and instruction, produce a new abstract state *) @@ -95,4 +95,4 @@ let checker {Callbacks.summary; exe_env} : Summary.t = report_if_leak post summary proc_data ; Payload.update_summary post summary | None -> - L.(die InternalError) "Analyzer failed to compute post for %a" Typ.Procname.pp proc_name + L.(die InternalError) "Analyzer failed to compute post for %a" Procname.pp proc_name diff --git a/infer/src/nullsafe/AnnotatedSignature.ml b/infer/src/nullsafe/AnnotatedSignature.ml index 43bae82dc..a6fe35951 100644 --- a/infer/src/nullsafe/AnnotatedSignature.ml +++ b/infer/src/nullsafe/AnnotatedSignature.ml @@ -134,7 +134,7 @@ let pp proc_name fmt annotated_signature = let mode_as_string = if annotated_signature.is_strict_mode then "Strict" else "Def" in F.fprintf fmt "[%s] %a%a %a (%a )" mode_as_string pp_ia ret_annotation_deprecated AnnotatedType.pp ret_annotated_type - (Typ.Procname.pp_simplified_string ~withclass:false) + (Procname.pp_simplified_string ~withclass:false) proc_name (Pp.comma_seq pp_annotated_param) annotated_signature.params @@ -175,7 +175,7 @@ let set_modelled_nullability proc_name asig model_source (nullability_for_ret, p let fail () = L.die InternalError "Annotation for procedure %a has wrong number of arguments.@\n Annotated signature: %a" - Typ.Procname.pp_unique_id proc_name (pp proc_name) asig + Procname.pp_unique_id proc_name (pp proc_name) asig in let rec model_param_nullability original_params params_nullability = match (original_params, params_nullability) with diff --git a/infer/src/nullsafe/AnnotatedSignature.mli b/infer/src/nullsafe/AnnotatedSignature.mli index 12acc06e4..970d4d7cc 100644 --- a/infer/src/nullsafe/AnnotatedSignature.mli +++ b/infer/src/nullsafe/AnnotatedSignature.mli @@ -31,12 +31,12 @@ and model_source = InternalModel | ThirdPartyRepo of {filename: string; line_num val param_has_annot : (Annot.Item.t -> bool) -> Pvar.t -> t -> bool (** Check if the given parameter has an annotation in the given signature *) -val set_modelled_nullability : Typ.Procname.t -> t -> model_source -> bool * bool list -> t +val set_modelled_nullability : Procname.t -> t -> model_source -> bool * bool list -> t (** Override nullability for a function signature given its modelled nullability (for ret value and params) *) val get : is_strict_mode:bool -> ProcAttributes.t -> t (** Get a method signature with annotations from a proc_attributes. *) -val pp : Typ.Procname.t -> Format.formatter -> t -> unit +val pp : Procname.t -> Format.formatter -> t -> unit (** Pretty print a method signature with annotations. *) diff --git a/infer/src/nullsafe/AssignmentRule.ml b/infer/src/nullsafe/AssignmentRule.ml index 2d1afd404..590a72856 100644 --- a/infer/src/nullsafe/AssignmentRule.ml +++ b/infer/src/nullsafe/AssignmentRule.ml @@ -11,7 +11,7 @@ type violation = {is_strict_mode: bool; lhs: Nullability.t; rhs: Nullability.t} type assignment_type = | PassingParamToFunction of function_info | AssigningToField of Fieldname.t - | ReturningFromFunction of Typ.Procname.t + | ReturningFromFunction of Procname.t [@@deriving compare] and function_info = @@ -19,7 +19,7 @@ and function_info = ; model_source: AnnotatedSignature.model_source option ; actual_param_expression: string ; param_position: int - ; function_procname: Typ.Procname.t } + ; function_procname: Procname.t } let is_whitelisted_assignment ~is_strict_mode ~lhs ~rhs = match (is_strict_mode, lhs, rhs) with @@ -103,7 +103,7 @@ let bad_param_description param can be nullable according to API but it was just not annotated. So we phrase it differently to remain truthful, but as specific as possible. *) - let procname_str = Typ.Procname.to_simplified_string ~withclass:true function_procname in + let procname_str = Procname.to_simplified_string ~withclass:true function_procname in Format.asprintf "Third-party %a is missing a signature that would allow passing a nullable to param #%d%a. \ Actual argument %s%s. Consider adding the correct signature of %a to %s." @@ -125,7 +125,7 @@ let bad_param_description in Format.asprintf "%a: parameter #%d%a is declared non-nullable%s but the argument %s%s." MF.pp_monospaced - (Typ.Procname.to_simplified_string ~withclass:true function_procname) + (Procname.to_simplified_string ~withclass:true function_procname) param_position pp_param_name param_signature.mangled nonnull_evidence argument_description nullability_evidence_as_suffix @@ -190,7 +190,7 @@ let violation_description {is_strict_mode; lhs; rhs} ~assignment_location assign in Format.asprintf "%a: return type is declared non-nullable but the method returns %s%s." MF.pp_monospaced - (Typ.Procname.to_simplified_string ~withclass:false function_proc_name) + (Procname.to_simplified_string ~withclass:false function_proc_name) return_description nullability_evidence_as_suffix in let issue_type = get_issue_type assignment_type in diff --git a/infer/src/nullsafe/AssignmentRule.mli b/infer/src/nullsafe/AssignmentRule.mli index 10ebf302f..cfba73971 100644 --- a/infer/src/nullsafe/AssignmentRule.mli +++ b/infer/src/nullsafe/AssignmentRule.mli @@ -18,7 +18,7 @@ val check : type assignment_type = | PassingParamToFunction of function_info | AssigningToField of Fieldname.t - | ReturningFromFunction of Typ.Procname.t + | ReturningFromFunction of Procname.t [@@deriving compare] and function_info = @@ -26,7 +26,7 @@ and function_info = ; model_source: AnnotatedSignature.model_source option ; actual_param_expression: string ; param_position: int - ; function_procname: Typ.Procname.t } + ; function_procname: Procname.t } val violation_description : violation diff --git a/infer/src/nullsafe/DereferenceRule.ml b/infer/src/nullsafe/DereferenceRule.ml index 732781de5..ad197b173 100644 --- a/infer/src/nullsafe/DereferenceRule.ml +++ b/infer/src/nullsafe/DereferenceRule.ml @@ -9,7 +9,7 @@ open! IStd type violation = Nullability.t [@@deriving compare] type dereference_type = - | MethodCall of Typ.Procname.t + | MethodCall of Procname.t | AccessToField of Fieldname.t | AccessByIndex of {index_desc: string} | ArrayLengthAccess @@ -67,7 +67,7 @@ let violation_description nullability ~dereference_location dereference_type ~nu match dereference_type with | MethodCall method_name -> Format.sprintf "calling %s" - (MF.monospaced_to_string (Typ.Procname.to_simplified_string method_name)) + (MF.monospaced_to_string (Procname.to_simplified_string method_name)) | AccessToField field_name -> Format.sprintf "accessing field %s" (MF.monospaced_to_string (Fieldname.to_simplified_string field_name)) diff --git a/infer/src/nullsafe/DereferenceRule.mli b/infer/src/nullsafe/DereferenceRule.mli index bab4e4919..a3bfa4073 100644 --- a/infer/src/nullsafe/DereferenceRule.mli +++ b/infer/src/nullsafe/DereferenceRule.mli @@ -14,7 +14,7 @@ type violation [@@deriving compare] val check : is_strict_mode:bool -> Nullability.t -> (unit, violation) result type dereference_type = - | MethodCall of Typ.Procname.t + | MethodCall of Procname.t | AccessToField of Fieldname.t | AccessByIndex of {index_desc: string} | ArrayLengthAccess diff --git a/infer/src/nullsafe/ErrorRenderingUtils.ml b/infer/src/nullsafe/ErrorRenderingUtils.ml index de3b15b8f..ea4e3f9d2 100644 --- a/infer/src/nullsafe/ErrorRenderingUtils.ml +++ b/infer/src/nullsafe/ErrorRenderingUtils.ml @@ -42,7 +42,7 @@ let is_object_nullability_self_explanatory ~object_expression object_origin = Latter case is self-explanatory: it is easy to the user to jump to definition and check out the method annotation. *) - let method_name = Typ.Procname.to_simplified_string pname in + let method_name = Procname.to_simplified_string pname in String.is_suffix object_expression ~suffix:method_name (* These cases are not yet supported because they normally mean non-nullable case, for which we don't render important messages yet. @@ -68,8 +68,8 @@ type message_info = let get_method_class_name procname = match procname with - | Typ.Procname.Java java_pname -> - Some (Typ.Procname.Java.get_simple_class_name java_pname) + | Procname.Java java_pname -> + Some (Procname.Java.get_simple_class_name java_pname) | _ -> None @@ -85,7 +85,7 @@ let get_info object_origin = | TypeOrigin.MethodCall {pname; call_loc} -> let offending_object = Format.asprintf "%a" MarkupFormatter.pp_monospaced - (Typ.Procname.to_simplified_string ~withclass:true pname) + (Procname.to_simplified_string ~withclass:true pname) in let object_loc = call_loc in let suggested_third_party_sig_file = diff --git a/infer/src/nullsafe/InheritanceRule.ml b/infer/src/nullsafe/InheritanceRule.ml index 7ad36f61e..08f21a012 100644 --- a/infer/src/nullsafe/InheritanceRule.ml +++ b/infer/src/nullsafe/InheritanceRule.ml @@ -45,9 +45,9 @@ type violation_type = let violation_description _ violation_type ~base_proc_name ~overridden_proc_name = let module MF = MarkupFormatter in let nullable_annotation = "@Nullable" in - let base_method_descr = Typ.Procname.to_simplified_string ~withclass:true base_proc_name in + let base_method_descr = Procname.to_simplified_string ~withclass:true base_proc_name in let overridden_method_descr = - Typ.Procname.to_simplified_string ~withclass:true overridden_proc_name + Procname.to_simplified_string ~withclass:true overridden_proc_name in match violation_type with | InconsistentReturn -> diff --git a/infer/src/nullsafe/InheritanceRule.mli b/infer/src/nullsafe/InheritanceRule.mli index 29785b4ea..9304f10a0 100644 --- a/infer/src/nullsafe/InheritanceRule.mli +++ b/infer/src/nullsafe/InheritanceRule.mli @@ -31,6 +31,6 @@ val check : type_role -> base:Nullability.t -> overridden:Nullability.t -> (unit val violation_description : violation -> violation_type - -> base_proc_name:Typ.Procname.t - -> overridden_proc_name:Typ.Procname.t + -> base_proc_name:Procname.t + -> overridden_proc_name:Procname.t -> string diff --git a/infer/src/nullsafe/Initializers.ml b/infer/src/nullsafe/Initializers.ml index a7ae61f4e..94543d9f1 100644 --- a/infer/src/nullsafe/Initializers.ml +++ b/infer/src/nullsafe/Initializers.ml @@ -7,7 +7,7 @@ open! IStd -type init = Typ.Procname.t * Procdesc.t +type init = Procname.t * Procdesc.t let equal_class_opt = [%compare.equal: string option] @@ -23,8 +23,8 @@ let final_typestates initializers_current_class tenv typecheck_proc = let same_class = let get_class_opt pn = match pn with - | Typ.Procname.Java pn_java -> - Some (Typ.Procname.Java.get_class_name pn_java) + | Procname.Java pn_java -> + Some (Procname.Java.get_class_name pn_java) | _ -> None in @@ -51,15 +51,15 @@ let final_typestates initializers_current_class tenv typecheck_proc = let initializers_recursive : init list = let initializers_base_case = initializers_current_class in let res = ref [] in - let seen = ref Typ.Procname.Set.empty in + let seen = ref Procname.Set.empty in let mark_seen (initializers : init list) : unit = - List.iter ~f:(fun (pn, _) -> seen := Typ.Procname.Set.add pn !seen) initializers ; + List.iter ~f:(fun (pn, _) -> seen := 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 (Typ.Procname.Set.mem pn !seen)) initializers_new + List.filter ~f:(fun (pn, _) -> not (Procname.Set.mem pn !seen)) initializers_new in mark_seen initializers_new' ; if initializers_new' <> [] then fixpoint initializers_new' @@ -101,11 +101,7 @@ let pname_and_pdescs_with tenv curr_pname get_procs_in_file f = let get_class pn = - match pn with - | Typ.Procname.Java pn_java -> - Some (Typ.Procname.Java.get_class_name pn_java) - | _ -> - None + match pn with Procname.Java pn_java -> Some (Procname.Java.get_class_name pn_java) | _ -> None (** Typestates after the current procedure and all initializer procedures. *) @@ -134,7 +130,7 @@ let final_constructor_typestates_lazy tenv curr_pname get_procs_in_file typechec lazy (let constructors_current_class = pname_and_pdescs_with tenv curr_pname get_procs_in_file (fun (pname, _) -> - Typ.Procname.is_constructor pname - && equal_class_opt (get_class pname) (get_class curr_pname) ) + Procname.is_constructor pname && equal_class_opt (get_class pname) (get_class curr_pname) + ) in final_typestates constructors_current_class tenv typecheck_proc ) diff --git a/infer/src/nullsafe/Initializers.mli b/infer/src/nullsafe/Initializers.mli index 31e37d42f..5f148f814 100644 --- a/infer/src/nullsafe/Initializers.mli +++ b/infer/src/nullsafe/Initializers.mli @@ -20,17 +20,17 @@ open! IStd val final_initializer_typestates_lazy : Tenv.t - -> Typ.Procname.t + -> Procname.t -> Procdesc.t - -> (Typ.Procname.t -> Typ.Procname.t list) - -> (bool -> Typ.Procname.t -> Procdesc.t -> 'a option -> 'b * 'c option) - -> (Typ.Procname.t * 'c) list lazy_t + -> (Procname.t -> Procname.t list) + -> (bool -> Procname.t -> Procdesc.t -> 'a option -> 'b * 'c option) + -> (Procname.t * 'c) list lazy_t (** Typestates after the current constructor and all initializer procedures. *) val final_constructor_typestates_lazy : Tenv.t - -> Typ.Procname.t - -> (Typ.Procname.t -> Typ.Procname.t list) - -> (bool -> Typ.Procname.t -> Procdesc.t -> 'a option -> 'b * 'c option) - -> (Typ.Procname.t * 'c) list lazy_t + -> Procname.t + -> (Procname.t -> Procname.t list) + -> (bool -> Procname.t -> Procdesc.t -> 'a option -> 'b * 'c option) + -> (Procname.t * 'c) list lazy_t (** Typestates after all constructors. *) diff --git a/infer/src/nullsafe/NullabilityCheck.ml b/infer/src/nullsafe/NullabilityCheck.ml index 955b75a5a..4a7b1ac35 100644 --- a/infer/src/nullsafe/NullabilityCheck.ml +++ b/infer/src/nullsafe/NullabilityCheck.ml @@ -11,7 +11,7 @@ module L = Logging module MF = MarkupFormatter module CallSites = AbstractDomain.FiniteSet (CallSite) module NullableAP = AbstractDomain.Map (AccessPath) (CallSites) -module NullCheckedPname = AbstractDomain.InvertedSet (Typ.Procname) +module NullCheckedPname = AbstractDomain.InvertedSet (Procname) module Domain = AbstractDomain.Pair (NullableAP) (NullCheckedPname) module TransferFunctions (CFG : ProcCfg.S) = struct @@ -34,8 +34,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_non_objc_instance_method callee_pname = match callee_pname with - | Typ.Procname.Java java_pname -> - not (Typ.Procname.Java.is_static java_pname) + | Procname.Java java_pname -> + not (Procname.Java.is_static java_pname) | _ -> Option.exists ~f:(fun attributes -> @@ -52,10 +52,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct (Summary.OnDisk.proc_resolve_attributes callee_pname) - let is_blacklisted_method : Typ.Procname.t -> bool = + let is_blacklisted_method : Procname.t -> bool = let blacklist = ["URLWithString:"; "objectForKeyedSubscript:"] in fun proc_name -> - let simplified_callee_pname = Typ.Procname.to_simplified_string proc_name in + let simplified_callee_pname = Procname.to_simplified_string proc_name in List.exists ~f:(String.equal simplified_callee_pname) blacklist @@ -68,7 +68,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_objc_container_add_method proc_name = - let callee_pname = Typ.Procname.to_string proc_name in + let callee_pname = Procname.to_string proc_name in Str.string_match container_method_regex callee_pname 0 @@ -90,7 +90,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct Here, we explicitely want to lookup the annotations locally: either form the implementation when defined locally, or from the included headers *) let lookup_local_attributes = function - | Typ.Procname.Java _ as pname -> + | Procname.Java _ as pname -> (* Looking up the attribute according to the classpath *) Summary.OnDisk.proc_resolve_attributes pname | pname -> @@ -107,11 +107,11 @@ module TransferFunctions (CFG : ProcCfg.S) = struct try CallSites.min_elt call_sites with Caml.Not_found -> L.(die InternalError) - "Expecting a least one element in the set of call sites when analyzing %a" - Typ.Procname.pp pname + "Expecting a least one element in the set of call sites when analyzing %a" Procname.pp + pname in let simplified_pname = - Typ.Procname.to_simplified_string ~withclass:true (CallSite.pname call_site) + Procname.to_simplified_string ~withclass:true (CallSite.pname call_site) in let is_direct_dereference = match ap with @@ -144,9 +144,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | None -> [] | Some attributes -> - let description = - F.asprintf "definition of %s" (Typ.Procname.get_method callee_pname) - in + let description = F.asprintf "definition of %s" (Procname.get_method callee_pname) in let trace_element = Errlog.make_trace_element 1 attributes.ProcAttributes.loc description [] in diff --git a/infer/src/nullsafe/NullabilitySuggest.ml b/infer/src/nullsafe/NullabilitySuggest.ml index c58f42a2a..fd90b8896 100644 --- a/infer/src/nullsafe/NullabilitySuggest.ml +++ b/infer/src/nullsafe/NullabilitySuggest.ml @@ -160,8 +160,8 @@ let make_error_trace astate ap ud = let pretty_field_name proc_data field_name = match Summary.get_proc_name proc_data.ProcData.summary with - | Typ.Procname.Java jproc_name -> - let proc_class_name = Typ.Procname.Java.get_class_name jproc_name in + | Procname.Java jproc_name -> + let proc_class_name = Procname.Java.get_class_name jproc_name in let field_class_name = Fieldname.get_class_name field_name |> Typ.Name.name in if String.equal proc_class_name field_class_name then Fieldname.get_field_name field_name else Fieldname.to_simplified_string field_name @@ -173,7 +173,7 @@ let pretty_field_name proc_data field_name = (* Checks if a field name stems from a class outside the domain of what is analyzed by Infer *) let is_outside_codebase proc_name field_name = match proc_name with - | Typ.Procname.Java _ -> + | Procname.Java _ -> Typ.Name.Java.is_external_classname (Typ.Name.name (Fieldname.get_class_name field_name)) | _ -> false @@ -232,5 +232,5 @@ let checker {Callbacks.summary; exe_env} = | Some post -> report post proc_data | None -> - L.internal_error "Analyzer failed to compute post for %a@." Typ.Procname.pp proc_name ) ; + L.internal_error "Analyzer failed to compute post for %a@." Procname.pp proc_name ) ; summary diff --git a/infer/src/nullsafe/OverAnnotatedRule.ml b/infer/src/nullsafe/OverAnnotatedRule.ml index de03ceda2..9259b6ae7 100644 --- a/infer/src/nullsafe/OverAnnotatedRule.ml +++ b/infer/src/nullsafe/OverAnnotatedRule.ml @@ -26,7 +26,7 @@ let check ~what ~by_rhs_upper_bound = type violation_type = | FieldOverAnnoted of Fieldname.t - | ReturnOverAnnotated of Typ.Procname.t (** Return value of a method can be made non-nullable *) + | ReturnOverAnnotated of Procname.t (** Return value of a method can be made non-nullable *) [@@deriving compare] let violation_description _ violation_type = @@ -40,5 +40,5 @@ let violation_description _ violation_type = MF.pp_monospaced nullable_annotation | ReturnOverAnnotated proc_name -> Format.asprintf "Method %a is annotated with %a but never returns null." MF.pp_monospaced - (Typ.Procname.to_simplified_string proc_name) + (Procname.to_simplified_string proc_name) MF.pp_monospaced nullable_annotation diff --git a/infer/src/nullsafe/OverAnnotatedRule.mli b/infer/src/nullsafe/OverAnnotatedRule.mli index a8833b644..feb382b1e 100644 --- a/infer/src/nullsafe/OverAnnotatedRule.mli +++ b/infer/src/nullsafe/OverAnnotatedRule.mli @@ -26,7 +26,7 @@ val check : what:Nullability.t -> by_rhs_upper_bound:Nullability.t -> (unit, vio type violation_type = | FieldOverAnnoted of Fieldname.t - | ReturnOverAnnotated of Typ.Procname.t (** Return value of a method can be made non-nullable *) + | ReturnOverAnnotated of Procname.t (** Return value of a method can be made non-nullable *) [@@deriving compare] val violation_description : violation -> violation_type -> string diff --git a/infer/src/nullsafe/ThirdPartyAnnotationInfo.ml b/infer/src/nullsafe/ThirdPartyAnnotationInfo.ml index 806dcc50b..b906c7562 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationInfo.ml +++ b/infer/src/nullsafe/ThirdPartyAnnotationInfo.ml @@ -81,8 +81,8 @@ let lookup_related_sig_file {filenames} ~package = let lookup_related_sig_file_by_package storage procname = let package = match procname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.get_package java_pname + | Procname.Java java_pname -> + Procname.Java.get_package java_pname | _ -> None in diff --git a/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli b/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli index ec54cdd59..84ce84956 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli +++ b/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli @@ -33,6 +33,6 @@ val find_nullability_info : storage -> ThirdPartyMethod.unique_repr -> signature val lookup_related_sig_file : storage -> package:string -> string option (** If the package is third-party, return the relevant .sig file to add signatures for this package. *) -val lookup_related_sig_file_by_package : storage -> Typ.Procname.t -> string option +val lookup_related_sig_file_by_package : storage -> Procname.t -> string option (** If the function is third-party (based on its package), return relevant .sig file to add the signature NOTE: this DOES NOT look if the function is is already *) diff --git a/infer/src/nullsafe/ThirdPartyMethod.ml b/infer/src/nullsafe/ThirdPartyMethod.ml index b2e2b9c72..f2c993ce7 100644 --- a/infer/src/nullsafe/ThirdPartyMethod.ml +++ b/infer/src/nullsafe/ThirdPartyMethod.ml @@ -60,13 +60,13 @@ let java_type_to_string java_type = let unique_repr_of_java_proc_name java_proc_name = - let class_name = Typ.Procname.Java.get_class_name java_proc_name in + let class_name = Procname.Java.get_class_name java_proc_name in let method_name = - if Typ.Procname.Java.is_constructor java_proc_name then Constructor - else Method (Typ.Procname.Java.get_method java_proc_name) + if Procname.Java.is_constructor java_proc_name then Constructor + else Method (Procname.Java.get_method java_proc_name) in let param_types = - Typ.Procname.Java.get_parameters java_proc_name |> List.map ~f:java_type_to_string + Procname.Java.get_parameters java_proc_name |> List.map ~f:java_type_to_string in {class_name; method_name; param_types} diff --git a/infer/src/nullsafe/ThirdPartyMethod.mli b/infer/src/nullsafe/ThirdPartyMethod.mli index 580895749..3671f43ee 100644 --- a/infer/src/nullsafe/ThirdPartyMethod.mli +++ b/infer/src/nullsafe/ThirdPartyMethod.mli @@ -25,7 +25,7 @@ type unique_repr = and method_name = Constructor | Method of string -val unique_repr_of_java_proc_name : Typ.Procname.Java.t -> unique_repr +val unique_repr_of_java_proc_name : Procname.Java.t -> unique_repr val pp_unique_repr : Format.formatter -> unique_repr -> unit diff --git a/infer/src/nullsafe/eradicate.ml b/infer/src/nullsafe/eradicate.ml index 27dcdd747..4061176f5 100644 --- a/infer/src/nullsafe/eradicate.ml +++ b/infer/src/nullsafe/eradicate.ml @@ -192,9 +192,8 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct let filter_special_cases () = if ( match proc_name with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_access_method java_pname - || Typ.Procname.Java.is_external java_pname + | Procname.Java java_pname -> + Procname.Java.is_access_method java_pname || Procname.Java.is_external java_pname | _ -> false ) || (Procdesc.get_attributes proc_desc).ProcAttributes.is_bridge_method diff --git a/infer/src/nullsafe/eradicateCheckers.mli b/infer/src/nullsafe/eradicateCheckers.mli index 09d25f146..b4efb71f5 100644 --- a/infer/src/nullsafe/eradicateCheckers.mli +++ b/infer/src/nullsafe/eradicateCheckers.mli @@ -11,7 +11,7 @@ open! IStd val report_error : Tenv.t - -> Typ.Procname.t + -> Procname.t -> Procdesc.t -> IssueType.t -> Location.t diff --git a/infer/src/nullsafe/eradicateChecks.ml b/infer/src/nullsafe/eradicateChecks.ml index 56c33ac2d..6a28f5994 100644 --- a/infer/src/nullsafe/eradicateChecks.ml +++ b/infer/src/nullsafe/eradicateChecks.ml @@ -73,7 +73,7 @@ let check_condition tenv case_zero find_canonical_duplicate curr_pdesc node e ty in let do_instr = function | Sil.Call (_, Exp.Const (Const.Cfun pn), [_; (Exp.Sizeof {typ}, _)], _, _) - when Typ.Procname.equal pn BuiltinDecl.__instanceof && typ_is_throwable typ -> + when Procname.equal pn BuiltinDecl.__instanceof && typ_is_throwable typ -> throwable_found := true | _ -> () @@ -238,7 +238,7 @@ let check_constructor_initialization tenv find_canonical_duplicate curr_construc curr_constructor_pdesc start_node ~typestates_for_curr_constructor_and_all_initializer_methods ~typestates_for_all_constructors_incl_current loc : unit = State.set_node start_node ; - if Typ.Procname.is_constructor curr_constructor_pname then + if Procname.is_constructor curr_constructor_pname then match PatternMatch.get_this_type_nonstatic_methods_only (Procdesc.get_attributes curr_constructor_pdesc) @@ -366,8 +366,8 @@ let check_return_annotation tenv find_canonical_duplicate curr_pdesc ret_range (* Disables the warnings since it is not clear how to annotate the return value of lambdas *) | Some _ when match curr_pname with - | Typ.Procname.Java java_pname -> - Typ.Procname.Java.is_lambda java_pname + | Procname.Java java_pname -> + Procname.Java.is_lambda java_pname | _ -> false -> () @@ -417,11 +417,11 @@ let is_third_party_via_sig_files proc_name = let is_marked_third_party_in_config proc_name = match proc_name with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> (* TODO: migrate to the new way of checking for third party: use signatures repository instead of looking it up in config params. *) - Typ.Procname.Java.is_external java_pname + Procname.Java.is_external java_pname | _ -> false @@ -549,7 +549,7 @@ let check_inheritance_rule_for_signature find_canonical_duplicate tenv loc ~base (* Check return value *) match base_proc_name with (* TODO model this as unknown nullability and get rid of that check *) - | Typ.Procname.Java java_pname when not (Typ.Procname.Java.is_external java_pname) -> + | Procname.Java java_pname when not (Procname.Java.is_external java_pname) -> (* Check if return value is consistent with the base *) let base_nullability = AnnotatedNullability.get_nullability diff --git a/infer/src/nullsafe/immutableChecker.ml b/infer/src/nullsafe/immutableChecker.ml index 66055d3ad..da71a0621 100644 --- a/infer/src/nullsafe/immutableChecker.ml +++ b/infer/src/nullsafe/immutableChecker.ml @@ -32,7 +32,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." - (Typ.Procname.to_simplified_string curr_pname) + (Procname.to_simplified_string curr_pname) Typ.Name.pp name_given Typ.Name.pp name_expected in EradicateCheckers.report_error tenv curr_pname curr_pdesc diff --git a/infer/src/nullsafe/models.ml b/infer/src/nullsafe/models.ml index e16b07d27..5af4aea33 100644 --- a/infer/src/nullsafe/models.ml +++ b/infer/src/nullsafe/models.ml @@ -13,14 +13,14 @@ open ModelTables let match_method_name pn name = match pn with - | Typ.Procname.Java pn_java -> - String.equal (Typ.Procname.Java.get_method pn_java) name + | Procname.Java pn_java -> + String.equal (Procname.Java.get_method pn_java) name | _ -> false let table_has_procedure table proc_name = - let proc_id = Typ.Procname.to_unique_id proc_name in + let proc_id = Procname.to_unique_id proc_name in try ignore (Hashtbl.find table proc_id) ; true @@ -34,7 +34,7 @@ let table_has_procedure table proc_name = let get_modelled_annotated_signature_for_biabduction proc_attributes = let proc_name = proc_attributes.ProcAttributes.proc_name in let annotated_signature = AnnotatedSignature.get ~is_strict_mode:false proc_attributes in - let proc_id = Typ.Procname.to_unique_id proc_name in + let proc_id = Procname.to_unique_id proc_name in let lookup_models_nullable ann_sig = try let modelled_nullability = Hashtbl.find annotated_table_nullability proc_id in @@ -47,7 +47,7 @@ let get_modelled_annotated_signature_for_biabduction proc_attributes = let get_unique_repr proc_name = let java_proc_name = - match proc_name with Typ.Procname.Java java_proc_name -> Some java_proc_name | _ -> None + match proc_name with Procname.Java java_proc_name -> Some java_proc_name | _ -> None in Option.map java_proc_name ~f:ThirdPartyMethod.unique_repr_of_java_proc_name @@ -70,7 +70,7 @@ let get_modelled_annotated_signature tenv proc_attributes = PatternMatch.check_current_class_attributes Annotations.ia_is_nullsafe_strict tenv proc_name in let annotated_signature = AnnotatedSignature.get ~is_strict_mode proc_attributes in - let proc_id = Typ.Procname.to_unique_id proc_name in + let proc_id = Procname.to_unique_id proc_name in (* Look in the infer internal models *) let correct_by_internal_models ann_sig = try @@ -107,7 +107,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 = Typ.Procname.to_unique_id proc_name in + let proc_id = Procname.to_unique_id proc_name in Hashtbl.find_opt check_not_null_parameter_table proc_id diff --git a/infer/src/nullsafe/typeCheck.ml b/infer/src/nullsafe/typeCheck.ml index 8403a11e1..60641202f 100644 --- a/infer/src/nullsafe/typeCheck.ml +++ b/infer/src/nullsafe/typeCheck.ml @@ -13,7 +13,7 @@ module DExp = DecompiledExp (** Module to treat selected complex expressions as constants. *) module ComplexExpressions = struct - let procname_instanceof = Typ.Procname.equal BuiltinDecl.__instanceof + let procname_instanceof = Procname.equal BuiltinDecl.__instanceof let procname_is_false_on_null tenv pn = match PatternMatch.lookup_attributes tenv pn with @@ -62,7 +62,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) -> - Typ.Procname.to_unique_id pn + Procname.to_unique_id pn | DExp.Dconst c -> F.asprintf "%a" (Const.pp Pp.text) c | DExp.Dderef de -> @@ -101,7 +101,7 @@ end (* ComplexExpressions *) -type check_return_type = Typ.Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit +type check_return_type = Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit type find_canonical_duplicate = Procdesc.Node.t -> Procdesc.Node.t @@ -349,11 +349,11 @@ let convert_complex_exp_to_pvar tenv idenv curr_pname let constructor_check_calls_this curr_pname calls_this pn = match (curr_pname, pn) with - | Typ.Procname.Java curr_pname_java, Typ.Procname.Java pn_java -> + | Procname.Java curr_pname_java, Procname.Java pn_java -> if String.equal - (Typ.Procname.Java.get_class_name curr_pname_java) - (Typ.Procname.Java.get_class_name pn_java) + (Procname.Java.get_class_name curr_pname_java) + (Procname.Java.get_class_name pn_java) then calls_this := true | _ -> () @@ -362,7 +362,7 @@ let constructor_check_calls_this curr_pname calls_this pn = (* Drops hidden and synthetic parameters which we do not check in a call. *) let drop_unchecked_params calls_this curr_pname proc_attributes params = let pname = proc_attributes.ProcAttributes.proc_name in - if Typ.Procname.is_constructor pname then + if Procname.is_constructor pname then match PatternMatch.get_this_type_nonstatic_methods_only proc_attributes with | Some _ -> constructor_check_calls_this curr_pname calls_this pname ; @@ -387,7 +387,7 @@ let drop_unchecked_params calls_this curr_pname proc_attributes params = (* Drop parameters from the signature which we do not check in a call. *) let drop_unchecked_signature_params proc_attributes annotated_signature = if - Typ.Procname.is_constructor proc_attributes.ProcAttributes.proc_name + Procname.is_constructor proc_attributes.ProcAttributes.proc_name && proc_attributes.ProcAttributes.is_synthetic_method then List.take annotated_signature.AnnotatedSignature.params @@ -562,17 +562,17 @@ let do_map_put call_params callee_pname tenv loc node curr_pname curr_pdesc call let object_t = Typ.Name.Java.Split.java_lang_object in let parameters = [object_t] in pname_put - |> Typ.Procname.Java.replace_method_name "get" - |> Typ.Procname.Java.replace_return_type object_t - |> Typ.Procname.Java.replace_parameters parameters + |> Procname.Java.replace_method_name "get" + |> Procname.Java.replace_return_type object_t + |> Procname.Java.replace_parameters parameters in match call_params with | ((_, Exp.Lvar pv_map), _) :: ((_, exp_key), _) :: ((_, 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, Typ.Procname.Java callee_pname_java -> - let pname_get = Typ.Procname.Java (pname_get_from_pname_put callee_pname_java) in + | Some dexp_key, Procname.Java callee_pname_java -> + let pname_get = 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 @@ -680,14 +680,14 @@ let rec check_condition_for_sil_prune tenv idenv calls_this find_canonical_dupli let map_dexp = function | Some (DExp.Dretcall - (DExp.Dconst (Const.Cfun (Typ.Procname.Java pname_java)), args, loc, call_flags)) -> + (DExp.Dconst (Const.Cfun (Procname.Java pname_java)), args, loc, call_flags)) -> let pname_java' = let object_t = Typ.Name.Java.Split.java_lang_object in pname_java - |> Typ.Procname.Java.replace_method_name "get" - |> Typ.Procname.Java.replace_return_type object_t + |> Procname.Java.replace_method_name "get" + |> Procname.Java.replace_return_type object_t in - let fun_dexp = DExp.Dconst (Const.Cfun (Typ.Procname.Java pname_java')) in + let fun_dexp = DExp.Dconst (Const.Cfun (Procname.Java pname_java')) in Some (DExp.Dretcall (fun_dexp, args, loc, call_flags)) | _ -> None @@ -911,7 +911,7 @@ let calc_typestate_after_call find_canonical_duplicate calls_this checks tenv id do_preconditions_check_not_null instr_ref tenv find_canonical_duplicate node loc curr_pdesc curr_pname curr_annotated_signature checks call_params idenv index ~is_vararg:false typestate1 - | None when Typ.Procname.Java.is_vararg callee_pname_java -> + | None when Procname.Java.is_vararg callee_pname_java -> let last_parameter = List.length call_params in do_preconditions_check_not_null instr_ref tenv find_canonical_duplicate node loc curr_pdesc curr_pname curr_annotated_signature checks call_params idenv last_parameter @@ -946,14 +946,14 @@ let typecheck_sil_call_function find_canonical_duplicate checks tenv instr_ref t List.mapi ~f:(fun i (_, typ) -> let arg = - if Int.equal i 0 && not (Typ.Procname.Java.is_static callee_pname_java) then + if Int.equal i 0 && not (Procname.Java.is_static callee_pname_java) then Mangled.this else Printf.sprintf "arg%d" i |> Mangled.from_string in (arg, typ) ) etl_ in - let ret_type = Typ.Procname.Java.get_return_typ callee_pname_java in + let ret_type = Procname.Java.get_return_typ callee_pname_java in let proc_attributes = { (ProcAttributes.default (SourceFile.invalid __FILE__) callee_pname) with ProcAttributes.formals @@ -979,7 +979,7 @@ let typecheck_sil_call_function find_canonical_duplicate checks tenv instr_ref t drop_unchecked_signature_params callee_attributes callee_annotated_signature in let is_anonymous_inner_class_constructor = - Typ.Procname.Java.is_anonymous_inner_class_constructor callee_pname_java + Procname.Java.is_anonymous_inner_class_constructor callee_pname_java in let do_return (ret_ta, ret_typ) typestate' = let mk_return_range () = (ret_typ, ret_ta) in @@ -1061,12 +1061,12 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p check_field_assign () ; typestate2 (* Java `new` operators *) | Sil.Call ((id, _), Exp.Const (Const.Cfun pn), [(_, typ)], _, _) - when Typ.Procname.equal pn BuiltinDecl.__new || Typ.Procname.equal pn BuiltinDecl.__new_array -> + when Procname.equal pn BuiltinDecl.__new || Procname.equal pn BuiltinDecl.__new_array -> (* new never returns null *) TypeState.add_id id (typ, InferredNullability.create TypeOrigin.New) typestate (* Type cast *) | Sil.Call ((id, _), Exp.Const (Const.Cfun pn), (e, typ) :: _, loc, _) - when Typ.Procname.equal pn BuiltinDecl.__cast -> + when Procname.equal pn BuiltinDecl.__cast -> typecheck_expr_for_errors ~is_strict_mode find_canonical_duplicate curr_pdesc calls_this checks tenv node instr_ref typestate e loc ; let e', typestate' = @@ -1080,7 +1080,7 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p typestate' (* myarray.length *) | Sil.Call ((id, _), Exp.Const (Const.Cfun pn), [(array_exp, t)], loc, _) - when Typ.Procname.equal pn BuiltinDecl.__get_array_length -> + when Procname.equal pn BuiltinDecl.__get_array_length -> let _, ta = typecheck_expr ~is_strict_mode find_canonical_duplicate calls_this checks tenv node instr_ref curr_pdesc typestate array_exp @@ -1100,7 +1100,7 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p (* Normal call of a function *) | Sil.Call ( ret_id_typ - , Exp.Const (Const.Cfun (Typ.Procname.Java callee_pname_java as callee_pname)) + , Exp.Const (Const.Cfun (Procname.Java callee_pname_java as callee_pname)) , etl_ , loc , cflags ) -> diff --git a/infer/src/nullsafe/typeCheck.mli b/infer/src/nullsafe/typeCheck.mli index 48e701cf2..70a19d061 100644 --- a/infer/src/nullsafe/typeCheck.mli +++ b/infer/src/nullsafe/typeCheck.mli @@ -9,7 +9,7 @@ open! IStd (** Module type for the type checking functions. *) -type check_return_type = Typ.Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit +type check_return_type = Procname.t -> Procdesc.t -> Typ.t -> Typ.t option -> Location.t -> unit type find_canonical_duplicate = Procdesc.Node.t -> Procdesc.Node.t @@ -20,7 +20,7 @@ val typecheck_node : -> bool ref -> checks -> Idenv.t - -> Typ.Procname.t + -> Procname.t -> Procdesc.t -> find_canonical_duplicate -> AnnotatedSignature.t diff --git a/infer/src/nullsafe/typeErr.ml b/infer/src/nullsafe/typeErr.ml index ac3622288..59b447441 100644 --- a/infer/src/nullsafe/typeErr.ml +++ b/infer/src/nullsafe/typeErr.ml @@ -62,8 +62,8 @@ type err_instance = | Inconsistent_subclass of { inheritance_violation: InheritanceRule.violation ; violation_type: InheritanceRule.violation_type - ; base_proc_name: Typ.Procname.t - ; overridden_proc_name: Typ.Procname.t } + ; base_proc_name: Procname.t + ; overridden_proc_name: Procname.t } | Field_not_initialized of Fieldname.t | Over_annotation of { over_annotated_violation: OverAnnotatedRule.violation @@ -186,7 +186,7 @@ end (* Severity *) type st_report_error = - Typ.Procname.t + Procname.t -> Procdesc.t -> IssueType.t -> Location.t diff --git a/infer/src/nullsafe/typeErr.mli b/infer/src/nullsafe/typeErr.mli index f27800514..f030ebc38 100644 --- a/infer/src/nullsafe/typeErr.mli +++ b/infer/src/nullsafe/typeErr.mli @@ -38,8 +38,8 @@ type err_instance = | Inconsistent_subclass of { inheritance_violation: InheritanceRule.violation ; violation_type: InheritanceRule.violation_type - ; base_proc_name: Typ.Procname.t - ; overridden_proc_name: Typ.Procname.t } + ; base_proc_name: Procname.t + ; overridden_proc_name: Procname.t } | Field_not_initialized of Fieldname.t | Over_annotation of { over_annotated_violation: OverAnnotatedRule.violation @@ -60,7 +60,7 @@ type err_instance = val node_reset_forall : Procdesc.Node.t -> unit type st_report_error = - Typ.Procname.t + Procname.t -> Procdesc.t -> IssueType.t -> Location.t diff --git a/infer/src/nullsafe/typeOrigin.ml b/infer/src/nullsafe/typeOrigin.ml index d406ab44b..ddf018551 100644 --- a/infer/src/nullsafe/typeOrigin.ml +++ b/infer/src/nullsafe/typeOrigin.ml @@ -38,7 +38,7 @@ and field_origin = ; access_loc: Location.t } and method_call_origin = - { pname: Typ.Procname.t + { pname: Procname.t ; call_loc: Location.t ; annotated_signature: AnnotatedSignature.t ; is_library: bool } @@ -85,7 +85,7 @@ let rec to_string = function | This -> "this" | MethodCall {pname} -> - Printf.sprintf "Fun %s" (Typ.Procname.to_simplified_string pname) + Printf.sprintf "Fun %s" (Procname.to_simplified_string pname) | New -> "New" | ArrayLengthResult -> @@ -133,7 +133,7 @@ let get_method_ret_description pname call_loc line_number in Format.sprintf "call to %s%s%s" - (Typ.Procname.to_simplified_string ~withclass:should_show_class_name pname) + (Procname.to_simplified_string ~withclass:should_show_class_name pname) (atline call_loc) model_info diff --git a/infer/src/nullsafe/typeOrigin.mli b/infer/src/nullsafe/typeOrigin.mli index 1ca75740e..3500730a9 100644 --- a/infer/src/nullsafe/typeOrigin.mli +++ b/infer/src/nullsafe/typeOrigin.mli @@ -36,7 +36,7 @@ and field_origin = ; access_loc: Location.t } and method_call_origin = - { pname: Typ.Procname.t + { pname: Procname.t ; call_loc: Location.t ; annotated_signature: AnnotatedSignature.t ; is_library: bool } diff --git a/infer/src/opensource/FbThreadSafety.mli b/infer/src/opensource/FbThreadSafety.mli index e7aad6087..eda2a2650 100644 --- a/infer/src/opensource/FbThreadSafety.mli +++ b/infer/src/opensource/FbThreadSafety.mli @@ -7,10 +7,10 @@ open! IStd -val is_custom_init : Tenv.t -> Typ.Procname.t -> bool +val is_custom_init : Tenv.t -> Procname.t -> bool -val is_logging_method : Typ.Procname.t -> bool +val is_logging_method : Procname.t -> bool -val get_fbthreadsafe_class_annot : Typ.Procname.t -> Tenv.t -> (string * string) option +val get_fbthreadsafe_class_annot : Procname.t -> Tenv.t -> (string * string) option val message_fbthreadsafe_class : string -> string -> string diff --git a/infer/src/pulse/Pulse.ml b/infer/src/pulse/Pulse.ml index 1f00e4e85..a281b9120 100644 --- a/infer/src/pulse/Pulse.ml +++ b/infer/src/pulse/Pulse.ml @@ -54,8 +54,8 @@ module PulseTransferFunctions = struct (* injected destructors are precisely inserted where an object goes out of scope *) if flags.cf_injected_destructor then match (proc_name_of_call call_exp, actuals) with - | Some (Typ.Procname.ObjC_Cpp pname), [(Exp.Lvar pvar, typ)] - when Pvar.is_local pvar && not (Typ.Procname.ObjC_Cpp.is_inner_destructor pname) -> + | Some (Procname.ObjC_Cpp pname), [(Exp.Lvar pvar, typ)] + when Pvar.is_local pvar && not (Procname.ObjC_Cpp.is_inner_destructor pname) -> (* ignore inner destructors, only trigger out of scope on the final destructor call *) Some (pvar, typ) | _ -> diff --git a/infer/src/pulse/PulseAbductiveDomain.ml b/infer/src/pulse/PulseAbductiveDomain.ml index 36f1a3ca9..0c6e36c16 100644 --- a/infer/src/pulse/PulseAbductiveDomain.ml +++ b/infer/src/pulse/PulseAbductiveDomain.ml @@ -964,7 +964,7 @@ module PrePost = struct is for a path where [formal != 0] and we pass [0] then it will be an FP. Maybe the solution is to bake in some value analysis. *) let apply callee_proc_name call_location pre_post ~formals ~actuals astate = - L.d_printfln "Applying pre/post for %a(%a):@\n%a" Typ.Procname.pp callee_proc_name + L.d_printfln "Applying pre/post for %a(%a):@\n%a" Procname.pp callee_proc_name (Pp.seq ~sep:"," Var.pp) formals pp pre_post ; let empty_call_state = {astate; subst= AddressMap.empty; rev_subst= AddressMap.empty; visited= AddressSet.empty} diff --git a/infer/src/pulse/PulseAbductiveDomain.mli b/infer/src/pulse/PulseAbductiveDomain.mli index e138f40a3..982efe2eb 100644 --- a/infer/src/pulse/PulseAbductiveDomain.mli +++ b/infer/src/pulse/PulseAbductiveDomain.mli @@ -69,7 +69,7 @@ module Memory : sig val invalidate : AbstractValue.t * ValueHistory.t -> Invalidation.t -> Location.t -> t -> t - val get_closure_proc_name : AbstractValue.t -> t -> Typ.Procname.t option + val get_closure_proc_name : AbstractValue.t -> t -> Procname.t option val is_std_vector_reserved : AbstractValue.t -> t -> bool @@ -97,7 +97,7 @@ module PrePost : sig val of_post : Procdesc.t -> domain_t -> t val apply : - Typ.Procname.t + Procname.t -> Location.t -> t -> formals:Var.t list diff --git a/infer/src/pulse/PulseAttribute.ml b/infer/src/pulse/PulseAttribute.ml index 7c10432ba..5fb510ec1 100644 --- a/infer/src/pulse/PulseAttribute.ml +++ b/infer/src/pulse/PulseAttribute.ml @@ -30,7 +30,7 @@ module Attribute = struct | AddressOfStackVariable of Var.t * Location.t * ValueHistory.t | Arithmetic of Arithmetic.t * Trace.t | BoItv of Itv.ItvPure.t - | Closure of Typ.Procname.t + | Closure of Procname.t | Invalid of Invalidation.t * Trace.t | MustBeValid of Trace.t | StdVectorReserve @@ -43,12 +43,12 @@ module Attribute = struct let dummy_trace = Trace.Immediate {location= Location.dummy; history= []} - let closure_rank = Variants.to_rank (Closure (Typ.Procname.from_string_c_fun "")) + let closure_rank = Variants.to_rank (Closure (Procname.from_string_c_fun "")) let written_to_rank = Variants.to_rank (WrittenTo dummy_trace) let address_of_stack_variable_rank = - let pname = Typ.Procname.from_string_c_fun "" in + let pname = Procname.from_string_c_fun "" in let var = Var.of_pvar (Pvar.mk (Mangled.from_string "") pname) in let location = Location.dummy in Variants.to_rank (AddressOfStackVariable (var, location, [])) @@ -78,7 +78,7 @@ module Attribute = struct | BoItv bo_itv -> F.fprintf f "BoItv (%a)" Itv.ItvPure.pp bo_itv | Closure pname -> - Typ.Procname.pp f pname + Procname.pp f pname | Arithmetic (phi, trace) -> F.fprintf f "Arith %a" (Trace.pp ~pp_immediate:(fun fmt -> Arithmetic.pp fmt phi)) trace | Invalid (invalidation, trace) -> diff --git a/infer/src/pulse/PulseAttribute.mli b/infer/src/pulse/PulseAttribute.mli index e2f9250ad..dd8c8d6f8 100644 --- a/infer/src/pulse/PulseAttribute.mli +++ b/infer/src/pulse/PulseAttribute.mli @@ -16,7 +16,7 @@ type t = | AddressOfStackVariable of Var.t * Location.t * ValueHistory.t | Arithmetic of Arithmetic.t * Trace.t | BoItv of Itv.ItvPure.t - | Closure of Typ.Procname.t + | Closure of Procname.t | Invalid of Invalidation.t * Trace.t | MustBeValid of Trace.t | StdVectorReserve @@ -32,7 +32,7 @@ module Attributes : sig val get_address_of_stack_variable : t -> (Var.t * Location.t * ValueHistory.t) option - val get_closure_proc_name : t -> Typ.Procname.t option + val get_closure_proc_name : t -> Procname.t option val get_arithmetic : t -> (Arithmetic.t * Trace.t) option diff --git a/infer/src/pulse/PulseBaseMemory.mli b/infer/src/pulse/PulseBaseMemory.mli index 1cfba2b90..19ee31914 100644 --- a/infer/src/pulse/PulseBaseMemory.mli +++ b/infer/src/pulse/PulseBaseMemory.mli @@ -56,7 +56,7 @@ val invalidate : AbstractValue.t * ValueHistory.t -> Invalidation.t -> Location. val check_valid : AbstractValue.t -> t -> (unit, Invalidation.t * Trace.t) result -val get_closure_proc_name : AbstractValue.t -> t -> Typ.Procname.t option +val get_closure_proc_name : AbstractValue.t -> t -> Procname.t option val get_arithmetic : AbstractValue.t -> t -> (Arithmetic.t * Trace.t) option diff --git a/infer/src/pulse/PulseCallEvent.ml b/infer/src/pulse/PulseCallEvent.ml index 6bef6fd64..cf423a756 100644 --- a/infer/src/pulse/PulseCallEvent.ml +++ b/infer/src/pulse/PulseCallEvent.ml @@ -8,14 +8,14 @@ open! IStd module F = Format type t = - | Call of Typ.Procname.t + | Call of Procname.t | Model of string - | SkippedKnownCall of Typ.Procname.t + | SkippedKnownCall of Procname.t | SkippedUnknownCall of Exp.t [@@deriving compare] let pp_config ~verbose fmt = - let pp_proc_name = if verbose then Typ.Procname.pp else Typ.Procname.describe in + let pp_proc_name = if verbose then Procname.pp else Procname.describe in function | Call proc_name -> F.fprintf fmt "`%a`" pp_proc_name proc_name diff --git a/infer/src/pulse/PulseCallEvent.mli b/infer/src/pulse/PulseCallEvent.mli index 7198a434c..ad6b37ab3 100644 --- a/infer/src/pulse/PulseCallEvent.mli +++ b/infer/src/pulse/PulseCallEvent.mli @@ -9,9 +9,9 @@ open! IStd module F = Format type t = - | Call of Typ.Procname.t (** known function with summary *) + | Call of Procname.t (** known function with summary *) | Model of string (** hardcoded model *) - | SkippedKnownCall of Typ.Procname.t (** known function without summary *) + | SkippedKnownCall of Procname.t (** known function without summary *) | SkippedUnknownCall of Exp.t (** couldn't link the expression to a proc name *) [@@deriving compare] diff --git a/infer/src/pulse/PulseModels.ml b/infer/src/pulse/PulseModels.ml index 78b79d5a9..7c76740e9 100644 --- a/infer/src/pulse/PulseModels.ml +++ b/infer/src/pulse/PulseModels.ml @@ -339,7 +339,7 @@ end module ProcNameDispatcher = struct let dispatch : (Tenv.t, model, arg_payload) ProcnameDispatcher.Call.dispatcher = let open ProcnameDispatcher.Call in - let match_builtin builtin _ s = String.equal s (Typ.Procname.get_method builtin) in + let match_builtin builtin _ s = String.equal s (Procname.get_method builtin) in make_dispatcher [ +match_builtin BuiltinDecl.free <>$ capt_arg_payload $--> C.free ; +match_builtin BuiltinDecl.__delete <>$ capt_arg_payload $--> Cplusplus.delete diff --git a/infer/src/pulse/PulseModels.mli b/infer/src/pulse/PulseModels.mli index 76c196326..c4ef47c99 100644 --- a/infer/src/pulse/PulseModels.mli +++ b/infer/src/pulse/PulseModels.mli @@ -18,6 +18,6 @@ type model = exec_fun val dispatch : Tenv.t - -> Typ.Procname.t + -> Procname.t -> (AbstractValue.t * ValueHistory.t) ProcnameDispatcher.Call.FuncArg.t list -> model option diff --git a/infer/src/pulse/PulseOperations.ml b/infer/src/pulse/PulseOperations.ml index a09a3d55f..6bbc83675 100644 --- a/infer/src/pulse/PulseOperations.ml +++ b/infer/src/pulse/PulseOperations.ml @@ -527,5 +527,5 @@ let call ~caller_summary call_loc callee_pname ~ret ~actuals astate = post :: posts ) | None -> (* no spec found for some reason (unknown function, ...) *) - L.d_printfln "No spec found for %a@\n" Typ.Procname.pp callee_pname ; + L.d_printfln "No spec found for %a@\n" Procname.pp callee_pname ; Ok [unknown_call call_loc (SkippedKnownCall callee_pname) ~ret ~actuals astate] diff --git a/infer/src/pulse/PulseOperations.mli b/infer/src/pulse/PulseOperations.mli index c4b744ef5..1e1e1528b 100644 --- a/infer/src/pulse/PulseOperations.mli +++ b/infer/src/pulse/PulseOperations.mli @@ -105,7 +105,7 @@ val check_address_escape : val call : caller_summary:Summary.t -> Location.t - -> Typ.Procname.t + -> Procname.t -> ret:Ident.t * Typ.t -> actuals:((AbstractValue.t * ValueHistory.t) * Typ.t) list -> t diff --git a/infer/src/pulse/PulseValueHistory.ml b/infer/src/pulse/PulseValueHistory.ml index 5af5e223e..79c9c4e36 100644 --- a/infer/src/pulse/PulseValueHistory.ml +++ b/infer/src/pulse/PulseValueHistory.ml @@ -40,7 +40,7 @@ let pp_event_no_location fmt event = | FormalDeclared (pvar, _) -> let pp_proc fmt pvar = Pvar.get_declaring_function pvar - |> Option.iter ~f:(fun proc_name -> F.fprintf fmt " of %a" Typ.Procname.pp proc_name) + |> Option.iter ~f:(fun proc_name -> F.fprintf fmt " of %a" Procname.pp proc_name) in F.fprintf fmt "parameter `%a`%a" Pvar.pp_value_non_verbose pvar pp_proc pvar | VariableAccessed (pvar, _) -> diff --git a/infer/src/quandary/ClangTaintAnalysis.ml b/infer/src/quandary/ClangTaintAnalysis.ml index 120d06dad..3475564e5 100644 --- a/infer/src/quandary/ClangTaintAnalysis.ml +++ b/infer/src/quandary/ClangTaintAnalysis.ml @@ -29,7 +29,7 @@ include TaintAnalysis.Make (struct [TaintSpec.Propagate_to_return] | Tvoid, [] -> [] - | Tvoid, _ when Typ.Procname.is_constructor pname -> + | Tvoid, _ when Procname.is_constructor pname -> (* "this" is always the first arg of a constructor; propagate taint there *) [TaintSpec.Propagate_to_receiver] | Tvoid, HilExp.AccessExpression access_expr :: _ -> ( @@ -49,7 +49,7 @@ include TaintAnalysis.Make (struct in (* if we have a specific model for a procedure, use that. otherwise, use the generic heuristics for dealing with unknown code *) - match Typ.Procname.get_method pname with + match Procname.get_method pname with | "operator+=" | "operator-=" | "operator*=" @@ -85,14 +85,14 @@ include TaintAnalysis.Make (struct from comstructor parameters to the constructed object. so we treat the empty constructor as a skip function instead *) let is_default_constructor pname = - Typ.Procname.is_c_method pname && Typ.Procname.is_constructor pname + Procname.is_c_method pname && Procname.is_constructor pname && AccessTree.BaseMap.is_empty summary in match pname with - | Typ.Procname.ObjC_Cpp _ + | Procname.ObjC_Cpp _ when is_default_constructor pname - || QualifiedCppName.Match.match_qualifiers models_matcher - (Typ.Procname.get_qualifiers pname) -> + || QualifiedCppName.Match.match_qualifiers models_matcher (Procname.get_qualifiers pname) + -> Some (handle_unknown_call pname ret_typ actuals tenv) | _ -> None diff --git a/infer/src/quandary/ClangTrace.ml b/infer/src/quandary/ClangTrace.ml index 02603726a..f8dc1b89c 100644 --- a/infer/src/quandary/ClangTrace.ml +++ b/infer/src/quandary/ClangTrace.ml @@ -67,19 +67,19 @@ module SourceKind = struct let get ~caller_pname:_ pname actuals tenv = let return = None in match pname with - | Typ.Procname.ObjC_Cpp cpp_name -> ( - let qualified_pname = Typ.Procname.get_qualifiers pname in + | Procname.ObjC_Cpp cpp_name -> ( + let qualified_pname = Procname.get_qualifiers pname in match ( QualifiedCppName.to_list - (Typ.Name.unqualified_name (Typ.Procname.ObjC_Cpp.get_class_type_name cpp_name)) - , Typ.Procname.get_method pname ) + (Typ.Name.unqualified_name (Procname.ObjC_Cpp.get_class_type_name cpp_name)) + , Procname.get_method pname ) with | ( ["std"; ("basic_istream" | "basic_iostream")] , ("getline" | "read" | "readsome" | "operator>>") ) -> [(ReadFile, Some 1)] | _ -> get_external_source qualified_pname ) - | Typ.Procname.C _ when Typ.Procname.equal pname BuiltinDecl.__global_access -> ( + | Procname.C _ when Procname.equal pname BuiltinDecl.__global_access -> ( (* is this var a command line flag created by the popular C++ gflags library for creating command-line flags (https://github.com/gflags/gflags)? *) let is_gflag access_path = @@ -109,16 +109,16 @@ module SourceKind = struct else [] | _ -> [] ) - | Typ.Procname.C _ -> ( - match Typ.Procname.to_string pname with + | Procname.C _ -> ( + match Procname.to_string pname with | "getenv" -> [(EnvironmentVariable, return)] | _ -> - get_external_source (Typ.Procname.get_qualifiers pname) ) - | Typ.Procname.Block _ -> + get_external_source (Procname.get_qualifiers pname) ) + | Procname.Block _ -> [] | pname -> - L.(die InternalError) "Non-C++ procname %a in C++ analysis" Typ.Procname.pp pname + L.(die InternalError) "Non-C++ procname %a in C++ analysis" Procname.pp pname let get_tainted_formals pdesc tenv = @@ -128,8 +128,8 @@ module SourceKind = struct let overrides_service_method pname tenv = PatternMatch.override_exists (function - | Typ.Procname.ObjC_Cpp cpp_pname -> - let class_name = Typ.Procname.ObjC_Cpp.get_class_name cpp_pname in + | Procname.ObjC_Cpp cpp_pname -> + let class_name = Procname.ObjC_Cpp.get_class_name cpp_pname in let res = String.is_suffix ~suffix:"SvIf" class_name || String.is_suffix ~suffix:"SvAsyncIf" class_name @@ -156,11 +156,11 @@ module SourceKind = struct (Procdesc.get_formals pdesc) in match Procdesc.get_proc_name pdesc with - | Typ.Procname.ObjC_Cpp cpp_pname as pname -> + | Procname.ObjC_Cpp cpp_pname as pname -> let qualified_pname = F.sprintf "%s::%s" - (Typ.Procname.ObjC_Cpp.get_class_name cpp_pname) - (Typ.Procname.get_method pname) + (Procname.ObjC_Cpp.get_class_name cpp_pname) + (Procname.get_method pname) in if QuandaryConfig.is_endpoint qualified_pname then taint_all_but_this_and_return ~make_source:(fun name desc -> @@ -265,7 +265,7 @@ module SinkKind = struct (* return Some(sink kinds) if [procedure_name] is in the list of externally specified sinks *) let get_external_sink pname actuals = - let qualified_pname = Typ.Procname.get_qualifiers pname in + let qualified_pname = Procname.get_qualifiers pname in List.find_map ~f:(fun (qualifiers, kinds, index) -> if QualifiedCppName.Match.match_qualifiers qualifiers qualified_pname then @@ -288,7 +288,7 @@ module SinkKind = struct report on accesses to maps etc., but also want to recognize custom vectors like fbvector rather than overfitting to std::vector *) let typename = - Typ.Procname.get_qualifiers pname |> QualifiedCppName.strip_template_args + Procname.get_qualifiers pname |> QualifiedCppName.strip_template_args |> QualifiedCppName.to_qual_string |> String.lowercase in String.is_substring ~substring:"vec" typename @@ -296,11 +296,11 @@ module SinkKind = struct || String.is_substring ~substring:"string" typename in match pname with - | Typ.Procname.ObjC_Cpp cpp_name -> ( + | Procname.ObjC_Cpp cpp_name -> ( match ( QualifiedCppName.to_list - (Typ.Name.unqualified_name (Typ.Procname.ObjC_Cpp.get_class_type_name cpp_name)) - , Typ.Procname.get_method pname ) + (Typ.Name.unqualified_name (Procname.ObjC_Cpp.get_class_type_name cpp_name)) + , Procname.get_method pname ) with | ( ["std"; ("basic_fstream" | "basic_ifstream" | "basic_ofstream")] , ("basic_fstream" | "basic_ifstream" | "basic_ofstream" | "open") ) -> @@ -309,17 +309,16 @@ module SinkKind = struct taint_nth 1 [BufferAccess] actuals | _ -> get_external_sink pname actuals ) - | Typ.Procname.C _ - when String.is_substring ~substring:"SetCommandLineOption" (Typ.Procname.to_string pname) -> + | Procname.C _ + when String.is_substring ~substring:"SetCommandLineOption" (Procname.to_string pname) -> taint_nth 1 [EnvironmentChange] actuals - | Typ.Procname.C _ - when Config.developer_mode && Typ.Procname.equal pname BuiltinDecl.__array_access -> + | Procname.C _ when Config.developer_mode && Procname.equal pname BuiltinDecl.__array_access -> taint_all [BufferAccess] actuals - | Typ.Procname.C _ when Typ.Procname.equal pname BuiltinDecl.__set_array_length -> + | Procname.C _ when Procname.equal pname BuiltinDecl.__set_array_length -> (* called when creating a stack-allocated array *) taint_nth 1 [StackAllocation] actuals - | Typ.Procname.C _ -> ( - match Typ.Procname.to_string pname with + | Procname.C _ -> ( + match Procname.to_string pname with | "creat" | "fopen" | "freopen" | "open" -> taint_nth 0 [CreateFile] actuals | "curl_easy_setopt" -> ( @@ -365,10 +364,10 @@ module SinkKind = struct taint_nth 2 [BufferAccess] actuals | _ -> get_external_sink pname actuals ) - | Typ.Procname.Block _ -> + | Procname.Block _ -> [] | pname -> - L.(die InternalError) "Non-C++ procname %a in C++ analysis" Typ.Procname.pp pname + L.(die InternalError) "Non-C++ procname %a in C++ analysis" Procname.pp pname let pp fmt kind = @@ -429,7 +428,7 @@ module CppSanitizer = struct let get pname _tenv = - let qualified_pname = Typ.Procname.get_qualifiers pname in + let qualified_pname = Procname.get_qualifiers pname in List.find_map ~f:(fun (qualifiers, kind) -> if QualifiedCppName.Match.match_qualifiers qualifiers qualified_pname then Some kind diff --git a/infer/src/quandary/JavaTaintAnalysis.ml b/infer/src/quandary/JavaTaintAnalysis.ml index dd83dd05f..021cfc366 100644 --- a/infer/src/quandary/JavaTaintAnalysis.ml +++ b/infer/src/quandary/JavaTaintAnalysis.ml @@ -40,18 +40,16 @@ include TaintAnalysis.Make (struct false in match pname with - | Typ.Procname.Java java_pname -> ( - let is_static = Typ.Procname.Java.is_static java_pname in + | Procname.Java java_pname -> ( + let is_static = Procname.Java.is_static java_pname in match - ( Typ.Procname.Java.get_class_name java_pname - , Typ.Procname.Java.get_method java_pname - , ret_typ ) + (Procname.Java.get_class_name java_pname, Procname.Java.get_method java_pname, ret_typ) with | "android.content.Intent", ("putExtra" | "putExtras"), _ -> (* don't care about tainted extras. instead. we'll check that result of getExtra is always used safely *) [] - | _ when Typ.Procname.is_constructor pname -> + | _ when Procname.is_constructor pname -> [TaintSpec.Propagate_to_receiver] | _, _, {Typ.desc= Tvoid | Tint _ | Tfloat _} when not is_static -> (* for instance methods with a non-Object return value, propagate the taint to the @@ -74,7 +72,7 @@ include TaintAnalysis.Make (struct | pname when BuiltinDecl.is_declared pname -> [] | pname -> - L.(die InternalError) "Non-Java procname %a in Java analysis" Typ.Procname.pp pname + L.(die InternalError) "Non-Java procname %a in Java analysis" Procname.pp pname let get_model _ _ _ _ _ = None diff --git a/infer/src/quandary/JavaTrace.ml b/infer/src/quandary/JavaTrace.ml index 7f1642e42..9a95d81b9 100644 --- a/infer/src/quandary/JavaTrace.ml +++ b/infer/src/quandary/JavaTrace.ml @@ -24,8 +24,8 @@ module SourceKind = struct let is_exposed ~caller_pname = match caller_pname with - | Typ.Procname.Java java_pname -> - let class_name = Typ.Procname.Java.get_class_name java_pname in + | Procname.Java java_pname -> + let class_name = Procname.Java.get_class_name java_pname in QuandaryConfig.is_endpoint class_name | _ -> false @@ -88,8 +88,8 @@ module SourceKind = struct Option.some_if (not (List.is_empty sources)) sources in match pname with - | Typ.Procname.Java pname -> - let method_name = Typ.Procname.Java.get_method pname in + | Procname.Java pname -> + let method_name = Procname.Java.get_method pname in let taint_matching_supertype typename = match (Typ.Name.name typename, method_name) with | "android.app.Activity", "getIntent" -> @@ -136,9 +136,9 @@ module SourceKind = struct get_external_source class_name method_name in PatternMatch.supertype_find_map_opt tenv taint_matching_supertype - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name pname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name pname)) |> Option.value ~default:[] - | Typ.Procname.C _ when Typ.Procname.equal pname BuiltinDecl.__global_access -> ( + | Procname.C _ when Procname.equal pname BuiltinDecl.__global_access -> ( (* accessed global will be passed to us as the only parameter *) match List.map actuals ~f:HilExp.ignore_cast with | [HilExp.AccessExpression access_expr] -> ( @@ -157,7 +157,7 @@ module SourceKind = struct | pname when BuiltinDecl.is_declared pname -> [] | pname -> - L.(die InternalError) "Non-Java procname %a in Java analysis" Typ.Procname.pp pname + L.(die InternalError) "Non-Java procname %a in Java analysis" Procname.pp pname let get_tainted_formals pdesc tenv = @@ -185,8 +185,8 @@ module SourceKind = struct in let formals = Procdesc.get_formals pdesc in match Procdesc.get_proc_name pdesc with - | Typ.Procname.Java java_pname as pname -> ( - let method_name = Typ.Procname.Java.get_method java_pname in + | Procname.Java java_pname as pname -> ( + let method_name = Procname.Java.get_method java_pname in let taint_matching_supertype typename = match (Typ.Name.name typename, method_name) with | ( ( "android.app.Activity" @@ -237,7 +237,7 @@ module SourceKind = struct Annotations.struct_typ_has_annot typ Annotations.ia_is_thrift_service && PatternMatch.override_exists ~check_current_type:false (fun superclass_pname -> - String.equal (Typ.Procname.get_method superclass_pname) method_name ) + String.equal (Procname.get_method superclass_pname) method_name ) tenv pname then (* assume every non-this formal of a Thrift service is tainted *) @@ -249,7 +249,7 @@ module SourceKind = struct in match PatternMatch.supertype_find_map_opt tenv taint_matching_supertype - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_pname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) with | Some tainted_formals -> tainted_formals @@ -257,7 +257,7 @@ module SourceKind = struct Source.all_formals_untainted pdesc ) | procname -> L.(die InternalError) - "Non-Java procedure %a where only Java procedures are expected" Typ.Procname.pp procname + "Non-Java procedure %a where only Java procedures are expected" Procname.pp procname let pp fmt kind = @@ -344,12 +344,12 @@ module SinkKind = struct let get pname actuals _ tenv = match pname with - | Typ.Procname.Java java_pname -> + | Procname.Java java_pname -> (* taint all the inputs of [pname]. for non-static procedures, taints the "this" parameter only if [taint_this] is true. *) let taint_all ?(taint_this = false) kinds = let actuals_to_taint, offset = - if Typ.Procname.Java.is_static java_pname || taint_this then (actuals, 0) + if Procname.Java.is_static java_pname || taint_this then (actuals, 0) else (List.tl_exn actuals, 1) in let indexes = @@ -359,7 +359,7 @@ module SinkKind = struct in (* taint the nth non-"this" parameter (0-indexed) *) let taint_nth n kinds = - let first_index = if Typ.Procname.Java.is_static java_pname then n else n + 1 in + let first_index = if Procname.Java.is_static java_pname then n else n + 1 in if first_index < List.length actuals then let first_index = IntSet.singleton first_index in Some (List.rev_map kinds ~f:(fun kind -> (kind, first_index))) @@ -385,7 +385,7 @@ module SinkKind = struct in Option.some_if (not (List.is_empty sinks)) sinks in - let method_name = Typ.Procname.Java.get_method java_pname in + let method_name = Procname.Java.get_method java_pname in let taint_matching_supertype typename = match (Typ.Name.name typename, method_name) with | "android.app.Activity", ("startActivityFromChild" | "startActivityFromFragment") -> @@ -480,12 +480,12 @@ module SinkKind = struct get_external_sink class_name method_name in PatternMatch.supertype_find_map_opt tenv taint_matching_supertype - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_pname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) |> Option.value ~default:[] | pname when BuiltinDecl.is_declared pname -> [] | pname -> - L.(die InternalError) "Non-Java procname %a in Java analysis" Typ.Procname.pp pname + L.(die InternalError) "Non-Java procname %a in Java analysis" Procname.pp pname let pp fmt kind = @@ -544,8 +544,8 @@ module JavaSanitizer = struct let get pname tenv = match pname with - | Typ.Procname.Java java_pname -> - let method_name = Typ.Procname.Java.get_method java_pname in + | Procname.Java java_pname -> + let method_name = Procname.Java.get_method java_pname in let sanitizer_matching_supertype typename = match (Typ.Name.name typename, method_name) with (* string concatenation is translated differently by invokedynamic in JDK11 *) @@ -557,7 +557,7 @@ module JavaSanitizer = struct get_external_sanitizer class_name method_name in PatternMatch.supertype_find_map_opt tenv sanitizer_matching_supertype - (Typ.Name.Java.from_string (Typ.Procname.Java.get_class_name java_pname)) + (Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) | _ -> None diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index 95ffdb73e..6ea1c3859 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -114,8 +114,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct let is_endpoint source = match CallSite.pname (TraceDomain.Source.call_site source) with - | Typ.Procname.Java java_pname -> - QuandaryConfig.is_endpoint (Typ.Procname.Java.get_class_name java_pname) + | Procname.Java java_pname -> + QuandaryConfig.is_endpoint (Procname.Java.get_class_name java_pname) | _ -> false @@ -123,7 +123,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct (** log any new reportable source-sink flows in [trace] *) let report_trace ?(sink_indexes = IntSet.empty) trace cur_site (proc_data : extras ProcData.t) = let get_summary pname = - if Typ.Procname.equal pname (Summary.get_proc_name proc_data.summary) then + if Procname.equal pname (Summary.get_proc_name proc_data.summary) then (* read_summary will trigger ondemand analysis of the current proc. we don't want that. *) TaintDomain.bottom else @@ -135,12 +135,11 @@ module Make (TaintSpecification : TaintSpec.S) = struct in let get_caller_string caller_site = let caller_pname = CallSite.pname caller_site in - F.sprintf " in procedure %s" - (Typ.Procname.to_simplified_string ~withclass:true caller_pname) + F.sprintf " in procedure %s" (Procname.to_simplified_string ~withclass:true caller_pname) in let pp_trace_elem site fmt caller_string = F.fprintf fmt "(%s)%s at %a" - (Typ.Procname.to_simplified_string ~withclass:true (CallSite.pname site)) + (Procname.to_simplified_string ~withclass:true (CallSite.pname site)) caller_string Location.pp (CallSite.loc site) in let pp_source source_caller_opt fmt initial_source = @@ -267,7 +266,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct ~f:(fun (access_path_opt, path_source) -> let desc, loc = let call_site = Source.call_site path_source in - ( Format.asprintf "Return from %a%a" Typ.Procname.pp (CallSite.pname call_site) + ( Format.asprintf "Return from %a%a" Procname.pp (CallSite.pname call_site) pp_access_path_opt access_path_opt , CallSite.loc call_site ) in @@ -291,8 +290,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct (IntSet.elements indexes) in let desc = - Format.asprintf "Call to %a%s" Typ.Procname.pp (CallSite.pname call_site) - indexes_str + Format.asprintf "Call to %a%s" Procname.pp (CallSite.pname call_site) indexes_str in Errlog.make_trace_element 0 (CallSite.loc call_site) desc [] ) expanded_sinks @@ -515,8 +513,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct let handle_model callee_pname access_tree model = let is_variadic = match callee_pname with - | Typ.Procname.Java pname -> - Typ.Procname.Java.is_vararg pname + | Procname.Java pname -> + Procname.Java.is_vararg pname | _ -> false in @@ -581,8 +579,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct List.fold ~f:handle_model_ ~init:access_tree model in let handle_unknown_call callee_pname access_tree = - match Typ.Procname.get_method callee_pname with - | "operator=" when not (Typ.Procname.is_java callee_pname) -> ( + match Procname.get_method callee_pname with + | "operator=" when not (Procname.is_java callee_pname) -> ( (* treat unknown calls to C++ operator= as assignment *) match List.map actuals ~f:HilExp.ignore_cast with | [AccessExpression lhs_access_expr; rhs_exp] -> @@ -611,7 +609,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct in let dummy_ret_opt = match ret_ap with - | _, {Typ.desc= Tvoid} when not (Typ.Procname.is_java callee_pname) -> ( + | _, {Typ.desc= Tvoid} when not (Procname.is_java callee_pname) -> ( (* the C++ frontend handles returns of non-pointers by adding a dummy pass-by-reference variable as the last actual, then returning the value by assigning to it. understand this pattern by pretending it's the return value *) @@ -767,7 +765,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct let make_summary {ProcData.summary; extras= {formal_map}} access_tree = - let is_java = Typ.Procname.is_java (Summary.get_proc_name summary) in + let is_java = Procname.is_java (Summary.get_proc_name summary) in (* if a trace has footprint sources, attach them to the appropriate footprint var *) let access_tree' = TaintDomain.fold @@ -871,8 +869,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct Payload.update_summary (make_summary proc_data access_tree) summary | None -> if Procdesc.Node.get_succs (Procdesc.get_start_node proc_desc) <> [] then ( - L.internal_error "Couldn't compute post for %a. Broken CFG suspected" Typ.Procname.pp - pname ; + L.internal_error "Couldn't compute post for %a. Broken CFG suspected" Procname.pp pname ; summary ) else summary end diff --git a/infer/src/quandary/TaintSpec.ml b/infer/src/quandary/TaintSpec.ml index ac036a60b..5c79f55f6 100644 --- a/infer/src/quandary/TaintSpec.ml +++ b/infer/src/quandary/TaintSpec.ml @@ -22,12 +22,12 @@ module type S = sig module AccessTree : module type of AccessTree.Make (Trace) (AccessTree.DefaultConfig) - val handle_unknown_call : Typ.Procname.t -> Typ.t -> HilExp.t list -> Tenv.t -> action list + val handle_unknown_call : Procname.t -> Typ.t -> HilExp.t list -> Tenv.t -> action list (** return a summary for handling an unknown call at the given site with the given return type and actuals *) val get_model : - Typ.Procname.t -> Typ.t -> HilExp.t list -> Tenv.t -> AccessTree.t -> action list option + Procname.t -> Typ.t -> HilExp.t list -> Tenv.t -> AccessTree.t -> action list option (** returns a model that should be used for the given (procname, return type, actuals, summary) instead of using the summary for the procname *) diff --git a/infer/src/test_determinator/JavaProfilerSamples.ml b/infer/src/test_determinator/JavaProfilerSamples.ml index 0e86cd585..b6a28419a 100644 --- a/infer/src/test_determinator/JavaProfilerSamples.ml +++ b/infer/src/test_determinator/JavaProfilerSamples.ml @@ -7,13 +7,13 @@ open! IStd -type labeled_profiler_sample = string * Typ.Procname.Set.t [@@deriving compare] +type labeled_profiler_sample = string * Procname.Set.t [@@deriving compare] let equal_labeled_profiler_sample = [%compare.equal: labeled_profiler_sample] let from_java_profiler_samples j ~use_signature = let process_methods methods = - Typ.Procname.Set.of_list + Procname.Set.of_list (List.map ~f:(fun {Java_profiler_samples_t.classname; methodname; signature} -> JProcname.create_procname ~classname ~methodname ~signature ~use_signature ) diff --git a/infer/src/test_determinator/JavaProfilerSamples.mli b/infer/src/test_determinator/JavaProfilerSamples.mli index e77f4525e..5e49f461b 100644 --- a/infer/src/test_determinator/JavaProfilerSamples.mli +++ b/infer/src/test_determinator/JavaProfilerSamples.mli @@ -7,7 +7,7 @@ open! IStd -type labeled_profiler_sample = string * Typ.Procname.Set.t [@@deriving compare] +type labeled_profiler_sample = string * Procname.Set.t [@@deriving compare] val equal_labeled_profiler_sample : labeled_profiler_sample -> labeled_profiler_sample -> bool diff --git a/infer/src/test_determinator/testDeterminator.ml b/infer/src/test_determinator/testDeterminator.ml index 76cf7c7cf..3639c95c1 100644 --- a/infer/src/test_determinator/testDeterminator.ml +++ b/infer/src/test_determinator/testDeterminator.ml @@ -32,7 +32,7 @@ module MethodRangeMap = struct L.die UserError "Could not read file %s" code_graph_file in let method_decls = java_method_decls_of_string json_string in - List.fold method_decls ~init:Typ.Procname.Map.empty ~f:(fun acc decl -> + List.fold method_decls ~init:Procname.Map.empty ~f:(fun acc decl -> let start_location = { Location.line= decl.start_line ; col= -1 @@ -50,7 +50,7 @@ module MethodRangeMap = struct let key = JProcname.create_procname ~use_signature ~classname ~methodname ~signature in - Typ.Procname.Map.add key (range, ()) acc + Procname.Map.add key (range, ()) acc | None -> acc ) | _ -> @@ -88,8 +88,8 @@ end [@@@warning "-32"] let pp_profiler_sample_set fmt s = - F.fprintf fmt " (set size = %i) " (Typ.Procname.Set.cardinal s) ; - Typ.Procname.Set.iter (fun m -> F.fprintf fmt "@\n %a " Typ.Procname.pp m) s + F.fprintf fmt " (set size = %i) " (Procname.Set.cardinal s) ; + Procname.Set.iter (fun m -> F.fprintf fmt "@\n %a " Procname.pp m) s module TestSample = struct @@ -130,19 +130,19 @@ let is_file_in_changed_lines file_changed_lines changed_lines range = let affected_methods method_range_map file_changed_lines changed_lines = - Typ.Procname.Map.fold + Procname.Map.fold (fun key (range, _) acc -> if is_file_in_changed_lines file_changed_lines changed_lines range then - Typ.Procname.Set.add key acc + Procname.Set.add key acc else acc ) - method_range_map Typ.Procname.Set.empty + method_range_map Procname.Set.empty let compute_affected_methods_java changed_lines_map method_range_map = - String.Map.fold changed_lines_map ~init:Typ.Procname.Set.empty + String.Map.fold changed_lines_map ~init:Procname.Set.empty ~f:(fun ~key:file_changed_lines ~data acc -> let am = affected_methods method_range_map file_changed_lines data in - Typ.Procname.Set.union am acc ) + Procname.Set.union am acc ) let compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_map = @@ -151,14 +151,14 @@ let compute_affected_methods_clang ~clang_range_map ~source_file ~changed_lines_ | Some changed_lines -> affected_methods clang_range_map fname changed_lines | None -> - Typ.Procname.Set.empty + Procname.Set.empty let compute_affected_proc_names_clang ~clang_range_map ~source_file ~changed_lines_map = let fname = SourceFile.to_rel_path source_file in match String.Map.find changed_lines_map fname with | Some changed_lines -> - Typ.Procname.Map.fold + Procname.Map.fold (fun _ (range, clang_proc) acc -> if is_file_in_changed_lines fname changed_lines range then clang_proc :: acc else acc ) clang_range_map [] @@ -169,7 +169,7 @@ let compute_affected_proc_names_clang ~clang_range_map ~source_file ~changed_lin let emit_relevant_methods relevant_methods = let cleaned_methods = List.dedup_and_sort ~compare:String.compare - (List.map (Typ.Procname.Set.elements relevant_methods) ~f:Typ.Procname.to_string) + (List.map (Procname.Set.elements relevant_methods) ~f:Procname.to_string) in let json = `List (List.map ~f:(fun t -> `String t) cleaned_methods) in let outpath = Config.results_dir ^/ Config.export_changed_functions_output in @@ -194,11 +194,11 @@ let java_test_to_run () = let method_range = MethodRangeMap.create_java_method_range_map code_graph_file in let affected_methods = compute_affected_methods_java changed_lines_map method_range in let profiler_samples = TestSample.read_java_test_sample test_samples_file in - if Typ.Procname.Set.is_empty affected_methods then [] + if Procname.Set.is_empty affected_methods then [] else List.fold profiler_samples ~init:[] ~f:(fun acc (label, profiler_samples) -> - let intersection = Typ.Procname.Set.inter affected_methods profiler_samples in - if Typ.Procname.Set.is_empty intersection then acc else label :: acc ) + let intersection = Procname.Set.inter affected_methods profiler_samples in + if Procname.Set.is_empty intersection then acc else label :: acc ) let remove_llvm_suffix_native_symbols native_symbols = diff --git a/infer/src/test_determinator/testDeterminator.mli b/infer/src/test_determinator/testDeterminator.mli index ed36242f3..ec87d047c 100644 --- a/infer/src/test_determinator/testDeterminator.mli +++ b/infer/src/test_determinator/testDeterminator.mli @@ -8,13 +8,13 @@ open! IStd val compute_and_emit_test_to_run : - ?clang_range_map:((Location.t * Location.t) * ClangProc.t option) Typ.Procname.Map.t + ?clang_range_map:((Location.t * Location.t) * ClangProc.t option) Procname.Map.t -> ?source_file:SourceFile.t -> unit -> unit val compute_and_emit_relevant_methods : - clang_range_map:((Location.t * Location.t) * ClangProc.t option) Typ.Procname.Map.t + clang_range_map:((Location.t * Location.t) * ClangProc.t option) Procname.Map.t -> source_file:SourceFile.t -> unit diff --git a/infer/src/topl/Topl.ml b/infer/src/topl/Topl.ml index d28a5efc6..52052222c 100644 --- a/infer/src/topl/Topl.ml +++ b/infer/src/topl/Topl.ml @@ -48,7 +48,7 @@ let evaluate_static_guard label (e_fun, arg_ts) = match e_fun with | Exp.Const (Const.Cfun n) -> (* TODO: perhaps handle inheritance *) - let name = Typ.Procname.hashable_name n in + let name = Procname.hashable_name n in let re = Str.regexp label.ToplAst.procedure_name in let result = Str.string_match re name 0 in tt "match name='%s' re='%s' result=%b@\n" name label.ToplAst.procedure_name result ; diff --git a/infer/src/topl/Topl.mli b/infer/src/topl/Topl.mli index 22cfbaecd..38f5981a4 100644 --- a/infer/src/topl/Topl.mli +++ b/infer/src/topl/Topl.mli @@ -10,10 +10,10 @@ open! IStd val is_active : unit -> bool (** Returns whether the TOPL analysis is active. *) -val get_proc_attr : Typ.Procname.t -> ProcAttributes.t option +val get_proc_attr : Procname.t -> ProcAttributes.t option (** [get_proc_attr proc_name] returns the attributes of [get_proc_desc proc_name] *) -val get_proc_desc : Typ.Procname.t -> Procdesc.t option +val get_proc_desc : Procname.t -> Procdesc.t option (** Returns a synthesized Procdesc.t, when it corresponds to instrumentation for a TOPL property. *) val instrument : Tenv.t -> Procdesc.t -> unit diff --git a/infer/src/topl/ToplMonitor.ml b/infer/src/topl/ToplMonitor.ml index 1572b2ffd..decb10076 100644 --- a/infer/src/topl/ToplMonitor.ml +++ b/infer/src/topl/ToplMonitor.ml @@ -25,11 +25,11 @@ let cfg = let sourcefile_location () = Location.none (sourcefile ()) -let type_of_paramtyp (_t : Typ.Procname.Parameter.t) : Typ.t = ToplUtils.any_type +let type_of_paramtyp (_t : Procname.Parameter.t) : Typ.t = ToplUtils.any_type (** NOTE: Similar to [JTrans.formals_from_signature]. *) let formals_of_procname proc_name = - let params = Typ.Procname.get_parameters proc_name in + let params = Procname.get_parameters proc_name in let new_arg_name = let n = ref (-1) in fun () -> incr n ; ToplName.arg !n @@ -196,7 +196,7 @@ let gen_maybe_call ret_id : node_generator = stmt_node [ToplUtils.topl_call ret_id (Tint IBool) (sourcefile_location ()) ToplName.maybe []] -let arguments_count proc_name = List.length (Typ.Procname.get_parameters proc_name) +let arguments_count proc_name = List.length (Procname.get_parameters proc_name) (* NOTE: The order of parameters must correspond to what gets generated by [Topl.call_save_args]. *) let generate_save_args automaton proc_name = @@ -233,7 +233,7 @@ let generate_execute automaton proc_name = let generate_execute_state automaton proc_name = let state : ToplAutomaton.vindex = let re = Str.regexp "execute_state_\\([0-9]*\\)$" in - let mname = Typ.Procname.get_method proc_name in + let mname = Procname.get_method proc_name in if Str.string_match re mname 0 then int_of_string (Str.matched_group 1 mname) else L.die InternalError "Topl.Monitor.generate_execute_state called for %s" mname in @@ -356,7 +356,7 @@ let generate_execute_state automaton proc_name = (** INV: For the code generated here, biabduction infers the spec "returned value can be anything" *) let generate_maybe _automaton proc_name = procedure proc_name (sequence []) -let name_matches re proc_name = Str.string_match re (Typ.Procname.get_method proc_name) 0 +let name_matches re proc_name = Str.string_match re (Procname.get_method proc_name) 0 let has_name s = name_matches (Str.regexp (s ^ "$")) @@ -381,5 +381,5 @@ let maybe_synthesize_it automaton proc_name = let generate automaton proc_name = IList.force_until_first_some - [ lazy (Typ.Procname.Hash.find_opt (cfg ()) proc_name) + [ lazy (Procname.Hash.find_opt (cfg ()) proc_name) ; lazy (maybe_synthesize_it automaton proc_name) ] diff --git a/infer/src/topl/ToplMonitor.mli b/infer/src/topl/ToplMonitor.mli index 2ccc6bc6e..d7590c45f 100644 --- a/infer/src/topl/ToplMonitor.mli +++ b/infer/src/topl/ToplMonitor.mli @@ -7,7 +7,7 @@ open! IStd -val generate : ToplAutomaton.t -> Typ.Procname.t -> Procdesc.t option +val generate : ToplAutomaton.t -> Procname.t -> Procdesc.t option (** [generate automaton proc_name] returns a CFG, provided that [proc_name] is a recognized procedure name *) diff --git a/infer/src/topl/ToplUtils.ml b/infer/src/topl/ToplUtils.ml index 0962395e7..67f3b5d0f 100644 --- a/infer/src/topl/ToplUtils.ml +++ b/infer/src/topl/ToplUtils.ml @@ -22,8 +22,8 @@ let topl_call ret_id (ret_typ : Typ.desc) loc name arg_ts : Sil.instr = let args_typ = List.map arg_ts ~f:(fun _ -> Typ.Name.Java.Split.java_lang_object) in Exp.Const (Const.Cfun - (Typ.Procname.Java - (Typ.Procname.Java.make topl_class_name ret_typ name args_typ Typ.Procname.Java.Static))) + (Procname.Java + (Procname.Java.make topl_class_name ret_typ name args_typ Procname.Java.Static))) in Sil.Call ((ret_id, Typ.mk ret_typ), e_fun, arg_ts, loc, CallFlags.default) @@ -45,8 +45,8 @@ let local_var proc_name x : Exp.t = Exp.Lvar (Pvar.mk (Mangled.from_string x) pr let constant_int (x : int) : Exp.t = Exp.int (IntLit.of_int x) let is_synthesized = function - | Typ.Procname.Java j -> - String.equal ToplName.topl_property (Typ.Procname.Java.get_class_name j) + | Procname.Java j -> + String.equal ToplName.topl_property (Procname.Java.get_class_name j) | _ -> false diff --git a/infer/src/topl/ToplUtils.mli b/infer/src/topl/ToplUtils.mli index 5e69b456d..898df46a5 100644 --- a/infer/src/topl/ToplUtils.mli +++ b/infer/src/topl/ToplUtils.mli @@ -19,7 +19,7 @@ val topl_class_typ : Typ.t val static_var : string -> Exp.t -val local_var : Typ.Procname.t -> string -> Exp.t +val local_var : Procname.t -> string -> Exp.t val constant_int : int -> Exp.t @@ -27,7 +27,7 @@ val topl_call : Ident.t -> Typ.desc -> Location.t -> string -> (Exp.t * Typ.t) l (** Call a TOPL function; that is, a static member of "topl.Property" with java.lang.Object arguments and return [ret_id] of type [ret_typ].*) -val is_synthesized : Typ.Procname.t -> bool +val is_synthesized : Procname.t -> bool val debug : ('a, Format.formatter, unit) IStd.format -> 'a diff --git a/infer/src/unit/JavaProfilerSamplesTest.ml b/infer/src/unit/JavaProfilerSamplesTest.ml index f671eaa84..20472475b 100644 --- a/infer/src/unit/JavaProfilerSamplesTest.ml +++ b/infer/src/unit/JavaProfilerSamplesTest.ml @@ -137,7 +137,7 @@ let test_jni_to_java_type_with_valid_input = Format.fprintf fmt "Expected: '(%s, %s)', found: '(%s, %s)'" exp_pkg exp_cl actual_pkg actual_cl in - let cmp a b = Int.equal 0 (Typ.Procname.Java.compare_java_type a b) in + let cmp a b = Int.equal 0 (Procname.Java.compare_java_type a b) in assert_equal ~cmp ~pp_diff expected found in [ ("test_jni_to_java_type_1", T.Boolean, mk_split (None, "bool")) @@ -163,7 +163,7 @@ let test_from_json_string_with_valid_input = assert_equal ~cmp:(List.equal JavaProfilerSamples.equal_labeled_profiler_sample) expected found in let input1 = "[{\"test\": \"label1\",\"methods\": []}]" in - let expected1 = [("label1", Typ.Procname.Set.of_list [])] in + let expected1 = [("label1", Procname.Set.of_list [])] in let input2 = Printf.sprintf "[{\"foo\":{},\"test\": \"label1\",\"methods\": [{\"class\": \"ggg.hhh.Iii\", \"boo\": \"\", \ @@ -178,8 +178,8 @@ let test_from_json_string_with_valid_input = in let expected2 = [ ( "label1" - , Typ.Procname.Set.of_list - [ Typ.Procname.( + , Procname.Set.of_list + [ Procname.( Java (Java.make (Typ.Name.Java.from_string "lll.mmm.Nnn") @@ -188,7 +188,7 @@ let test_from_json_string_with_valid_input = ; mk_split (None, "int[]") ; mk_split (None, "long") ] Java.Non_Static)) - ; Typ.Procname.( + ; Procname.( Java (Java.make (Typ.Name.Java.from_string "ggg.hhh.Iii") @@ -198,8 +198,8 @@ let test_from_json_string_with_valid_input = ; mk_split (None, "long") ] Java.Non_Static)) ] ) ; ( "label2" - , Typ.Procname.Set.of_list - [ Typ.Procname.( + , Procname.Set.of_list + [ Procname.( Java (Java.make (Typ.Name.Java.from_string "ddd.eee.Fff") @@ -209,7 +209,7 @@ let test_from_json_string_with_valid_input = ; mk_split (None, "int[]") ; mk_split (None, "long") ] Java.Non_Static)) - ; Typ.Procname.( + ; Procname.( Java (Java.make (Typ.Name.Java.from_string "aaa.bbb.Ccc") @@ -218,26 +218,26 @@ let test_from_json_string_with_valid_input = in let expected3 = [ ( "label1" - , Typ.Procname.Set.of_list - [ Typ.Procname.( + , Procname.Set.of_list + [ Procname.( Java (Java.make (Typ.Name.Java.from_string "lll.mmm.Nnn") None "" [] Java.Non_Static)) - ; Typ.Procname.( + ; Procname.( Java (Java.make (Typ.Name.Java.from_string "ggg.hhh.Iii") None "" [] Java.Non_Static)) ] ) ; ( "label2" - , Typ.Procname.Set.of_list - [ Typ.Procname.( + , Procname.Set.of_list + [ Procname.( Java (Java.make (Typ.Name.Java.from_string "ddd.eee.Fff") (Some (mk_split (None, "void"))) "methodTwo" [] Java.Non_Static)) - ; Typ.Procname.( + ; Procname.( Java (Java.make (Typ.Name.Java.from_string "aaa.bbb.Ccc") diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index dd65fe7da..8334a2035 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -19,7 +19,7 @@ module MockTrace = Trace.Make (struct include MockTraceElem let get ~caller_pname:_ pname _ _ = - if String.is_prefix ~prefix:"SOURCE" (Typ.Procname.to_string pname) then + if String.is_prefix ~prefix:"SOURCE" (Procname.to_string pname) then [(CallSite.make pname Location.dummy, None)] else [] @@ -31,7 +31,7 @@ module MockTrace = Trace.Make (struct include MockTraceElem let get pname _ _ _ = - if String.is_prefix ~prefix:"SINK" (Typ.Procname.to_string pname) then + if String.is_prefix ~prefix:"SINK" (Procname.to_string pname) then [(CallSite.make pname Location.dummy, IntSet.singleton 0)] else [] end) @@ -67,7 +67,7 @@ let tests = let open AnalyzerTester.StructuredSil in (* less verbose form of pretty-printing to make writing tests easy *) let pp_sparse fmt astate = - let pp_call_site fmt call_site = Typ.Procname.pp fmt (CallSite.pname call_site) in + let pp_call_site fmt call_site = Procname.pp fmt (CallSite.pname call_site) in let pp_sources fmt sources = if MockTrace.Sources.is_empty sources then F.pp_print_char fmt '?' else @@ -94,15 +94,15 @@ let tests = PrettyPrintable.pp_collection ~pp_item fmt (List.rev trace_assocs) in let assign_to_source ret_str = - let procname = Typ.Procname.from_string_c_fun "SOURCE" in + let procname = Procname.from_string_c_fun "SOURCE" in make_call ~procname ~return:(ident_of_str ret_str, dummy_typ) [] in let assign_to_non_source ret_str = - let procname = Typ.Procname.from_string_c_fun "NON-SOURCE" in + let procname = Procname.from_string_c_fun "NON-SOURCE" in make_call ~procname ~return:(ident_of_str ret_str, dummy_typ) [] in let call_sink_with_exp exp = - let procname = Typ.Procname.from_string_c_fun "SINK" in + let procname = Procname.from_string_c_fun "SINK" in make_call ~procname [(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 db36cc3ca..b6ff658e4 100644 --- a/infer/src/unit/accessPathTestUtils.ml +++ b/infer/src/unit/accessPathTestUtils.ml @@ -7,7 +7,7 @@ open! IStd -let make_var var_str = Pvar.mk (Mangled.from_string var_str) Typ.Procname.empty_block +let make_var var_str = Pvar.mk (Mangled.from_string var_str) Procname.empty_block let make_base ?(typ = Typ.mk 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 cbc307191..f317827a4 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -53,7 +53,7 @@ module StructuredSil = struct let dummy_loc = Location.dummy - let dummy_procname = Typ.Procname.empty_block + let dummy_procname = Procname.empty_block let label_counter = ref 0 @@ -293,7 +293,7 @@ module Make (T : TransferFunctions.SIL with type CFG.Node.t = Procdesc.Node.t) = let ai_list = [("ai_rpo", AI_RPO.create_test); ("ai_wto", AI_WTO.create_test)] - let create_tests ?(test_pname = Typ.Procname.empty_block) ~initial ?pp_opt extras tests = + let create_tests ?(test_pname = Procname.empty_block) ~initial ?pp_opt extras tests = let open OUnit2 in List.concat_map ~f:(fun (name, test_program) -> diff --git a/infer/src/unit/procCfgTests.ml b/infer/src/unit/procCfgTests.ml index e619121e2..bfdd466f2 100644 --- a/infer/src/unit/procCfgTests.ml +++ b/infer/src/unit/procCfgTests.ml @@ -15,7 +15,7 @@ let tests = let cfg = Cfg.create () in let test_pdesc = Cfg.create_proc_desc cfg - (ProcAttributes.default (SourceFile.invalid __FILE__) Typ.Procname.empty_block) + (ProcAttributes.default (SourceFile.invalid __FILE__) Procname.empty_block) in let dummy_instr1 = Sil.skip_instr in let dummy_instr2 = Sil.Metadata (Abstract Location.dummy) in