diff --git a/infer/src/IR/CapturedVar.ml b/infer/src/IR/CapturedVar.ml index a19aa0c42..e7ba1c8b0 100644 --- a/infer/src/IR/CapturedVar.ml +++ b/infer/src/IR/CapturedVar.ml @@ -8,10 +8,14 @@ open! IStd module F = Format -type t = {name: Mangled.t; typ: Typ.t; capture_mode: Pvar.capture_mode} [@@deriving compare] +type capture_mode = ByReference | ByValue [@@deriving compare, equal] + +let string_of_capture_mode = function ByReference -> "by ref" | ByValue -> "by value" + +type t = {name: Mangled.t; typ: Typ.t; capture_mode: capture_mode} [@@deriving compare] let make ~name ~typ ~capture_mode = {name; typ; capture_mode} let pp fmt {name; typ; capture_mode} = F.fprintf fmt "(%a,@,%a,@,%s)" Mangled.pp name (Typ.pp_full Pp.text) typ - (Pvar.string_of_capture_mode capture_mode) + (string_of_capture_mode capture_mode) diff --git a/infer/src/IR/CapturedVar.mli b/infer/src/IR/CapturedVar.mli index 3f59cd2db..bfb6b9ea3 100644 --- a/infer/src/IR/CapturedVar.mli +++ b/infer/src/IR/CapturedVar.mli @@ -7,8 +7,12 @@ open! IStd -type t = {name: Mangled.t; typ: Typ.t; capture_mode: Pvar.capture_mode} [@@deriving compare] +type capture_mode = ByReference | ByValue [@@deriving compare, equal] + +val string_of_capture_mode : capture_mode -> string + +type t = {name: Mangled.t; typ: Typ.t; capture_mode: capture_mode} [@@deriving compare] val pp : Format.formatter -> t -> unit -val make : name:Mangled.t -> typ:Typ.t -> capture_mode:Pvar.capture_mode -> t +val make : name:Mangled.t -> typ:Typ.t -> capture_mode:capture_mode -> t diff --git a/infer/src/IR/DotCfg.ml b/infer/src/IR/DotCfg.ml index 2118c0868..d2f57bed6 100644 --- a/infer/src/IR/DotCfg.ml +++ b/infer/src/IR/DotCfg.ml @@ -23,7 +23,7 @@ let pp_etlist fmt etl = let pp_var_list fmt etl = List.iter etl ~f:(fun {CapturedVar.name; typ; capture_mode} -> Format.fprintf fmt " [%s]%a:%a" - (Pvar.string_of_capture_mode capture_mode) + (CapturedVar.string_of_capture_mode capture_mode) Mangled.pp name (Typ.pp_full Pp.text) typ ) diff --git a/infer/src/IR/Exp.ml b/infer/src/IR/Exp.ml index 0d1ceb8d7..3f409f59b 100644 --- a/infer/src/IR/Exp.ml +++ b/infer/src/IR/Exp.ml @@ -18,7 +18,8 @@ type ident_ = Ident.t let compare_ident_ x y = Ident.compare y x -type closure = {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t * Pvar.capture_mode) list} +type closure = + {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t * CapturedVar.capture_mode) list} (** This records information about a [sizeof(typ)] expression. @@ -243,7 +244,7 @@ and pp_captured_var pe pp_t f (exp, var, typ, mode) = (Pvar.pp pe) f var | _ -> F.fprintf f "([%s]%a %a:%a)" - (Pvar.string_of_capture_mode mode) + (CapturedVar.string_of_capture_mode mode) (pp_ pe pp_t) exp (Pvar.pp pe) var (Typ.pp pe) typ diff --git a/infer/src/IR/Exp.mli b/infer/src/IR/Exp.mli index 8dcfa4c5d..b5d5ed20a 100644 --- a/infer/src/IR/Exp.mli +++ b/infer/src/IR/Exp.mli @@ -13,7 +13,8 @@ open! IStd module F = Format -type closure = {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t * Pvar.capture_mode) list} +type closure = + {name: Procname.t; captured_vars: (t * Pvar.t * Typ.t * CapturedVar.capture_mode) list} (** This records information about a [sizeof(typ)] expression. diff --git a/infer/src/IR/PredSymb.ml b/infer/src/IR/PredSymb.ml index d9f0ebc90..f44ee1f83 100644 --- a/infer/src/IR/PredSymb.ml +++ b/infer/src/IR/PredSymb.ml @@ -12,22 +12,6 @@ open! IStd module L = Logging module F = Format -(** Visibility modifiers. *) -type access = Default | Public | Private | Protected [@@deriving compare] - -let equal_access = [%compare.equal: access] - -let string_of_access = function - | Default -> - "Default" - | Public -> - "Public" - | Private -> - "Private" - | Protected -> - "Protected" - - type mem_kind = | Mmalloc (** memory allocated with malloc *) | Mnew (** memory allocated with new *) diff --git a/infer/src/IR/PredSymb.mli b/infer/src/IR/PredSymb.mli index 8e5d49be1..279e772b8 100644 --- a/infer/src/IR/PredSymb.mli +++ b/infer/src/IR/PredSymb.mli @@ -12,13 +12,6 @@ open! IStd (** {2 Programs and Types} *) -(** Visibility modifiers. *) -type access = Default | Public | Private | Protected [@@deriving compare] - -val equal_access : access -> access -> bool - -val string_of_access : access -> string - type mem_kind = | Mmalloc (** memory allocated with malloc *) | Mnew (** memory allocated with new *) diff --git a/infer/src/IR/ProcAttributes.ml b/infer/src/IR/ProcAttributes.ml index ee9529c2a..6dfc87319 100644 --- a/infer/src/IR/ProcAttributes.ml +++ b/infer/src/IR/ProcAttributes.ml @@ -10,6 +10,22 @@ open! IStd module F = Format +(** Visibility modifiers. *) +type access = Default | Public | Private | Protected [@@deriving compare] + +let equal_access = [%compare.equal: access] + +let string_of_access = function + | Default -> + "Default" + | Public -> + "Public" + | Private -> + "Private" + | Protected -> + "Protected" + + (** Type for ObjC accessors *) type objc_accessor_type = Objc_getter of Struct.field | Objc_setter of Struct.field [@@deriving compare] @@ -44,7 +60,7 @@ type specialized_with_blocks_info = [@@deriving compare] type t = - { access: PredSymb.access (** visibility access *) + { access: access (** visibility access *) ; captured: CapturedVar.t list (** name and type of variables captured in blocks *) ; exceptions: string list (** exceptions thrown by the procedure *) ; formals: (Mangled.t * Typ.t) list (** name and type of formal parameters *) @@ -104,17 +120,12 @@ let get_access attributes = attributes.access let get_formals attributes = attributes.formals -let get_pvar_formals attributes = - let pname = attributes.proc_name in - List.map attributes.formals ~f:(fun (name, typ) -> (Pvar.mk name pname, typ)) - - let get_proc_name attributes = attributes.proc_name let get_loc attributes = attributes.loc let default translation_unit proc_name = - { access= PredSymb.Default + { access= Default ; captured= [] ; exceptions= [] ; formals= [] @@ -197,8 +208,8 @@ let pp f in 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 (equal_access default.access access) then + F.fprintf f "; access= %a@," (Pp.of_string ~f:string_of_access) access ; if not ([%compare.equal: CapturedVar.t list] default.captured captured) then F.fprintf f "; captured= [@[%a@]]@," pp_captured captured ; if not ([%compare.equal: string list] default.exceptions exceptions) then diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index 009468ac6..dc16d2251 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -9,6 +9,11 @@ open! IStd (** Attributes of a procedure. *) +(** Visibility modifiers. *) +type access = Default | Public | Private | Protected [@@deriving compare] + +val equal_access : access -> access -> bool + type objc_accessor_type = Objc_getter of Struct.field | Objc_setter of Struct.field type var_data = @@ -26,7 +31,7 @@ type specialized_with_blocks_info = [@@deriving compare] type t = - { access: PredSymb.access (** visibility access *) + { access: access (** visibility access *) ; captured: CapturedVar.t list (** name, type, and mode of variables captured in blocks and lambdas *) ; exceptions: string list (** exceptions thrown by the procedure *) @@ -68,7 +73,7 @@ val default : SourceFile.t -> Procname.t -> t val pp : Format.formatter -> t -> unit -val get_access : t -> PredSymb.access +val get_access : t -> access (** Return the visibility attribute *) val get_formals : t -> (Mangled.t * Typ.t) list @@ -81,7 +86,4 @@ val get_loc : t -> Location.t val get_proc_name : t -> Procname.t -val get_pvar_formals : t -> (Pvar.t * Typ.t) list -(** Return pvar and type of formal parameters *) - module SQLite : SqliteUtils.Data with type t = t diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 52a81aaef..34983457c 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -513,10 +513,7 @@ let get_proc_name pdesc = pdesc.attributes.proc_name (** Return name and type of formal parameters *) let get_formals pdesc = pdesc.attributes.formals -let get_pvar_formals pdesc = - let proc_name = get_proc_name pdesc in - get_formals pdesc |> List.map ~f:(fun (name, typ) -> (Pvar.mk name proc_name, typ)) - +let get_pvar_formals pdesc = Pvar.get_pvar_formals pdesc.attributes let get_loc pdesc = pdesc.attributes.loc @@ -786,7 +783,7 @@ let pp_captured_list fmt etl = List.iter ~f:(fun {CapturedVar.name; typ; capture_mode} -> Format.fprintf fmt " [%s] %a:%a" - (Pvar.string_of_capture_mode capture_mode) + (CapturedVar.string_of_capture_mode capture_mode) Mangled.pp name (Typ.pp_full Pp.text) typ ) etl diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index d7008d351..50c25555a 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -229,7 +229,7 @@ val find_map_instrs : t -> f:(Sil.instr -> 'a option) -> 'a option val from_proc_attributes : ProcAttributes.t -> t (** Use [Cfg.create_proc_desc] if you are adding a proc desc to a cfg *) -val get_access : t -> PredSymb.access +val get_access : t -> ProcAttributes.access (** Return the visibility attribute *) val get_attributes : t -> ProcAttributes.t diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index 2412da5e4..02698d62d 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -332,6 +332,6 @@ module Set = PrettyPrintable.MakePPSet (struct let pp = pp Pp.text end) -type capture_mode = ByReference | ByValue [@@deriving compare, equal] - -let string_of_capture_mode = function ByReference -> "by ref" | ByValue -> "by value" +let get_pvar_formals (attributes : ProcAttributes.t) = + let pname = attributes.proc_name in + List.map attributes.formals ~f:(fun (name, typ) -> (mk name pname, typ)) diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index fa0fd9d3a..b37f68eeb 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -176,6 +176,5 @@ val swap_proc_in_local_pvar : t -> Procname.t -> t (** Sets of pvars. *) module Set : PrettyPrintable.PPSet with type elt = t -type capture_mode = ByReference | ByValue [@@deriving compare, equal] - -val string_of_capture_mode : capture_mode -> string +val get_pvar_formals : ProcAttributes.t -> (t * Typ.t) list +(** Return pvar and type of formal parameters *) diff --git a/infer/src/backend/InferAnalyzeJson.ml b/infer/src/backend/InferAnalyzeJson.ml index 591f4e7d0..f80a67b0e 100644 --- a/infer/src/backend/InferAnalyzeJson.ml +++ b/infer/src/backend/InferAnalyzeJson.ml @@ -357,13 +357,13 @@ let parse_method_annotation (json : Safe.t) : Annot.Method.t = let parse_captured_var (json : Safe.t) = let n = to_string (member "name" json) in let t = parse_sil_type_name (member "type" json) in - CapturedVar.make ~name:(Mangled.from_string n) ~typ:t ~capture_mode:Pvar.ByValue + CapturedVar.make ~name:(Mangled.from_string n) ~typ:t ~capture_mode:ByValue let parse_proc_attributes_var (json : Safe.t) = let n = to_string (member "name" json) in let t = parse_sil_type_name (member "type" json) in - (Mangled.from_string n, t, Pvar.ByValue) + (Mangled.from_string n, t, CapturedVar.ByValue) let parse_proc_attributes_formals (json : Safe.t) = @@ -379,18 +379,18 @@ let parse_proc_attributes_locals (json : Safe.t) : ProcAttributes.var_data = let parse_proc_attributes (json : Safe.t) = - let access = + let access : ProcAttributes.access = match to_string (member "access" json) with | "Default" -> - PredSymb.Default + Default | "Public" -> - PredSymb.Public + Public | "Private" -> - PredSymb.Private + Private | "Protected" -> - PredSymb.Protected + Protected | atype -> - Logging.die InternalError "Unsupported access type %s" atype + L.die InternalError "Unsupported access type %s" atype in let captured = parse_list parse_captured_var (member "captured" json) in let formals = parse_list parse_proc_attributes_formals (member "formals" json) in diff --git a/infer/src/biabduction/Predicates.ml b/infer/src/biabduction/Predicates.ml index 2d979a4b9..68aa266ab 100644 --- a/infer/src/biabduction/Predicates.ml +++ b/infer/src/biabduction/Predicates.ml @@ -928,7 +928,7 @@ let rec exp_sub_ids (f : subst_fun) exp = if phys_equal e' e then exp else Exp.Exn e' | Closure c -> let captured_vars = - IList.map_changed ~equal:[%compare.equal: Exp.t * Pvar.t * Typ.t * Pvar.capture_mode] + IList.map_changed ~equal:[%compare.equal: Exp.t * Pvar.t * Typ.t * CapturedVar.capture_mode] ~f:(fun ((e, pvar, typ, mode) as captured) -> let e' = exp_sub_ids f e in if phys_equal e' e then captured else (e', pvar, typ, mode) ) diff --git a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml index 47986fefa..2dbc1c822 100644 --- a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml +++ b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml @@ -475,7 +475,7 @@ let compute_invariant_map : let open IOption.Let_syntax in let get_summary proc_name = analyze_dependency proc_name >>| snd in let get_formals callee_pname = - AnalysisCallbacks.proc_resolve_attributes callee_pname >>| ProcAttributes.get_pvar_formals + AnalysisCallbacks.proc_resolve_attributes callee_pname >>| Pvar.get_pvar_formals in let integer_type_widths = Exe_env.get_integer_type_widths exe_env proc_name in let oenv = OndemandEnv.mk proc_desc tenv integer_type_widths in diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index e4add4d88..f560b383c 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -458,7 +458,7 @@ let checker ({InterproceduralAnalysis.proc_desc; tenv; exe_env; analyze_dependen analysis_summary in let get_formals callee_pname = - AnalysisCallbacks.proc_resolve_attributes callee_pname >>| ProcAttributes.get_pvar_formals + AnalysisCallbacks.proc_resolve_attributes callee_pname >>| Pvar.get_pvar_formals in compute_checks get_checks_summary get_summary get_formals proc_name tenv integer_type_widths cfg inv_map diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 3243f5ae3..3ef0d39fe 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -194,16 +194,16 @@ let create_local_procdesc ?(set_objc_accessor_attr = false) ?(record_lambda_capt let defined = not (List.is_empty fbody) in let proc_name = ms.CMethodSignature.name in let clang_method_kind = ms.CMethodSignature.method_kind in - let access = + let access : ProcAttributes.access = match ms.CMethodSignature.access with | `None -> - PredSymb.Default + Default | `Private -> - PredSymb.Private + Private | `Protected -> - PredSymb.Protected + Protected | `Public -> - PredSymb.Protected + Protected in let captured_mangled = List.map diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index 960851cae..b47dd2399 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -33,7 +33,7 @@ val create_local_procdesc : -> Tenv.t -> CMethodSignature.t -> Clang_ast_t.stmt list - -> (Pvar.t * Typ.t * Pvar.capture_mode) list + -> (Pvar.t * Typ.t * CapturedVar.capture_mode) list -> bool val create_external_procdesc : @@ -57,7 +57,7 @@ val method_signature_of_pointer : Tenv.t -> Clang_ast_t.pointer -> CMethodSignat val get_method_name_from_clang : Tenv.t -> CMethodSignature.t option -> Procname.t option val create_procdesc_with_pointer : - ?captured_vars:(Pvar.t * Typ.t * Pvar.capture_mode) list + ?captured_vars:(Pvar.t * Typ.t * CapturedVar.capture_mode) list -> CContext.t -> Clang_ast_t.pointer -> Typ.Name.t option @@ -65,6 +65,6 @@ val create_procdesc_with_pointer : -> Procname.t val get_procname_from_cpp_lambda : - CContext.t -> Clang_ast_t.decl -> (Pvar.t * Typ.t * Pvar.capture_mode) list -> Procname.t + CContext.t -> Clang_ast_t.decl -> (Pvar.t * Typ.t * CapturedVar.capture_mode) list -> 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 02f17f95d..c49acdb9a 100644 --- a/infer/src/clang/cModule_type.ml +++ b/infer/src/clang/cModule_type.ml @@ -8,7 +8,7 @@ open! IStd type block_data = - { captured_vars: (Pvar.t * Typ.t * Pvar.capture_mode) list + { captured_vars: (Pvar.t * Typ.t * CapturedVar.capture_mode) list ; context: CContext.t ; passed_as_noescape_block_to: Procname.t option ; procname: Procname.t diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 62f8f0838..f25700379 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -297,10 +297,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (** Given a captured var, return the instruction to assign it to a temp *) let assign_captured_var loc (cvar, typ, mode) = - match mode with - | Pvar.ByReference -> + match (mode : CapturedVar.capture_mode) with + | ByReference -> ((Exp.Lvar cvar, cvar, typ, mode), None) - | Pvar.ByValue -> + | ByValue -> let id = Ident.create_fresh Ident.knormal in let instr = Sil.Load {id; e= Exp.Lvar cvar; root_typ= typ; typ; loc} in ((Exp.Var id, cvar, typ, mode), Some instr) @@ -3363,8 +3363,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s List.map captured_vars_no_mode ~f:(fun (var, typ, modify_in_block) -> let mode, typ = if modify_in_block || Pvar.is_global var then - (Pvar.ByReference, Typ.mk (Tptr (typ, Pk_reference))) - else (Pvar.ByValue, typ) + (CapturedVar.ByReference, Typ.mk (Tptr (typ, Pk_reference))) + else (CapturedVar.ByValue, typ) in (var, typ, mode) ) in @@ -3419,8 +3419,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s "Capture-init statement without var decl" in let translate_normal_capture mode (pvar, typ) (trans_results_acc, captured_vars_acc) = - match mode with - | Pvar.ByReference -> ( + match (mode : CapturedVar.capture_mode) with + | ByReference -> ( match typ.Typ.desc with | Tptr (_, Typ.Pk_reference) -> let trans_result, captured_var = @@ -3435,7 +3435,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ( trans_results_acc , (Exp.Lvar pvar, pvar, Typ.mk (Tptr (typ, Pk_reference)), mode) :: captured_vars_acc ) ) - | Pvar.ByValue -> ( + | ByValue -> ( let init, exp, typ_new = match typ.Typ.desc with (* TODO: Structs are missing copy constructor instructions when passed by value *) @@ -3479,7 +3479,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | `LCK_StarThis (* [*this] is special syntax for capturing current object by value *) -> false in - let mode = if is_by_ref then Pvar.ByReference else Pvar.ByValue in + let mode = if is_by_ref then CapturedVar.ByReference else CapturedVar.ByValue in match (lci_captured_var, lci_init_captured_vardecl) with | Some captured_var_decl_ref, Some init_decl -> ( (* capture and init *) diff --git a/infer/src/concurrency/RacerDFileAnalysis.ml b/infer/src/concurrency/RacerDFileAnalysis.ml index 184a4f037..9705313f7 100644 --- a/infer/src/concurrency/RacerDFileAnalysis.ml +++ b/infer/src/concurrency/RacerDFileAnalysis.ml @@ -361,7 +361,7 @@ let should_report_on_proc tenv procdesc = (* return true if procedure is at an abstraction boundary or reporting has been explicitly requested via @ThreadSafe in java *) RacerDModels.is_thread_safe_method proc_name tenv - || (not (PredSymb.equal_access (Procdesc.get_access procdesc) Private)) + || (not (ProcAttributes.equal_access (Procdesc.get_access procdesc) Private)) && (not (Procname.Java.is_class_initializer java_pname)) && (not (Procname.Java.is_autogen_method java_pname)) && not (Annotations.pdesc_return_annot_ends_with procdesc Annotations.visibleForTesting) @@ -369,7 +369,7 @@ let should_report_on_proc tenv procdesc = (* do not report on lambdas; they are essentially private though do not appear as such *) false | ObjC_Cpp {kind= CPPMethod _ | CPPConstructor _ | CPPDestructor _} -> - not (PredSymb.equal_access (Procdesc.get_access procdesc) Private) + not (ProcAttributes.equal_access (Procdesc.get_access procdesc) Private) | ObjC_Cpp {kind= ObjCClassMethod | ObjCInstanceMethod | ObjCInternalMethod; class_name} -> Tenv.lookup tenv class_name |> Option.exists ~f:(fun {Struct.exported_objc_methods} -> diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 5c0cf27e4..1e0c37294 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -638,7 +638,7 @@ let fold_reportable_summaries analyze_ondemand tenv clazz ~init ~f = List.fold methods ~init ~f -let is_private attrs = PredSymb.equal_access (ProcAttributes.get_access attrs) Private +let is_private attrs = ProcAttributes.equal_access (ProcAttributes.get_access attrs) Private (* Note about how many times we report a deadlock: normally twice, at each trace starting point. Due to the fact we look for deadlocks in the summaries of the class at the root of a path, diff --git a/infer/src/cost/cost.ml b/infer/src/cost/cost.ml index 0a9271bec..11829ba75 100644 --- a/infer/src/cost/cost.ml +++ b/infer/src/cost/cost.ml @@ -436,7 +436,7 @@ let checker ({InterproceduralAnalysis.proc_desc; exe_env; analyze_dependency} as inferbo_summary in let get_formals callee_pname = - AnalysisCallbacks.proc_resolve_attributes callee_pname >>| ProcAttributes.get_pvar_formals + AnalysisCallbacks.proc_resolve_attributes callee_pname >>| Pvar.get_pvar_formals in let instr_cfg = InstrCFG.from_pdesc proc_desc in let extras = diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index a5c1460ea..6d4b7568c 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -287,15 +287,15 @@ let pp_jbir fmt jbir = fmt (JBir.print jbir) -let trans_access = function +let trans_access : _ -> ProcAttributes.access = function | `Default -> - PredSymb.Default + Default | `Public -> - PredSymb.Public + Public | `Private -> - PredSymb.Private + Private | `Protected -> - PredSymb.Protected + Protected let create_callee_attributes tenv program cn ms procname = diff --git a/infer/src/nullsafe/Initializers.ml b/infer/src/nullsafe/Initializers.ml index 276413858..e92b6c01b 100644 --- a/infer/src/nullsafe/Initializers.ml +++ b/infer/src/nullsafe/Initializers.ml @@ -18,7 +18,7 @@ let final_typestates initializers_current_class tenv typecheck_proc = let do_proc (init_pn, init_pd) = let filter callee_pn callee_attributes = let is_private = - PredSymb.equal_access callee_attributes.ProcAttributes.access PredSymb.Private + ProcAttributes.equal_access callee_attributes.ProcAttributes.access Private in let same_class = let get_class_opt pn = diff --git a/infer/src/pulse/Pulse.ml b/infer/src/pulse/Pulse.ml index f029d8a88..9881ebc86 100644 --- a/infer/src/pulse/Pulse.ml +++ b/infer/src/pulse/Pulse.ml @@ -38,7 +38,7 @@ module PulseTransferFunctions = struct type analysis_data = PulseSummary.t InterproceduralAnalysis.t let get_pvar_formals pname = - AnalysisCallbacks.proc_resolve_attributes pname |> Option.map ~f:ProcAttributes.get_pvar_formals + AnalysisCallbacks.proc_resolve_attributes pname |> Option.map ~f:Pvar.get_pvar_formals let interprocedural_call {InterproceduralAnalysis.analyze_dependency; tenv; proc_desc} ret diff --git a/infer/src/pulse/PulseModels.ml b/infer/src/pulse/PulseModels.ml index b7f569c05..91a155ce1 100644 --- a/infer/src/pulse/PulseModels.ml +++ b/infer/src/pulse/PulseModels.ml @@ -97,7 +97,7 @@ module Misc = struct in let formals_opt = AnalysisCallbacks.proc_resolve_attributes callee_procname - |> Option.map ~f:ProcAttributes.get_pvar_formals + |> Option.map ~f:Pvar.get_pvar_formals in PulseCallOperations.unknown_call tenv location (Model skip_reason) ~ret ~actuals ~formals_opt astate diff --git a/infer/src/pulse/PulseOperations.ml b/infer/src/pulse/PulseOperations.ml index 04c10a58f..91990eb7a 100644 --- a/infer/src/pulse/PulseOperations.ml +++ b/infer/src/pulse/PulseOperations.ml @@ -105,14 +105,14 @@ module Closures = struct let fake_capture_field_prefix = "__capture_" let string_of_capture_mode = function - | Pvar.ByReference -> + | CapturedVar.ByReference -> "by_ref_" - | Pvar.ByValue -> + | CapturedVar.ByValue -> "by_value_" let fake_captured_by_ref_field_prefix = - Printf.sprintf "%s%s" fake_capture_field_prefix (string_of_capture_mode Pvar.ByReference) + Printf.sprintf "%s%s" fake_capture_field_prefix (string_of_capture_mode ByReference) let mk_fake_field ~id mode = diff --git a/infer/src/pulse/PulseOperations.mli b/infer/src/pulse/PulseOperations.mli index c5e1655b6..38f0d577e 100644 --- a/infer/src/pulse/PulseOperations.mli +++ b/infer/src/pulse/PulseOperations.mli @@ -204,7 +204,7 @@ val check_address_escape : val get_captured_actuals : Location.t - -> captured_vars:(Var.t * Pvar.capture_mode * Typ.t) list + -> captured_vars:(Var.t * CapturedVar.capture_mode * Typ.t) list -> actual_closure:AbstractValue.t * ValueHistory.t -> t -> (t * (Var.t * ((AbstractValue.t * ValueHistory.t) * Typ.t)) list) AccessResult.t diff --git a/infer/src/pulse/PulseValueHistory.ml b/infer/src/pulse/PulseValueHistory.ml index 55fd9b075..675df5b87 100644 --- a/infer/src/pulse/PulseValueHistory.ml +++ b/infer/src/pulse/PulseValueHistory.ml @@ -12,7 +12,7 @@ type event = | Allocation of {f: CallEvent.t; location: Location.t} | Assignment of Location.t | Call of {f: CallEvent.t; location: Location.t; in_call: t} - | Capture of {captured_as: Pvar.t; mode: Pvar.capture_mode; location: Location.t} + | Capture of {captured_as: Pvar.t; mode: CapturedVar.capture_mode; location: Location.t} | Conditional of {is_then_branch: bool; if_kind: Sil.if_kind; location: Location.t} | CppTemporaryCreated of Location.t | FormalDeclared of Pvar.t * Location.t @@ -45,7 +45,7 @@ let pp_event_no_location fmt event = F.fprintf fmt "allocated by call to %a" CallEvent.pp f | Capture {captured_as; mode; location= _} -> F.fprintf fmt "value captured %s as `%a`" - (Pvar.string_of_capture_mode mode) + (CapturedVar.string_of_capture_mode mode) Pvar.pp_value_non_verbose captured_as | Conditional {is_then_branch; if_kind; location= _} -> F.fprintf fmt "expression in %s condition is %b" (Sil.if_kind_to_string if_kind) diff --git a/infer/src/pulse/PulseValueHistory.mli b/infer/src/pulse/PulseValueHistory.mli index 9210fa1e4..e1716991c 100644 --- a/infer/src/pulse/PulseValueHistory.mli +++ b/infer/src/pulse/PulseValueHistory.mli @@ -12,7 +12,7 @@ type event = | Allocation of {f: CallEvent.t; location: Location.t} | Assignment of Location.t | Call of {f: CallEvent.t; location: Location.t; in_call: t} - | Capture of {captured_as: Pvar.t; mode: Pvar.capture_mode; location: Location.t} + | Capture of {captured_as: Pvar.t; mode: CapturedVar.capture_mode; location: Location.t} | Conditional of {is_then_branch: bool; if_kind: Sil.if_kind; location: Location.t} | CppTemporaryCreated of Location.t | FormalDeclared of Pvar.t * Location.t diff --git a/infer/src/quandary/ClangTrace.ml b/infer/src/quandary/ClangTrace.ml index 599a0e00e..72cfd48bb 100644 --- a/infer/src/quandary/ClangTrace.ml +++ b/infer/src/quandary/ClangTrace.ml @@ -122,8 +122,8 @@ module SourceKind = struct let get_tainted_formals pdesc tenv = - if PredSymb.equal_access (Procdesc.get_attributes pdesc).ProcAttributes.access PredSymb.Private - then Source.all_formals_untainted pdesc + if ProcAttributes.equal_access (Procdesc.get_access pdesc) Private then + Source.all_formals_untainted pdesc else let overrides_service_method pname tenv = PatternMatch.override_exists diff --git a/infer/src/unit/addressTakenTests.ml b/infer/src/unit/addressTakenTests.ml index 1c73a2a83..07a93c676 100644 --- a/infer/src/unit/addressTakenTests.ml +++ b/infer/src/unit/addressTakenTests.ml @@ -17,7 +17,7 @@ let tests = let fun_ptr_typ = Typ.mk (Tptr (Typ.mk Tfun, Pk_pointer)) in let closure_exp captureds = let mk_captured_var str = - (Exp.Var (ident_of_str str), pvar_of_str str, int_ptr_typ, Pvar.ByReference) + (Exp.Var (ident_of_str str), pvar_of_str str, int_ptr_typ, CapturedVar.ByReference) in let captured_vars = List.map ~f:mk_captured_var captureds in let closure = {Exp.name= dummy_procname; captured_vars} in diff --git a/infer/src/unit/livenessTests.ml b/infer/src/unit/livenessTests.ml index 25df8b436..2c77888d6 100644 --- a/infer/src/unit/livenessTests.ml +++ b/infer/src/unit/livenessTests.ml @@ -16,7 +16,7 @@ let tests = let fun_ptr_typ = Typ.mk (Tptr (Typ.mk Tfun, Pk_pointer)) in let closure_exp captured_pvars = let mk_captured_var str = - (Exp.Var (ident_of_str str), pvar_of_str str, dummy_typ, Pvar.ByReference) + (Exp.Var (ident_of_str str), pvar_of_str str, dummy_typ, CapturedVar.ByReference) in let captured_vars = List.map ~f:mk_captured_var captured_pvars in let closure = {Exp.name= dummy_procname; captured_vars} in