diff --git a/infer/src/.ocamlformat b/infer/src/.ocamlformat index cc75ba8df..9320c5f93 100644 --- a/infer/src/.ocamlformat +++ b/infer/src/.ocamlformat @@ -2,4 +2,5 @@ profile = ocamlformat break-before-in = fit-or-vertical let-binding-spacing = sparse margin = 100 +parse-docstrings = true version = 0.12-21-gdd929ea diff --git a/infer/src/IR/AccessPath.mli b/infer/src/IR/AccessPath.mli index 833ffd515..8482bf870 100644 --- a/infer/src/IR/AccessPath.mli +++ b/infer/src/IR/AccessPath.mli @@ -17,23 +17,23 @@ type access = [@@deriving compare] (** root var, and a list of accesses. closest to the root var is first that is, x.f.g is - representedas (x, [f; g]) *) + representedas (x, [f; g]) *) and t = base * access list [@@deriving compare] val truncate : t -> t * access option -(** remove and return the last access of the access path if the access list is non-empty. returns +(** remove and return the last access of the access path if the access list is non-empty. returns the original access path * None if the access list is empty *) val get_last_access : t -> access option (** get the last access in the list. returns None if the list is empty *) val get_field_and_annotation : t -> Tenv.t -> (Typ.Fieldname.t * Annot.Item.t) option -(** get the field name and the annotation of the last access in the list of accesses if - the list is non-empty and the last access is a field access *) +(** get the field name and the annotation of the last access in the list of accesses if the list is + non-empty and the last access is a field access *) val get_typ : t -> Tenv.t -> Typ.t option -(** get the typ of the last access in the list of accesses if the list is non-empty, or the base - if the list is empty. that is, for x.f.g, return typ(g), and for x, return typ(x) *) +(** get the typ of the last access in the list of accesses if the list is non-empty, or the base if + the list is empty. that is, for x.f.g, return typ(g), and for x, return typ(x) *) val base_of_pvar : Pvar.t -> Typ.t -> base (** create a base from a pvar *) @@ -46,7 +46,8 @@ val of_id : Ident.t -> Typ.t -> t val of_exp : include_array_indexes:bool -> Exp.t -> Typ.t -> f_resolve_id:(Var.t -> t option) -> t list -(** extract the access paths that occur in [exp], resolving identifiers using [f_resolve_id]. don't include index expressions in array accesses if [include_array_indexes] is false *) +(** extract the access paths that occur in [exp], resolving identifiers using [f_resolve_id]. don't + include index expressions in array accesses if [include_array_indexes] is false *) val of_lhs_exp : include_array_indexes:bool -> Exp.t -> Typ.t -> f_resolve_id:(Var.t -> t option) -> t option @@ -62,15 +63,13 @@ val is_prefix : t -> t -> bool val replace_prefix : prefix:t -> t -> t -> t option [@@warning "-32"] val inner_class_normalize : t -> t -(** transform an access path that starts on "this" of an inner class but which breaks out to - access outer class fields to the outermost one. - Cases handled (recursively): -- (this:InnerClass* ).(this$n:OuterClassAccessor).f. ... -> (this:OuterClass* ).f . ... -- this$n.(this$m:OuterClassAccessor).f ... -> (this$m:OuterClass* ).f . ... - (happens in ctrs only) -- this$n.f ... -> this.f . ... - (happens in ctrs only) -*) +(** transform an access path that starts on "this" of an inner class but which breaks out to access + outer class fields to the outermost one. Cases handled (recursively): + + - (this:InnerClass* ).(this$n:OuterClassAccessor).f. ... -> (this:OuterClass* ).f . ... + - this$n.(this$m:OuterClassAccessor).f ... -> (this$m:OuterClass* ).f . ... (happens in ctrs + only) + - this$n.f ... -> this.f . ... (happens in ctrs only) *) val equal : t -> t -> bool @@ -99,11 +98,11 @@ module Abs : sig val get_footprint_index_base : base -> int option (** return the formal index associated with the base of this access path if there is one, or None - otherwise *) + otherwise *) val with_base : base -> t -> t (** swap base of existing access path for [base_var] (e.g., `with_base_bvar x y.f.g` produces - `x.f.g` *) + `x.f.g` *) val extract : t -> raw (** extract a raw access path from its wrapper *) diff --git a/infer/src/IR/Annot.ml b/infer/src/IR/Annot.ml index b3d152a1d..4bf38008b 100644 --- a/infer/src/IR/Annot.ml +++ b/infer/src/IR/Annot.ml @@ -15,7 +15,7 @@ type parameter = {name: string option; value: string} [@@deriving compare] type parameters = parameter list [@@deriving compare] -(** Type to represent one @Annotation. *) +(** Type to represent one [@Annotation]. *) type t = { class_name: string (** name of the annotation *) ; parameters: parameters (** currently only one string parameter *) } diff --git a/infer/src/IR/Annot.mli b/infer/src/IR/Annot.mli index c9252eed1..b60b1982c 100644 --- a/infer/src/IR/Annot.mli +++ b/infer/src/IR/Annot.mli @@ -15,7 +15,7 @@ type parameter = {name: string option; value: string} type parameters = parameter list -(** Type to represent one @Annotation. *) +(** Type to represent one [@Annotation]. *) type t = { class_name: string (** name of the annotation *) ; parameters: parameters (** currently only one string parameter *) } diff --git a/infer/src/IR/Attributes.mli b/infer/src/IR/Attributes.mli index e6bdf479e..a3703125d 100644 --- a/infer/src/IR/Attributes.mli +++ b/infer/src/IR/Attributes.mli @@ -23,8 +23,7 @@ val load_defined : Typ.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 -(** 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. *) +(** 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. *) val pp_attributes_kind : Format.formatter -> attributes_kind -> unit diff --git a/infer/src/IR/Binop.ml b/infer/src/IR/Binop.ml index cdafa5fde..13e5b19ad 100644 --- a/infer/src/IR/Binop.ml +++ b/infer/src/IR/Binop.ml @@ -26,8 +26,8 @@ type t = | Mod (** % *) | Shiftlt (** shift left *) | Shiftrt (** shift right *) - | Lt (** < (arithmetic comparison) *) - | Gt (** > (arithmetic comparison) *) + | Lt (** < (arithmetic comparison) *) + | Gt (** > (arithmetic comparison) *) | Le (** <= (arithmetic comparison) *) | Ge (** >= (arithmetic comparison) *) | Eq (** == (arithmetic comparison) *) @@ -41,13 +41,12 @@ type t = let equal = [%compare.equal: t] -(** This function returns true if the operation is injective - wrt. each argument: op(e,-) and op(-, e) is injective for all e. - The return value false means "don't know". *) +(** This function returns true if the operation is injective wrt. each argument: op(e,-) and op(-, + e) is injective for all e. The return value false means "don't know". *) let injective = function PlusA _ | PlusPI | MinusA _ | MinusPI | MinusPP -> true | _ -> false -(** This function returns true if 0 is the right unit of [binop]. - The return value false means "don't know". *) +(** This function returns true if 0 is the right unit of [binop]. The return value false means + "don't know". *) let is_zero_runit = function PlusA _ | PlusPI | MinusA _ | MinusPI | MinusPP -> true | _ -> false let text = function diff --git a/infer/src/IR/Binop.mli b/infer/src/IR/Binop.mli index 40b248e53..4b5d71b47 100644 --- a/infer/src/IR/Binop.mli +++ b/infer/src/IR/Binop.mli @@ -22,8 +22,8 @@ type t = | Mod (** % *) | Shiftlt (** shift left *) | Shiftrt (** shift right *) - | Lt (** < (arithmetic comparison) *) - | Gt (** > (arithmetic comparison) *) + | Lt (** < (arithmetic comparison) *) + | Gt (** > (arithmetic comparison) *) | Le (** <= (arithmetic comparison) *) | Ge (** >= (arithmetic comparison) *) | Eq (** == (arithmetic comparison) *) @@ -38,13 +38,12 @@ type t = val equal : t -> t -> bool val injective : t -> bool -(** This function returns true if the operation is injective - wrt. each argument: op(e,-) and op(-, e) is injective for all e. - The return value false means "don't know". *) +(** This function returns true if the operation is injective wrt. each argument: op(e,-) and op(-, + e) is injective for all e. The return value false means "don't know". *) val is_zero_runit : t -> bool -(** This function returns true if 0 is the right unit of [binop]. - The return value false means "don't know". *) +(** This function returns true if 0 is the right unit of [binop]. The return value false means + "don't know". *) val str : Pp.env -> t -> string (** String representation of a binary operator. *) diff --git a/infer/src/IR/Cfg.mli b/infer/src/IR/Cfg.mli index 929b3ac3a..7112dfead 100644 --- a/infer/src/IR/Cfg.mli +++ b/infer/src/IR/Cfg.mli @@ -18,7 +18,7 @@ val get_all_defined_proc_names : t -> Typ.Procname.t list val store : SourceFile.t -> t -> unit (** Save the individual [Procdesc.t] and [ProcAttributes.t] to the database for the procedures in - the cfg. *) + the cfg. *) (** {2 Functions for manipulating an interprocedural CFG} *) diff --git a/infer/src/IR/DecompiledExp.ml b/infer/src/IR/DecompiledExp.ml index 9719a0518..46f737894 100644 --- a/infer/src/IR/DecompiledExp.ml +++ b/infer/src/IR/DecompiledExp.ml @@ -27,8 +27,8 @@ type t = | Dunknown | Dretcall of t * t list * Location.t * CallFlags.t -(** Value paths: identify an occurrence of a value in a symbolic heap - each expression represents a path, with Dpvar being the simplest one *) +(** Value paths: identify an occurrence of a value in a symbolic heap each expression represents a + path, with Dpvar being the simplest one *) type vpath = t option let eradicate_java () = Config.eradicate && Language.curr_language_is Java diff --git a/infer/src/IR/DecompiledExp.mli b/infer/src/IR/DecompiledExp.mli index 0e97c29d9..326f3bba3 100644 --- a/infer/src/IR/DecompiledExp.mli +++ b/infer/src/IR/DecompiledExp.mli @@ -27,8 +27,8 @@ type t = | Dunknown | Dretcall of t * t list * Location.t * CallFlags.t -(** Value paths: identify an occurrence of a value in a symbolic heap - each expression represents a path, with Dpvar being the simplest one *) +(** Value paths: identify an occurrence of a value in a symbolic heap each expression represents a + path, with Dpvar being the simplest one *) type vpath = t option val pp : F.formatter -> t -> unit diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 0a674c0bb..aed1d8951 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -141,9 +141,8 @@ module ErrLogHash = struct include Hashtbl.Make (Key) end -(** Type of the error log, to be reset once per function. - Map severity, footprint / re - execution flag, error name, - error description, severity, to set of err_data. *) +(** Type of the error log, to be reset once per function. Map severity, footprint / re - execution + flag, error name, error description, severity, to set of err_data. *) type t = ErrDataSet.t ErrLogHash.t (** Empty error log *) @@ -215,8 +214,8 @@ let pp_html source path_to_root fmt (errlog : t) = List.iter Exceptions.[Advice; Error; Info; Like; Warning] ~f:pp -(** Add an error description to the error log unless there is - one already at the same node + session; return true if added *) +(** Add an error description to the error log unless there is one already at the same node + + session; return true if added *) let add_issue tbl err_key (err_datas : ErrDataSet.t) : bool = try let current_eds = ErrLogHash.find tbl err_key in diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 69d90f4c1..5dab14942 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -31,9 +31,8 @@ type loc_trace = loc_trace_elem list val concat_traces : (string * loc_trace) list -> loc_trace val compute_local_exception_line : loc_trace -> int option -(** Look at all the trace steps and find those that are arising any exception, - then bind them to the closest step at level 0. - This extra information adds value to the report itself, and may avoid +(** Look at all the trace steps and find those that are arising any exception, then bind them to the + closest step at level 0. This extra information adds value to the report itself, and may avoid digging into the trace to understand the cause of the report. *) type node = @@ -52,8 +51,8 @@ val merge_err_key : -> merge_descriptions:(string list -> string list -> string) -> err_key (** Merges two error keys, setting the result's severity to the maximum of that of the two arguments - and giving the user the opportunity to pass a function to merge the IssueTypes and descriptions - of the two. *) + and giving the user the opportunity to pass a function to merge the IssueTypes and descriptions + of the two. *) (** Data associated to a specific error *) type err_data = private @@ -73,8 +72,8 @@ type err_data = private val merge_err_data : err_data -> err_data -> err_data (** Merges two err_datas, throwing out most information and setting the trace of the result to the - concatenation of the traces of the two arguments with a separator in between. Used specifically - for QuandaryBO. *) + concatenation of the traces of the two arguments with a separator in between. Used specifically + for QuandaryBO. *) (** Type of the error log *) type t @@ -104,7 +103,7 @@ val pp_html : SourceFile.t -> DB.Results_dir.path -> Format.formatter -> t -> un (** Print an error log in html format *) val size : (Exceptions.severity -> bool) -> t -> int -(** Return the number of elements in the error log which satisfy the filter. *) +(** Return the number of elements in the error log which satisfy the filter. *) val update : t -> t -> unit (** Update an old error log with a new one *) diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index b9f098561..f52d72df8 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -585,7 +585,7 @@ let severity_string = function "WARNING" -(** pretty print an error *) +(** pretty print an error *) let pp_err loc severity ex_name desc ocaml_pos_opt fmt () = let kind = severity_string (if equal_severity severity Info then Warning else severity) in F.fprintf fmt "%a:%d: %s: %a %a%a@\n" SourceFile.pp loc.Location.file loc.Location.line kind diff --git a/infer/src/IR/Exp.ml b/infer/src/IR/Exp.ml index 7ff037372..3eb12ef5a 100644 --- a/infer/src/IR/Exp.ml +++ b/infer/src/IR/Exp.ml @@ -81,8 +81,8 @@ let rec is_const = function Const _ -> true | Cast (_, x) -> is_const x | _ -> f (** {2 Utility Functions for Expressions} *) -(** Turn an expression representing a type into the type it represents - If not a sizeof, return the default type if given, otherwise raise an exception *) +(** Turn an expression representing a type into the type it represents If not a sizeof, return the + default type if given, otherwise raise an exception *) let texp_to_typ default_opt = function | Sizeof {typ} -> typ @@ -111,8 +111,8 @@ let rec root_of_lexp lexp = lexp -(** Checks whether an expression denotes a location by pointer arithmetic. - Currently, catches array-indexing expressions such as a[i] only. *) +(** Checks whether an expression denotes a location by pointer arithmetic. Currently, catches + array-indexing expressions such as a[i] only. *) let rec pointer_arith = function | Lfield (e, _, _) -> pointer_arith e diff --git a/infer/src/IR/Exp.mli b/infer/src/IR/Exp.mli index 2d3c0cde6..4c72e6f90 100644 --- a/infer/src/IR/Exp.mli +++ b/infer/src/IR/Exp.mli @@ -8,8 +8,7 @@ (** The Smallfoot Intermediate Language: Expressions -NOTE: For doing substitutionson expressions, there are some functions in [Sil]. -*) + NOTE: For doing substitutionson expressions, there are some functions in [Sil]. *) open! IStd module F = Format @@ -68,19 +67,19 @@ val is_const : t -> bool (** {2 Utility Functions for Expressions} *) val texp_to_typ : Typ.t option -> t -> Typ.t -(** Turn an expression representing a type into the type it represents - If not a sizeof, return the default type if given, otherwise raise an exception *) +(** Turn an expression representing a type into the type it represents If not a sizeof, return the + default type if given, otherwise raise an exception *) val root_of_lexp : t -> t (** Return the root of [lexp]. *) val get_undefined : bool -> t -(** Get an expression "undefined", the boolean indicates - whether the undefined value goest into the footprint *) +(** Get an expression "undefined", the boolean indicates whether the undefined value goest into the + footprint *) val pointer_arith : t -> bool -(** Checks whether an expression denotes a location using pointer arithmetic. - Currently, catches array - indexing expressions such as a[i] only. *) +(** Checks whether an expression denotes a location using pointer arithmetic. Currently, catches + array - indexing expressions such as a[i] only. *) val has_local_addr : t -> bool (** returns true if the expression operates on address of local variable *) @@ -134,7 +133,7 @@ val program_vars : t -> Pvar.t Sequence.t val rename_pvars : f:(string -> string) -> t -> t (** Rename all Pvars according to the function [f]. WARNING: You want to rename pvars before you -combine expressions from different symbolic states, which you RARELY want to.*) + combine expressions from different symbolic states, which you RARELY want to.*) val fold_captured : f:('a -> t -> 'a) -> t -> 'a -> 'a (** Fold over the expressions captured by this expression. *) diff --git a/infer/src/IR/HilExp.ml b/infer/src/IR/HilExp.ml index b8daa6b56..e1f59da5f 100644 --- a/infer/src/IR/HilExp.ml +++ b/infer/src/IR/HilExp.ml @@ -36,12 +36,12 @@ module Access = struct end (** Module where unsafe construction of [access_expression] is allowed. In the rest of the code, and - especially in clients of the whole [AccessExpression] module, we do not want to allow - constructing access expressions directly as they could introduce de-normalized expressions of the - form [AddressOf (Dereference t)] or [Dereference (AddressOf t)]. + especially in clients of the whole [AccessExpression] module, we do not want to allow + constructing access expressions directly as they could introduce de-normalized expressions of + the form [AddressOf (Dereference t)] or [Dereference (AddressOf t)]. We could make only the types of [AddressOf] and [Dereference] private but that proved too - cumbersome... *) + cumbersome... *) module T : sig type t = | AccessExpression of access_expression @@ -648,9 +648,8 @@ let rec eval_boolean_binop op var e1 e2 = |> Option.map ~f:(fun (b1, b2) -> op b1 b2) -(** return [Some bool_value] if the given boolean expression evaluates to bool_value when - [var] is set to true. return None if it has free variables that stop us from - evaluating it *) +(** return [Some bool_value] if the given boolean expression evaluates to bool_value when [var] is + set to true. return None if it has free variables that stop us from evaluating it *) and eval_boolean_exp var = function | AccessExpression access_expr when AccessExpression.equal access_expr var -> Some true diff --git a/infer/src/IR/HilExp.mli b/infer/src/IR/HilExp.mli index fddca643e..a65d65f27 100644 --- a/infer/src/IR/HilExp.mli +++ b/infer/src/IR/HilExp.mli @@ -31,8 +31,8 @@ type t = | Constant of Const.t (** Constants *) | Cast of Typ.t * t (** Type cast *) | Sizeof of Typ.t * t option - (** C-style sizeof(), and also used to treate a type as an expression. Refer to [Exp] module for - canonical documentation *) + (** C-style sizeof(), and also used to treate a type as an expression. Refer to [Exp] module + for canonical documentation *) and access_expression = private | Base of AccessPath.base @@ -81,12 +81,12 @@ module AccessExpression : sig val add_access : access_expression -> t option Access.t -> access_expression option val truncate : access_expression -> (access_expression * t option Access.t) option - (** remove and return the prefix and the last access of the expression if it's a base; - otherwise return None *) + (** remove and return the prefix and the last access of the expression if it's a base; otherwise + return None *) val append : onto:access_expression -> access_expression -> access_expression option - (** [append ~onto y] replaces the base of [y] with [onto] itself; this makes sense if no - [Dereference (AddressOf _)] instances are introduced *) + (** [append ~onto y] replaces the base of [y] with [onto] itself; this makes sense if no + [Dereference (AddressOf _)] instances are introduced *) type nonrec t = access_expression = private | Base of AccessPath.base @@ -124,9 +124,9 @@ val is_int_zero : t -> bool val eval : t -> Const.t option val eval_boolean_exp : AccessExpression.t -> t -> bool option -(** [eval_boolean_exp var exp] returns [Some bool_value] if the given boolean expression [exp] - evaluates to [bool_value] when [var] is set to true. Return None if it has free variables - that stop us from evaluating it, or is not a boolean expression. *) +(** [eval_boolean_exp var exp] returns [Some bool_value] if the given boolean expression [exp] + evaluates to [bool_value] when [var] is set to true. Return None if it has free variables that + stop us from evaluating it, or is not a boolean expression. *) val ignore_cast : t -> t diff --git a/infer/src/IR/HilInstr.ml b/infer/src/IR/HilInstr.ml index 256005227..21ac14bb5 100644 --- a/infer/src/IR/HilInstr.ml +++ b/infer/src/IR/HilInstr.ml @@ -42,9 +42,9 @@ let pp fmt = function type translation = Instr of t | Bind of Var.t * HilExp.AccessExpression.t (** convert an SIL instruction into an HIL instruction. The [f_resolve_id] function should map an - SSA temporary variable to the access path it represents. Evaluating the HIL instruction should - produce the same result as evaluating the SIL instruction and replacing the temporary variables - using [f_resolve_id]. *) + SSA temporary variable to the access path it represents. Evaluating the HIL instruction should + produce the same result as evaluating the SIL instruction and replacing the temporary variables + using [f_resolve_id]. *) let of_sil ~include_array_indexes ~f_resolve_id (instr : Sil.instr) = let exp_of_sil ?(add_deref = false) = HilExp.of_sil ~include_array_indexes ~f_resolve_id ~add_deref diff --git a/infer/src/IR/HilInstr.mli b/infer/src/IR/HilInstr.mli index 4577d0d8b..f5b81a56e 100644 --- a/infer/src/IR/HilInstr.mli +++ b/infer/src/IR/HilInstr.mli @@ -36,6 +36,6 @@ val of_sil : -> Sil.instr -> translation (** convert an SIL instruction into an HIL instruction. The [f_resolve_id] function should map an - SSA temporary variable to the access path it represents. Evaluating the HIL instruction should - produce the same result as evaluating the SIL instruction and replacing the temporary variables - using [f_resolve_id]. *) + SSA temporary variable to the access path it represents. Evaluating the HIL instruction should + produce the same result as evaluating the SIL instruction and replacing the temporary variables + using [f_resolve_id]. *) diff --git a/infer/src/IR/Ident.ml b/infer/src/IR/Ident.ml index 08f57e290..1375b76bb 100644 --- a/infer/src/IR/Ident.ml +++ b/infer/src/IR/Ident.ml @@ -46,8 +46,9 @@ let equal_name = [%compare.equal: name] type kind = | KNone - (** special kind of "null ident" (basically, a more compact way of implementing an ident option). - useful for situations when an instruction requires an id, but no one should read the result. *) + (** special kind of "null ident" (basically, a more compact way of implementing an ident + option). useful for situations when an instruction requires an id, but no one should read + the result. *) | KFootprint | KNormal | KPrimed diff --git a/infer/src/IR/Ident.mli b/infer/src/IR/Ident.mli index 189b342a3..814caf2ee 100644 --- a/infer/src/IR/Ident.mli +++ b/infer/src/IR/Ident.mli @@ -98,7 +98,8 @@ val create_fresh : kind -> t (** Create a fresh identifier with default name for the given kind. *) val create_fresh_specialized_with_blocks : kind -> t -(** Create a fresh identifier with default name for the given kind, with a non-clashing id for objc block specialization *) +(** Create a fresh identifier with default name for the given kind, with a non-clashing id for objc + block specialization *) val create_path : string -> t (** Generate a normal identifier whose name encodes a path given as a string. *) diff --git a/infer/src/IR/IntLit.mli b/infer/src/IR/IntLit.mli index 5c18e69b2..d6dfcf5b4 100644 --- a/infer/src/IR/IntLit.mli +++ b/infer/src/IR/IntLit.mli @@ -20,8 +20,8 @@ val compare : t -> t -> int (** compare integers ignoring the distinction between pointers and non-pointers *) val compare_value : t -> t -> int -(** compare the value of the integers, notice this is different from const compare, - which distinguished between signed and unsigned +1 *) +(** compare the value of the integers, notice this is different from const compare, which + distinguished between signed and unsigned +1 *) val div : t -> t -> t diff --git a/infer/src/IR/Io_infer.mli b/infer/src/IR/Io_infer.mli index 98e2b79e4..c9cd6688e 100644 --- a/infer/src/IR/Io_infer.mli +++ b/infer/src/IR/Io_infer.mli @@ -50,10 +50,9 @@ module Html : sig -> Format.formatter -> int -> unit - (** Print an html link to the given node. - Usage: [pp_node_link path_to_root ... fmt id]. - [path_to_root] is the path to the dir for the procedure in the spec db. - [id] is the node identifier. *) + (** Print an html link to the given node. Usage: [pp_node_link path_to_root ... fmt id]. + [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 (** Print an html link to the given proc *) diff --git a/infer/src/IR/IssueLog.mli b/infer/src/IR/IssueLog.mli index f5f03fcc6..ac772126a 100644 --- a/infer/src/IR/IssueLog.mli +++ b/infer/src/IR/IssueLog.mli @@ -16,12 +16,12 @@ val iter : f:(Typ.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 -(** 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. *) +(** 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. *) val store : dir:string -> file:SourceFile.t -> t -> unit (** If there are any issues in the log, [store ~dir ~file] stores map to [infer-out/dir/file]. Otherwise, no file is written. *) val load : string -> t -(** [load directory] walks [infer-out/directory], merging maps stored in files into one map. *) +(** [load directory] walks [infer-out/directory], merging maps stored in files into one map. *) diff --git a/infer/src/IR/Localise.ml b/infer/src/IR/Localise.ml index c816212f8..8d651e39f 100644 --- a/infer/src/IR/Localise.ml +++ b/infer/src/IR/Localise.ml @@ -34,7 +34,7 @@ module Tags = struct (** describes a NPE that comes from field not nullable *) let field_not_null_checked = "field_not_null_checked" - (** @Nullable-annoted field/param/retval that causes a warning *) + (** [@Nullable]-annoted field/param/retval that causes a warning *) let nullable_src = "nullable_src" (** Weak variable captured in a block that causes a warning *) diff --git a/infer/src/IR/Objc_models.ml b/infer/src/IR/Objc_models.ml index c5a19df54..165233732 100644 --- a/infer/src/IR/Objc_models.ml +++ b/infer/src/IR/Objc_models.ml @@ -7,10 +7,11 @@ open! IStd -(** This module handles C or Objective-C types for which there are special rules for memory management *) +(** This module handles C or Objective-C types for which there are special rules for memory + management *) -(** This module models special c struct types from the Apple's Core Foundation libraries - for which there are particular rules for memory management. *) +(** This module models special c struct types from the Apple's Core Foundation libraries for which + there are particular rules for memory management. *) module Core_foundation_model = struct let core_foundation = diff --git a/infer/src/IR/Objc_models.mli b/infer/src/IR/Objc_models.mli index b8adf0f90..54b486309 100644 --- a/infer/src/IR/Objc_models.mli +++ b/infer/src/IR/Objc_models.mli @@ -7,8 +7,8 @@ open! IStd -(** This module models special c struct types from the Apple's Core Foundation libraries - for which there are particular rules for memory management. *) +(** This module models special c struct types from the Apple's Core Foundation libraries for which + there are particular rules for memory management. *) val is_core_lib_type : Typ.t -> bool diff --git a/infer/src/IR/PredSymb.ml b/infer/src/IR/PredSymb.ml index ee9038cd4..4b8109572 100644 --- a/infer/src/IR/PredSymb.ml +++ b/infer/src/IR/PredSymb.ml @@ -47,8 +47,7 @@ let equal_res_act_kind = [%compare.equal: res_act_kind] type dangling_kind = | DAuninit (** pointer is dangling because it is uninitialized *) | DAaddr_stack_var - (** pointer is dangling because it is the address - of a stack variable which went out of scope *) + (** pointer is dangling because it is the address of a stack variable which went out of scope *) | DAminusone (** pointer is -1 *) [@@deriving compare] @@ -84,11 +83,11 @@ type path_pos_ = path_pos let compare_path_pos_ _ _ = 0 (** Attributes are nary function symbols that are applied to expression arguments in Apred and - Anpred atomic formulas. Many operations don't make much sense for nullary predicates, and are - generally treated as no-ops. The first argument is treated specially, as the "anchor" of the - predicate application. For example, adding or removing an attribute uses the anchor to identify - the atom to operate on. Also, abstraction and normalization operations treat the anchor - specially and maintain more information on it than other arguments. Therefore when attaching an + Anpred atomic formulas. Many operations don't make much sense for nullary predicates, and are + generally treated as no-ops. The first argument is treated specially, as the "anchor" of the + predicate application. For example, adding or removing an attribute uses the anchor to identify + the atom to operate on. Also, abstraction and normalization operations treat the anchor + specially and maintain more information on it than other arguments. Therefore when attaching an attribute to an expression, that expression should be the first argument, optionally followed by additional related expressions. *) type t = diff --git a/infer/src/IR/PredSymb.mli b/infer/src/IR/PredSymb.mli index 278b4a8d0..fef35e375 100644 --- a/infer/src/IR/PredSymb.mli +++ b/infer/src/IR/PredSymb.mli @@ -55,11 +55,11 @@ type res_action = ; ra_vpath: DecompiledExp.vpath (** vpath of the resource value *) } (** Attributes are nary function symbols that are applied to expression arguments in Apred and - Anpred atomic formulas. Many operations don't make much sense for nullary predicates, and are - generally treated as no-ops. The first argument is treated specially, as the "anchor" of the - predicate application. For example, adding or removing an attribute uses the anchor to identify - the atom to operate on. Also, abstraction and normalization operations treat the anchor - specially and maintain more information on it than other arguments. Therefore when attaching an + Anpred atomic formulas. Many operations don't make much sense for nullary predicates, and are + generally treated as no-ops. The first argument is treated specially, as the "anchor" of the + predicate application. For example, adding or removing an attribute uses the anchor to identify + the atom to operate on. Also, abstraction and normalization operations treat the anchor + specially and maintain more information on it than other arguments. Therefore when attaching an attribute to an expression, that expression should be the first argument, optionally followed by additional related expressions. *) type t = @@ -104,7 +104,7 @@ type category = val equal_category : category -> category -> bool val to_category : t -> category -(** Return the category to which the attribute belongs. *) +(** Return the category to which the attribute belongs. *) val is_undef : t -> bool diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index cf3a93b00..3beb8efd5 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -17,7 +17,8 @@ type var_data = { name: Mangled.t ; typ: Typ.t ; modify_in_block: bool - (** __block attribute of Objective-C variables, means that it will be modified inside a block *) + (** __block attribute of Objective-C variables, means that it will be modified inside a + block *) ; is_constexpr: bool } type t = diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 142264cef..63e635d43 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -627,9 +627,9 @@ let create_node pdesc loc kind instrs = create_node_from_not_reversed pdesc loc kind (Instrs.of_list instrs) -(** Set the successor and exception nodes. - If this is a join node right before the exit node, add an extra node in the middle, - otherwise nullify and abstract instructions cannot be added after a conditional. *) +(** Set the successor and exception nodes. If this is a join node right before the exit node, add an + extra node in the middle, otherwise nullify and abstract instructions cannot be added after a + conditional. *) let node_set_succs pdesc (node : Node.t) ~normal:succs ~exn = match (node.kind, succs) with | Join_node, [({Node.kind= Exit_node} as exit_node)] -> @@ -676,10 +676,9 @@ let get_wto pdesc = wto -(** Get loop heads for widening. - It collects all target nodes of back-edges in a depth-first traversal. - We need to use the exceptional CFG otherwise we will miss loop heads in catch clauses. -*) +(** Get loop heads for widening. It collects all target nodes of back-edges in a depth-first + traversal. We need to use the exceptional CFG otherwise we will miss loop heads in catch + clauses. *) let get_loop_heads pdesc = match pdesc.loop_heads with | Some lh -> diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index 29a54faf5..a8c228d89 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -202,8 +202,8 @@ val compute_distance_to_exit_node : t -> unit (** Compute the distance of each node to the exit node, if not computed already *) val create_node : t -> Location.t -> Node.nodekind -> Sil.instr list -> Node.t -(** Create a new cfg node with the given location, kind, list of instructions, - and add it to the procdesc. *) +(** Create a new cfg node with the given location, kind, list of instructions, and add it to the + procdesc. *) val create_node_from_not_reversed : t -> Location.t -> Node.nodekind -> Instrs.not_reversed_t -> Node.t @@ -269,12 +269,12 @@ val iter_instrs : (Node.t -> Sil.instr -> unit) -> t -> unit (** iterate over all nodes and their instructions *) val replace_instrs : t -> f:(Node.t -> Sil.instr -> Sil.instr) -> bool -(** Map and replace the instructions to be executed. - Returns true if at least one substitution occured. *) +(** Map and replace the instructions to be executed. Returns true if at least one substitution + occured. *) val replace_instrs_by : t -> f:(Node.t -> Sil.instr -> Sil.instr array) -> bool -(** Like [replace_instrs], but slower, and each instruction may be replaced -by 0, 1, or more instructions. *) +(** Like [replace_instrs], but slower, and each instruction may be replaced by 0, 1, or more + instructions. *) val iter_nodes : (Node.t -> unit) -> t -> unit (** iterate over all the nodes of a procedure *) @@ -319,6 +319,6 @@ val is_connected : t -> (unit, [`Join | `Other]) Result.t 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 *) + CFG *) val load : Typ.Procname.t -> t option diff --git a/infer/src/IR/ProcnameDispatcher.ml b/infer/src/IR/ProcnameDispatcher.ml index 6a2c2f466..bcdd0e2af 100644 --- a/infer/src/IR/ProcnameDispatcher.ml +++ b/infer/src/IR/ProcnameDispatcher.ml @@ -776,8 +776,8 @@ module Call = struct fun m ~on_args:_ _context _args _f_capt -> RetryWith m - (** Retries matching with another matcher if the function does not have the - exact number/types of args *) + (** Retries matching with another matcher if the function does not have the exact number/types of + args *) let exact_args_or_retry : ('context, 'f, 'arg_payload) matcher -> ('context, _, _, 'arg_payload) func_args_end = fun m -> alternative_args_end no_args_left (args_end_retry m) @@ -869,7 +869,7 @@ module type NameCommon = sig -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher (** After a name, accepts ALL template arguments, accepts ALL path tails (names, templates), - accepts ALL function arguments, binds the function *) + accepts ALL function arguments, binds the function *) end module NameCommon = struct diff --git a/infer/src/IR/ProcnameDispatcher.mli b/infer/src/IR/ProcnameDispatcher.mli index b35d7440e..95b8c5723 100644 --- a/infer/src/IR/ProcnameDispatcher.mli +++ b/infer/src/IR/ProcnameDispatcher.mli @@ -103,8 +103,8 @@ module type Common = sig ('context, 'f_in, 'f_out, 'arg_payload) name_matcher -> ('context -> string -> bool) -> ('context, 'f_in, 'f_out, 'arg_payload) name_matcher - (** Separates names that satisfies the given function (accepts ALL - template arguments on the left one) *) + (** Separates names that satisfies the given function (accepts ALL template arguments on the left + one) *) val ( <>:: ) : ('context, 'f_in, 'f_out, 'arg_payload) name_matcher @@ -137,7 +137,7 @@ module type NameCommon = sig -> ('context, 'f_out, 'arg_payload) matcher (** After a name, accepts ALL template arguments, accepts ALL path tails (names, templates), - accepts ALL function arguments, binds the function *) + accepts ALL function arguments, binds the function *) end module ProcName : @@ -179,7 +179,7 @@ module Call : sig val capt_arg_payload : ('context, 'arg_payload, 'wrapped_arg, 'wrapped_arg -> 'f, 'f, 'arg_payload) one_arg - (** Captures the payload of one arg at current state *) + (** Captures the payload of one arg at current state *) val capt_exp : ('context, Exp.t, 'wrapped_arg, 'wrapped_arg -> 'f, 'f, 'arg_payload) one_arg (** Captures one arg expression *) @@ -279,7 +279,8 @@ module Call : sig ('context, 'f_in, 'f_out, 'arg_payload) name_matcher -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher - (** After a name, accepts ALL template arguments, accepts NO function arguments, binds the function *) + (** After a name, accepts ALL template arguments, accepts NO function arguments, binds the + function *) val ( <>$$--> ) : ('context, 'f_in, 'f_out, 'arg_payload) name_matcher @@ -291,20 +292,22 @@ module Call : sig ('context, 'f_in, 'f_out, 'arg_payload) name_matcher -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher - (** After a name, accepts ALL template arguments, accepts ALL function arguments, binds the function *) + (** After a name, accepts ALL template arguments, accepts ALL function arguments, binds the + function *) val ( <>--> ) : ('context, 'f_in, 'f_out, 'arg_payload) name_matcher -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher - (** After a name, accepts NO template arguments, accepts ALL function arguments, binds the function *) + (** After a name, accepts NO template arguments, accepts ALL function arguments, binds the + function *) val ( &++> ) : ('context, 'f_in, 'arg_payload FuncArg.t list -> 'f_out, 'arg_payload) name_matcher -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher (** After a name, accepts ALL template arguments, captures ALL function arguments as a list, binds - the function *) + the function *) val ( &::.*--> ) : ('context, 'f_in, 'f_out, 'arg_payload) name_matcher @@ -317,7 +320,7 @@ module Call : sig ('context, 'f_in, 'f_proc_out, 'f_out, 'arg_payload) args_matcher -> 'f_in -> ('context, 'f_out, 'arg_payload) matcher - (** Ends function arguments, accepts NO more function arguments. - If the args do not match, raise an internal error. *) + (** Ends function arguments, accepts NO more function arguments. If the args do not match, raise + an internal error. *) end [@@warning "-32"] diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index cdb726a9f..ab1a1412b 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -226,8 +226,8 @@ let get_ret_pvar pname = mk Ident.name_return pname 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 *) +(** [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 = {pv_hash= name_hash name; pv_name= name; pv_kind= Callee_var proc_name} diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index c0c5ecb45..244b4db85 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -14,11 +14,11 @@ module F = Format type translation_unit = SourceFile.t option [@@deriving compare] (** Type for program variables. There are 4 kinds of variables: - 1) local variables, used for local variables and formal parameters - 2) callee program variables, used to handle recursion ([x | callee] is distinguished from [x]) - 3) global variables - 4) seed variables, used to store the initial value of formal parameters -*) + + + local variables, used for local variables and formal parameters + + callee program variables, used to handle recursion ([x | callee] is distinguished from [x]) + + global variables + + seed variables, used to store the initial value of formal parameters *) type t [@@deriving compare] val compare_modulo_this : t -> t -> int @@ -83,7 +83,8 @@ val is_ssa_frontend_tmp : t -> bool once on a non-looping control-flow path *) val is_cpp_temporary : t -> bool -(** return true if this pvar represents a C++ temporary object (see http://en.cppreference.com/w/cpp/language/lifetime) *) +(** return true if this pvar represents a C++ temporary object (see + http://en.cppreference.com/w/cpp/language/lifetime) *) val mk : Mangled.t -> Typ.Procname.t -> t (** [mk name proc_name] creates a program var with the given function name *) @@ -95,8 +96,8 @@ val mk_abduced_ret : Typ.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 -(** [mk_callee name proc_name] creates a program var - for a callee function with the given function name *) +(** [mk_callee name proc_name] creates a program var for a callee function with the given function + name *) val mk_global : ?is_constexpr:bool @@ -151,8 +152,8 @@ val get_initializer_pname : t -> Typ.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 -(** [get_name_of_local_with_procname var] Return a name that is composed of the name of -var and the name of the procname in case of locals *) +(** [get_name_of_local_with_procname var] Return a name that is composed of the name of var and the + name of the procname in case of locals *) val materialized_cpp_temporary : string diff --git a/infer/src/IR/QualifiedCppName.mli b/infer/src/IR/QualifiedCppName.mli index 1c49deac0..f213b1d5f 100644 --- a/infer/src/IR/QualifiedCppName.mli +++ b/infer/src/IR/QualifiedCppName.mli @@ -28,12 +28,13 @@ val extract_last : t -> (string * t) option val strip_template_args : t -> t (** returns qualified name without template arguments. For example: - input: std::shared_ptr::shared_ptr - output: std::shared_ptr::shared_ptr *) + + - input: std::shared_ptr::shared_ptr + - output: std::shared_ptr::shared_ptr *) val append_template_args_to_last : t -> args:string -> t -(** append template arguments to the last qualifier. Fails if qualified name is empty or it already has - template args *) +(** append template arguments to the last qualifier. Fails if qualified name is empty or it already + has template args *) val to_list : t -> string list (** returns list of qualifiers *) @@ -54,30 +55,32 @@ val pp : Format.formatter -> t -> unit (** Module to match qualified C++ procnames "fuzzily", that is up to namescapes and templating. In particular, this deals with the following issues: - 1. 'std::' namespace may have inline namespace afterwards: std::move becomes std::__1::move. This - happens on libc++ and to some extent on libstdc++. To work around this problem, make matching - against 'std::' more fuzzier: std::X::Y::Z will match std::.*::X::Y::Z (but only for the - 'std' namespace). - - 2. The names are allowed not to commit to a template specialization: we want std::move to match - std::__1::move and std::__1::move. To do so, comparison function for qualifiers - will ignore template specializations. - - For example: - ["std", "move"]: - matches: ["std", "blah", "move"] - matches: ["std", "blah", "move"] - does not match: ["std","blah", "move", "BAD"] - we don't want std::.*::X::.* to pass - does not match: ["stdBAD", "move"], - it's not std namespace anymore - - ["folly", "someFunction"] - matches: ["folly","someFunction"] - matches: ["folly","someFunction"] - matches: ["folly","someFunction"] - does not match: ["folly", "BAD", "someFunction"] - unlike 'std' any other namespace needs all - qualifiers to match - does not match: ["folly","someFunction", "BAD"] - same as previous example - *) + + 'std::' namespace may have inline namespace afterwards: std::move becomes std::__1::move. This + happens on libc++ and to some extent on libstdc++. To work around this problem, make matching + against 'std::' more fuzzier: std::X::Y::Z will match std::.*::X::Y::Z (but only for the 'std' + namespace). + + + The names are allowed not to commit to a template specialization: we want std::move to match + std::__1::move and std::__1::move. To do so, comparison function for qualifiers + will ignore template specializations. + + For example: + + ["std", "move"]: + + - matches: ["std", "blah", "move"] + - matches: ["std", "blah", "move"] + - does not match: ["std","blah", "move", "BAD"] - we don't want std::.*::X::.* to pass + - does not match: ["stdBAD", "move"], - it's not std namespace anymore + + ["folly", "someFunction"] + + - matches: ["folly","someFunction"] + - matches: ["folly","someFunction"] + - matches: ["folly","someFunction"] + - does not match: ["folly", "BAD", "someFunction"] - unlike 'std' any other namespace needs all + qualifiers to match + - does not match: ["folly","someFunction", "BAD"] - same as previous example *) module Match : sig type quals_matcher diff --git a/infer/src/IR/Sil.ml b/infer/src/IR/Sil.ml index fce95875d..02825595f 100644 --- a/infer/src/IR/Sil.ml +++ b/infer/src/IR/Sil.ml @@ -43,23 +43,25 @@ type instr = | Load of {id: Ident.t; e: Exp.t; root_typ: Typ.t; typ: Typ.t; loc: Location.t} (** Load a value from the heap into an identifier. - [id = *exp:typ(root_typ)] where - [exp] is an expression denoting a heap address - [typ] is typ of [exp] and [id] - [root_typ] is the root type of [exp] + [id = *exp:typ(root_typ)] where - The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the + - [exp] is an expression denoting a heap address + - [typ] is typ of [exp] and [id] + - [root_typ] is the root type of [exp] + + The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the future, so please use [typ] instead. *) | Store of {e1: Exp.t; root_typ: Typ.t; typ: Typ.t; e2: Exp.t; loc: Location.t} (** Store the value of an expression into the heap. - [*exp1:typ(root_typ) = exp2] where - [exp1] is an expression denoting a heap address - [typ] is typ of [*exp1] and [exp2] - [root_typ] is the root type of [exp1] - [exp2] is the expression whose value is stored. + [*exp1:typ(root_typ) = exp2] where + + - [exp1] is an expression denoting a heap address + - [typ] is typ of [*exp1] and [exp2] + - [root_typ] is the root type of [exp1] + - [exp2] is the expression whose value is stored. - The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the + The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the future, so please use [typ] instead. *) | Prune of Exp.t * Location.t * bool * if_kind (** prune the state based on [exp=1], the boolean indicates whether true branch *) @@ -143,13 +145,11 @@ type 'inst strexp0 = | Eexp of Exp.t * 'inst (** Base case: expression with instrumentation *) | Estruct of (Typ.Fieldname.t * 'inst strexp0) list * 'inst (** C structure *) | Earray of Exp.t * (Exp.t * 'inst strexp0) list * 'inst - (** Array of given length - There are two conditions imposed / used in the array case. - First, if some index and value pair appears inside an array - in a strexp, then the index is less than the length of the array. - For instance, x |->[10 | e1: v1] implies that e1 <= 9. - Second, if two indices appear in an array, they should be different. - For instance, x |->[10 | e1: v1, e2: v2] implies that e1 != e2. *) + (** Array of given length There are two conditions imposed / used in the array case. First, if + some index and value pair appears inside an array in a strexp, then the index is less than + the length of the array. For instance, [x |->\[10 | e1: v1\]] implies that [e1 <= 9]. + Second, if two indices appear in an array, they should be different. For instance, + [x |->\[10 | e1: v1, e2: v2\]] implies that [e1 != e2]. *) [@@deriving compare] type strexp = inst strexp0 @@ -163,30 +163,26 @@ let equal_strexp ?(inst = false) se1 se2 = Int.equal (compare_strexp ~inst se1 s (** an atomic heap predicate *) type 'inst hpred0 = | Hpointsto of Exp.t * 'inst strexp0 * Exp.t - (** represents [exp|->strexp:typexp] where [typexp] - is an expression representing a type, e.h. [sizeof(t)]. *) + (** represents [exp|->strexp:typexp] where [typexp] is an expression representing a type, e.h. + [sizeof(t)]. *) | Hlseg of lseg_kind * 'inst hpara0 * Exp.t * Exp.t * Exp.t list - (** higher - order predicate for singly - linked lists. - Should ensure that exp1!= exp2 implies that exp1 is allocated. - This assumption is used in the rearrangement. The last [exp list] parameter - is used to denote the shared links by all the nodes in the list. *) + (** higher - order predicate for singly - linked lists. Should ensure that exp1!= exp2 implies + that exp1 is allocated. This assumption is used in the rearrangement. The last [exp list] + parameter is used to denote the shared links by all the nodes in the list. *) | Hdllseg of lseg_kind * 'inst hpara_dll0 * Exp.t * Exp.t * Exp.t * Exp.t * Exp.t list - (** higher-order predicate for doubly-linked lists. - Parameter for the higher-order singly-linked list predicate. - Means "lambda (root,next,svars). Exists evars. body". - Assume that root, next, svars, evars are disjoint sets of - primed identifiers, and include all the free primed identifiers in body. - body should not contain any non - primed identifiers or program - variables (i.e. pvars). *) + (** higher-order predicate for doubly-linked lists. Parameter for the higher-order + singly-linked list predicate. Means "lambda (root,next,svars). Exists evars. body". Assume + that root, next, svars, evars are disjoint sets of primed identifiers, and include all the + free primed identifiers in body. body should not contain any non - primed identifiers or + program variables (i.e. pvars). *) [@@deriving compare] and 'inst hpara0 = {root: Ident.t; next: Ident.t; svars: Ident.t list; evars: Ident.t list; body: 'inst hpred0 list} [@@deriving compare] -(** parameter for the higher-order doubly-linked list predicates. - Assume that all the free identifiers in body_dll should belong to - cell, blink, flink, svars_dll, evars_dll. *) +(** parameter for the higher-order doubly-linked list predicates. Assume that all the free + identifiers in body_dll should belong to cell, blink, flink, svars_dll, evars_dll. *) and 'inst hpara_dll0 = { cell: Ident.t (** address cell *) ; blink: Ident.t (** backward link *) @@ -380,7 +376,7 @@ let exps_of_instr = function exps_of_instr_metadata metadata -(** Convert an if_kind to string *) +(** Convert an if_kind to string *) let if_kind_to_string = function | Ik_bexp -> "boolean exp" @@ -481,9 +477,8 @@ let pp_lseg_kind f = function Lseg_NE -> F.pp_print_string f "ne" | Lseg_PE -> ( (** Print a *-separated sequence. *) let pp_star_seq pp f l = Pp.seq ~sep:" * " pp f l -(** Module Predicates records the occurrences of predicates as parameters - of (doubly -)linked lists and Epara. Provides unique numbering - for predicates and an iterator. *) +(** Module Predicates records the occurrences of predicates as parameters of (doubly -)linked lists + and Epara. Provides unique numbering for predicates and an iterator. *) module Predicates : sig (** predicate environment *) @@ -505,8 +500,8 @@ module Predicates : sig val get_hpara_dll_id : env -> hpara_dll -> int - (** [iter env f f_dll] iterates [f] and [f_dll] on all the hpara and hpara_dll, - passing the unique id to the functions. The iterator can only be used once. *) + (** [iter env f f_dll] iterates [f] and [f_dll] on all the hpara and hpara_dll, passing the unique + id to the functions. The iterator can only be used once. *) val iter : env -> (int -> hpara -> unit) -> (int -> hpara_dll -> unit) -> unit @@ -593,11 +588,9 @@ end = struct {num= 0; hash= HparaHash.create 3; todo= []; hash_dll= HparaDllHash.create 3; todo_dll= []} - (** iterator for predicates which are marked as todo in env, - unless they have been visited already. - This can in turn extend the todo list for the nested predicates, - which are then visited as well. - Can be applied only once, as it destroys the todo list *) + (** iterator for predicates which are marked as todo in env, unless they have been visited + already. This can in turn extend the todo list for the nested predicates, which are then + visited as well. Can be applied only once, as it destroys the todo list *) let iter (env : env) f f_dll = while env.todo <> [] || env.todo_dll <> [] do match env.todo with @@ -1113,9 +1106,8 @@ let equal_subst = [%compare.equal: subst] let sub_no_duplicated_ids sub = not (List.contains_dup ~compare:compare_ident_exp_ids sub) -(** Create a substitution from a list of pairs. - For all (id1, e1), (id2, e2) in the input list, - if id1 = id2, then e1 = e2. *) +(** Create a substitution from a list of pairs. For all (id1, e1), (id2, e2) in the input list, if + id1 = id2, then e1 = e2. *) let subst_of_list sub = let sub' = List.dedup_and_sort ~compare:compare_ident_exp sub in assert (sub_no_duplicated_ids sub') ; @@ -1133,18 +1125,16 @@ let sub_empty = subst_of_list [] let is_sub_empty = List.is_empty -(** Join two substitutions into one. - For all id in dom(sub1) cap dom(sub2), sub1(id) = sub2(id). *) +(** Join two substitutions into one. For all id in dom(sub1) cap dom(sub2), sub1(id) = sub2(id). *) let sub_join sub1 sub2 = let sub = IList.merge_dedup ~compare:compare_ident_exp sub1 sub2 in assert (sub_no_duplicated_ids sub) ; sub -(** Compute the common id-exp part of two inputs [subst1] and [subst2]. - The first component of the output is this common part. - The second and third components are the remainder of [subst1] - and [subst2], respectively. *) +(** Compute the common id-exp part of two inputs [subst1] and [subst2]. The first component of the + output is this common part. The second and third components are the remainder of [subst1] and + [subst2], respectively. *) let sub_symmetric_difference sub1_in sub2_in = let rec diff sub_common sub1_only sub2_only sub1 sub2 = match (sub1, sub2) with @@ -1162,24 +1152,23 @@ let sub_symmetric_difference sub1_in sub2_in = diff [] [] [] sub1_in sub2_in -(** [sub_find filter sub] returns the expression associated to the first identifier - that satisfies [filter]. Raise [Not_found] if there isn't one. *) +(** [sub_find filter sub] returns the expression associated to the first identifier that satisfies + [filter]. Raise [Not_found] if there isn't one. *) let sub_find filter (sub : subst) = snd (List.find_exn ~f:(fun (i, _) -> filter i) sub) -(** [sub_filter filter sub] restricts the domain of [sub] to the - identifiers satisfying [filter]. *) +(** [sub_filter filter sub] restricts the domain of [sub] to the identifiers satisfying [filter]. *) let sub_filter filter (sub : subst) = List.filter ~f:(fun (i, _) -> filter i) sub -(** [sub_filter_pair filter sub] restricts the domain of [sub] to the - identifiers satisfying [filter(id, sub(id))]. *) +(** [sub_filter_pair filter sub] restricts the domain of [sub] to the identifiers satisfying + [filter(id, sub(id))]. *) let sub_filter_pair = List.filter -(** [sub_range_partition filter sub] partitions [sub] according to - whether range expressions satisfy [filter]. *) +(** [sub_range_partition filter sub] partitions [sub] according to whether range expressions satisfy + [filter]. *) let sub_range_partition filter (sub : subst) = List.partition_tf ~f:(fun (_, e) -> filter e) sub -(** [sub_domain_partition filter sub] partitions [sub] according to - whether domain identifiers satisfy [filter]. *) +(** [sub_domain_partition filter sub] partitions [sub] according to whether domain identifiers + satisfy [filter]. *) let sub_domain_partition filter (sub : subst) = List.partition_tf ~f:(fun (i, _) -> filter i) sub (** Return the list of identifiers in the domain of the substitution. *) @@ -1191,8 +1180,8 @@ let sub_range sub = List.map ~f:snd sub (** [sub_range_map f sub] applies [f] to the expressions in the range of [sub]. *) let sub_range_map f sub = subst_of_list (List.map ~f:(fun (i, e) -> (i, f e)) sub) -(** [sub_map f g sub] applies the renaming [f] to identifiers in the domain - of [sub] and the substitution [g] to the expressions in the range of [sub]. *) +(** [sub_map f g sub] applies the renaming [f] to identifiers in the domain of [sub] and the + substitution [g] to the expressions in the range of [sub]. *) let sub_map f g sub = subst_of_list (List.map ~f:(fun (i, e) -> (f i, g e)) sub) let mem_sub id sub = List.exists ~f:(fun (id1, _) -> Ident.equal id id1) sub @@ -1329,8 +1318,8 @@ let hpred_sub subst = (** {2 Functions for replacing occurrences of expressions.} *) -(** The first parameter should define a partial function. - No parts of hpara are replaced by these functions. *) +(** The first parameter should define a partial function. No parts of hpara are replaced by these + functions. *) let rec exp_replace_exp epairs e = (* First we check if there is an exact match *) match List.find ~f:(fun (e1, _) -> Exp.equal e e1) epairs with @@ -1505,10 +1494,9 @@ let sigma_to_sigma_ne sigma : (atom list * hpred list) list = else [([], sigma)] -(** [hpara_instantiate para e1 e2 elist] instantiates [para] with [e1], - [e2] and [elist]. If [para = lambda (x, y, xs). exists zs. b], - then the result of the instantiation is [b\[e1 / x, e2 / y, elist / xs, zs'_/ zs\]] - for some fresh [_zs'].*) +(** [hpara_instantiate para e1 e2 elist] instantiates [para] with [e1], [e2] and [elist]. If + [para = lambda (x, y, xs). exists zs. b], then the result of the instantiation is + [b\[e1 / x, e2 / y, elist / xs, zs'_/ zs\]] for some fresh [_zs'].*) let hpara_instantiate para e1 e2 elist = let subst_for_svars = let g id e = (id, e) in @@ -1528,11 +1516,10 @@ let hpara_instantiate para e1 e2 elist = (ids_evars, List.map ~f:(hpred_sub subst) para.body) -(** [hpara_dll_instantiate para cell blink flink elist] instantiates [para] with [cell], - [blink], [flink], and [elist]. If [para = lambda (x, y, z, xs). exists zs. b], - then the result of the instantiation is - [b\[cell / x, blink / y, flink / z, elist / xs, zs'_/ zs\]] - for some fresh [_zs'].*) +(** [hpara_dll_instantiate para cell blink flink elist] instantiates [para] with [cell], [blink], + [flink], and [elist]. If [para = lambda (x, y, z, xs). exists zs. b], then the result of the + instantiation is [b\[cell / x, blink / y, flink / z, elist / xs, zs'_/ zs\]] for some fresh + [_zs'].*) let hpara_dll_instantiate (para : hpara_dll) cell blink flink elist = let subst_for_svars = let g id e = (id, e) in diff --git a/infer/src/IR/Sil.mli b/infer/src/IR/Sil.mli index 3e15063a8..66d770828 100644 --- a/infer/src/IR/Sil.mli +++ b/infer/src/IR/Sil.mli @@ -41,23 +41,25 @@ type instr = | Load of {id: Ident.t; e: Exp.t; root_typ: Typ.t; typ: Typ.t; loc: Location.t} (** Load a value from the heap into an identifier. - [id = *exp:typ(root_typ)] where - [exp] is an expression denoting a heap address - [typ] is typ of [exp] and [id] - [root_typ] is the root type of [exp] + [id = *exp:typ(root_typ)] where - The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the + - [exp] is an expression denoting a heap address + - [typ] is typ of [exp] and [id] + - [root_typ] is the root type of [exp] + + The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the future, so please use [typ] instead. *) | Store of {e1: Exp.t; root_typ: Typ.t; typ: Typ.t; e2: Exp.t; loc: Location.t} (** Store the value of an expression into the heap. - [*exp1:typ(root_typ) = exp2] where - [exp1] is an expression denoting a heap address - [typ] is typ of [*exp1] and [exp2] - [root_typ] is the root type of [exp1] - [exp2] is the expression whose value is stored. + [*exp1:typ(root_typ) = exp2] where + + - [exp1] is an expression denoting a heap address + - [typ] is typ of [*exp1] and [exp2] + - [root_typ] is the root type of [exp1] + - [exp2] is the expression whose value is stored. - The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the + The [root_typ] is deprecated: it is broken in C/C++. We are removing [root_typ] in the future, so please use [typ] instead. *) | Prune of Exp.t * Location.t * bool * if_kind (** prune the state based on [exp=1], the boolean indicates whether true branch *) @@ -166,54 +168,46 @@ type 'inst strexp0 = | Eexp of Exp.t * 'inst (** Base case: expression with instrumentation *) | Estruct of (Typ.Fieldname.t * 'inst strexp0) list * 'inst (** C structure *) | Earray of Exp.t * (Exp.t * 'inst strexp0) list * 'inst - (** Array of given length - There are two conditions imposed / used in the array case. - First, if some index and value pair appears inside an array - in a strexp, then the index is less than the length of the array. - For instance, x |->[10 | e1: v1] implies that e1 <= 9. - Second, if two indices appear in an array, they should be different. - For instance, x |->[10 | e1: v1, e2: v2] implies that e1 != e2. *) + (** Array of given length There are two conditions imposed / used in the array case. First, if + some index and value pair appears inside an array in a strexp, then the index is less than + the length of the array. For instance, [x |->\[10 | e1: v1\]] implies that [e1 <= 9]. + Second, if two indices appear in an array, they should be different. For instance, + [x |->\[10 | e1: v1, e2: v2\]] implies that [e1 != e2]. *) [@@deriving compare] type strexp = inst strexp0 val compare_strexp : ?inst:bool -> strexp -> strexp -> int -(** Comparison function for strexp. - The inst:: parameter specifies whether instumentations should also - be considered (false by default). *) +(** Comparison function for strexp. The inst:: parameter specifies whether instumentations should + also be considered (false by default). *) val equal_strexp : ?inst:bool -> strexp -> strexp -> bool -(** Equality function for strexp. - The inst:: parameter specifies whether instumentations should also - be considered (false by default). *) +(** Equality function for strexp. The inst:: parameter specifies whether instumentations should also + be considered (false by default). *) (** an atomic heap predicate *) type 'inst hpred0 = | Hpointsto of Exp.t * 'inst strexp0 * Exp.t - (** represents [exp|->strexp:typexp] where [typexp] - is an expression representing a type, e.h. [sizeof(t)]. *) + (** represents [exp|->strexp:typexp] where [typexp] is an expression representing a type, e.h. + [sizeof(t)]. *) | Hlseg of lseg_kind * 'inst hpara0 * Exp.t * Exp.t * Exp.t list - (** higher - order predicate for singly - linked lists. - Should ensure that exp1!= exp2 implies that exp1 is allocated. - This assumption is used in the rearrangement. The last [exp list] parameter - is used to denote the shared links by all the nodes in the list. *) + (** higher - order predicate for singly - linked lists. Should ensure that exp1!= exp2 implies + that exp1 is allocated. This assumption is used in the rearrangement. The last [exp list] + parameter is used to denote the shared links by all the nodes in the list. *) | Hdllseg of lseg_kind * 'inst hpara_dll0 * Exp.t * Exp.t * Exp.t * Exp.t * Exp.t list - (** higher-order predicate for doubly-linked lists. - Parameter for the higher-order singly-linked list predicate. - Means "lambda (root,next,svars). Exists evars. body". - Assume that root, next, svars, evars are disjoint sets of - primed identifiers, and include all the free primed identifiers in body. - body should not contain any non - primed identifiers or program - variables (i.e. pvars). *) + (** higher-order predicate for doubly-linked lists. Parameter for the higher-order + singly-linked list predicate. Means "lambda (root,next,svars). Exists evars. body". Assume + that root, next, svars, evars are disjoint sets of primed identifiers, and include all the + free primed identifiers in body. body should not contain any non - primed identifiers or + program variables (i.e. pvars). *) [@@deriving compare] and 'inst hpara0 = {root: Ident.t; next: Ident.t; svars: Ident.t list; evars: Ident.t list; body: 'inst hpred0 list} [@@deriving compare] -(** parameter for the higher-order doubly-linked list predicates. - Assume that all the free identifiers in body_dll should belong to - cell, blink, flink, svars_dll, evars_dll. *) +(** parameter for the higher-order doubly-linked list predicates. Assume that all the free + identifiers in body_dll should belong to cell, blink, flink, svars_dll, evars_dll. *) and 'inst hpara_dll0 = { cell: Ident.t (** address cell *) ; blink: Ident.t (** backward link *) @@ -230,14 +224,12 @@ type hpara = inst hpara0 type hpara_dll = inst hpara_dll0 val compare_hpred : ?inst:bool -> hpred -> hpred -> int -(** Comparison function for hpred. - The inst:: parameter specifies whether instumentations should also - be considered (false by default). *) +(** Comparison function for hpred. The inst:: parameter specifies whether instumentations should + also be considered (false by default). *) val equal_hpred : ?inst:bool -> hpred -> hpred -> bool -(** Equality function for hpred. - The inst:: parameter specifies whether instumentations should also - be considered (false by default). *) +(** Equality function for hpred. The inst:: parameter specifies whether instumentations should also + be considered (false by default). *) module HpredSet : Caml.Set.S with type elt = hpred (** Sets of heap predicates *) @@ -262,9 +254,8 @@ val is_block_pvar : Pvar.t -> bool (** Check if a pvar is a local pointing to a block in objc *) val add_with_block_parameters_flag : instr -> instr -(** Adds a with_blocks_parameters flag to a method call, when the arguments - contain an Objective-C block, and the method is an Objective-C method - (to be extended to other methods) *) +(** Adds a with_blocks_parameters flag to a method call, when the arguments contain an Objective-C + block, and the method is an Objective-C method (to be extended to other methods) *) (** {2 Pretty Printing} *) @@ -338,9 +329,8 @@ val pp_hpara : Pp.env -> F.formatter -> hpara -> unit val pp_hpara_dll : Pp.env -> F.formatter -> hpara_dll -> unit (** Pretty print a hpara_dll. *) -(** Module Predicates records the occurrences of predicates as parameters - of (doubly -)linked lists and Epara. - Provides unique numbering for predicates and an iterator. *) +(** Module Predicates records the occurrences of predicates as parameters of (doubly -)linked lists + and Epara. Provides unique numbering for predicates and an iterator. *) module Predicates : sig (** predicate environment *) type env @@ -352,8 +342,8 @@ module Predicates : sig (** return true if the environment is empty *) val iter : env -> (int -> hpara -> unit) -> (int -> hpara_dll -> unit) -> unit - (** [iter env f f_dll] iterates [f] and [f_dll] on all the hpara and hpara_dll, - passing the unique id to the functions. The iterator can only be used once. *) + (** [iter env f f_dll] iterates [f] and [f_dll] on all the hpara and hpara_dll, passing the unique + id to the functions. The iterator can only be used once. *) val process_hpred : env -> hpred -> unit (** Process one hpred, updating the predicate environment *) @@ -365,23 +355,19 @@ val pp_hpred_env : Pp.env -> Predicates.env option -> F.formatter -> hpred -> un (** {2 Functions for traversing SIL data types} *) val strexp_expmap : (Exp.t * inst option -> Exp.t * inst option) -> strexp -> strexp -(** Change exps in strexp using [f]. - WARNING: the result might not be normalized. *) +(** Change exps in strexp using [f]. WARNING: the result might not be normalized. *) val hpred_expmap : (Exp.t * inst option -> Exp.t * inst option) -> hpred -> hpred -(** Change exps in hpred by [f]. - WARNING: the result might not be normalized. *) +(** Change exps in hpred by [f]. WARNING: the result might not be normalized. *) val hpred_instmap : (inst -> inst) -> hpred -> hpred (** Change instrumentations in hpred using [f]. *) val hpred_list_expmap : (Exp.t * inst option -> Exp.t * inst option) -> hpred list -> hpred list -(** Change exps in hpred list by [f]. - WARNING: the result might not be normalized. *) +(** Change exps in hpred list by [f]. WARNING: the result might not be normalized. *) val atom_expmap : (Exp.t -> Exp.t) -> atom -> atom -(** Change exps in atom by [f]. - WARNING: the result might not be normalized. *) +(** Change exps in atom by [f]. WARNING: the result might not be normalized. *) val hpred_list_get_lexps : (Exp.t -> bool) -> hpred list -> Exp.t list @@ -408,9 +394,8 @@ val equal_subst : subst -> subst -> bool (** Equality for substitutions. *) val subst_of_list : (Ident.t * Exp.t) list -> subst -(** Create a substitution from a list of pairs. - For all (id1, e1), (id2, e2) in the input list, - if id1 = id2, then e1 = e2. *) +(** Create a substitution from a list of pairs. For all (id1, e1), (id2, e2) in the input list, if + id1 = id2, then e1 = e2. *) val subst_of_list_duplicates : (Ident.t * Exp.t) list -> subst (** like subst_of_list, but allow duplicate ids and only keep the first occurrence *) @@ -424,37 +409,33 @@ val sub_empty : subst val is_sub_empty : subst -> bool val sub_join : subst -> subst -> subst -(** Compute the common id-exp part of two inputs [subst1] and [subst2]. - The first component of the output is this common part. - The second and third components are the remainder of [subst1] - and [subst2], respectively. *) +(** Compute the common id-exp part of two inputs [subst1] and [subst2]. The first component of the + output is this common part. The second and third components are the remainder of [subst1] and + [subst2], respectively. *) val sub_symmetric_difference : subst -> subst -> subst * subst * subst -(** Compute the common id-exp part of two inputs [subst1] and [subst2]. - The first component of the output is this common part. - The second and third components are the remainder of [subst1] - and [subst2], respectively. *) +(** Compute the common id-exp part of two inputs [subst1] and [subst2]. The first component of the + output is this common part. The second and third components are the remainder of [subst1] and + [subst2], respectively. *) val sub_find : (Ident.t -> bool) -> subst -> Exp.t -(** [sub_find filter sub] returns the expression associated to the first identifier - that satisfies [filter]. - Raise [Not_found] if there isn't one. *) +(** [sub_find filter sub] returns the expression associated to the first identifier that satisfies + [filter]. Raise [Not_found] if there isn't one. *) val sub_filter : (Ident.t -> bool) -> subst -> subst -(** [sub_filter filter sub] restricts the domain of [sub] to the - identifiers satisfying [filter]. *) +(** [sub_filter filter sub] restricts the domain of [sub] to the identifiers satisfying [filter]. *) val sub_filter_pair : subst -> f:(Ident.t * Exp.t -> bool) -> subst -(** [sub_filter_exp filter sub] restricts the domain of [sub] to the - identifiers satisfying [filter(id, sub(id))]. *) +(** [sub_filter_exp filter sub] restricts the domain of [sub] to the identifiers satisfying + [filter(id, sub(id))]. *) val sub_range_partition : (Exp.t -> bool) -> subst -> subst * subst -(** [sub_range_partition filter sub] partitions [sub] according to - whether range expressions satisfy [filter]. *) +(** [sub_range_partition filter sub] partitions [sub] according to whether range expressions satisfy + [filter]. *) val sub_domain_partition : (Ident.t -> bool) -> subst -> subst * subst -(** [sub_domain_partition filter sub] partitions [sub] according to - whether domain identifiers satisfy [filter]. *) +(** [sub_domain_partition filter sub] partitions [sub] according to whether domain identifiers + satisfy [filter]. *) val sub_domain : subst -> Ident.t list (** Return the list of identifiers in the domain of the substitution. *) @@ -466,8 +447,8 @@ val sub_range_map : (Exp.t -> Exp.t) -> subst -> subst (** [sub_range_map f sub] applies [f] to the expressions in the range of [sub]. *) val sub_map : (Ident.t -> Ident.t) -> (Exp.t -> Exp.t) -> subst -> subst -(** [sub_map f g sub] applies the renaming [f] to identifiers in the domain - of [sub] and the substitution [g] to the expressions in the range of [sub]. *) +(** [sub_map f g sub] applies the renaming [f] to identifiers in the domain of [sub] and the + substitution [g] to the expressions in the range of [sub]. *) val extend_sub : subst -> Ident.t -> Exp.t -> subst option (** Extend substitution and return [None] if not possible. *) @@ -476,8 +457,7 @@ val subst_free_vars : subst -> Ident.t Sequence.t val subst_gen_free_vars : subst -> (unit, Ident.t) Sequence.Generator.t -(** substitution functions - WARNING: these functions do not ensure that the results are normalized. *) +(** substitution functions WARNING: these functions do not ensure that the results are normalized. *) val exp_sub : subst -> Exp.t -> Exp.t @@ -507,17 +487,15 @@ val exp_add_offsets : Exp.t -> offset list -> Exp.t val sigma_to_sigma_ne : hpred list -> (atom list * hpred list) list val hpara_instantiate : hpara -> Exp.t -> Exp.t -> Exp.t list -> Ident.t list * hpred list -(** [hpara_instantiate para e1 e2 elist] instantiates [para] with [e1], - [e2] and [elist]. If [para = lambda (x, y, xs). exists zs. b], - then the result of the instantiation is [b\[e1 / x, e2 / y, elist / xs, _zs'/ zs\]] - for some fresh [_zs'].*) +(** [hpara_instantiate para e1 e2 elist] instantiates [para] with [e1], [e2] and [elist]. If + [para = lambda (x, y, xs). exists zs. b], then the result of the instantiation is + [b\[e1 / x, e2 / y, elist / xs, _zs'/ zs\]] for some fresh [_zs'].*) val hpara_dll_instantiate : hpara_dll -> Exp.t -> Exp.t -> Exp.t -> Exp.t list -> Ident.t list * hpred list -(** [hpara_dll_instantiate para cell blink flink elist] instantiates [para] with [cell], - [blink], [flink], and [elist]. If [para = lambda (x, y, z, xs). exists zs. b], - then the result of the instantiation is - [b\[cell / x, blink / y, flink / z, elist / xs, _zs'/ zs\]] - for some fresh [_zs'].*) +(** [hpara_dll_instantiate para cell blink flink elist] instantiates [para] with [cell], [blink], + [flink], and [elist]. If [para = lambda (x, y, z, xs). exists zs. b], then the result of the + instantiation is [b\[cell / x, blink / y, flink / z, elist / xs, _zs'/ zs\]] for some fresh + [_zs'].*) val custom_error : Pvar.t diff --git a/infer/src/IR/SpecializeProcdesc.ml b/infer/src/IR/SpecializeProcdesc.ml index b3f0cf430..3ab9b0e7c 100644 --- a/infer/src/IR/SpecializeProcdesc.ml +++ b/infer/src/IR/SpecializeProcdesc.ml @@ -43,8 +43,7 @@ let convert_cfg ~callee_pdesc ~resolved_pdesc ~f_instr_list = resolved_pdesc -(** clone a procedure description and apply the type substitutions where - the parameters are used *) +(** clone a procedure description and apply the type substitutions where the parameters are used *) let with_formals_types_proc callee_pdesc resolved_pdesc substitutions = let resolved_pname = Procdesc.get_proc_name resolved_pdesc in let convert_pvar pvar = Pvar.mk (Pvar.get_name pvar) resolved_pname in @@ -132,10 +131,10 @@ let with_formals_types_proc callee_pdesc resolved_pdesc substitutions = exception UnmatchedParameters -(** 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 proc desc 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 *) +(** 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 proc desc is isomorphic but all the type of the + parameters are replaced in the instructions according to the list. The virtual calls are also + replaced to match the parameter types *) let with_formals_types ?(has_clang_model = false) callee_pdesc resolved_pname args = let callee_attributes = Procdesc.get_attributes callee_pdesc in let resolved_params, substitutions = diff --git a/infer/src/IR/SpecializeProcdesc.mli b/infer/src/IR/SpecializeProcdesc.mli index 1d7a35744..316717104 100644 --- a/infer/src/IR/SpecializeProcdesc.mli +++ b/infer/src/IR/SpecializeProcdesc.mli @@ -11,14 +11,15 @@ exception UnmatchedParameters val with_formals_types : ?has_clang_model:bool -> Procdesc.t -> Typ.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 *) +(** 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 -(** 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 - a) the block parameters are replaces with the closures - b) the parameters of the method are extended with parameters for the captured variables - in the closures *) +(** 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 + + - the block parameters are replaces with the closures + - the parameters of the method are extended with parameters for the captured variables in the + closures *) diff --git a/infer/src/IR/Subtype.ml b/infer/src/IR/Subtype.ml index 7ec606e40..0a39bd724 100644 --- a/infer/src/IR/Subtype.ml +++ b/infer/src/IR/Subtype.ml @@ -21,7 +21,7 @@ type t' = Exact (** denotes the current type only *) | Subtypes of Typ.Name.t l let equal_modulo_flag (st1, _) (st2, _) = [%compare.equal: t'] st1 st2 -(** denotes the current type and a list of types that are not their subtypes *) +(** denotes the current type and a list of types that are not their subtypes *) type kind = CAST | INSTOF | NORMAL [@@deriving compare] let equal_kind = [%compare.equal: kind] @@ -264,13 +264,11 @@ let case_analysis_basic tenv (c1, st) (c2, (_, flag2)) = (change_flag pos_st c1 c2 flag2, change_flag neg_st c1 c2 flag2) -(** [case_analysis (c1, st1) (c2, st2) f] performs case analysis on [c1 <: c2] - according to [st1] and [st2] - where f c1 c2 is true if c1 is a subtype of c2. - get_subtypes returning a pair: +(** [case_analysis (c1, st1) (c2, st2) f] performs case analysis on [c1 <: c2] according to [st1] + and [st2] where f c1 c2 is true if c1 is a subtype of c2. get_subtypes returning a pair: + - whether [st1] and [st2] admit [c1 <: c2], and in case return the updated subtype [st1] - - whether [st1] and [st2] admit [not(c1 <: c2)], - and in case return the updated subtype [st1] *) + - whether [st1] and [st2] admit [not(c1 <: c2)], and in case return the updated subtype [st1] *) let case_analysis tenv (c1, st1) (c2, st2) = if Config.subtype_multirange then get_subtypes tenv (c1, st1) (c2, st2) else case_analysis_basic tenv (c1, st1) (c2, st2) diff --git a/infer/src/IR/Subtype.mli b/infer/src/IR/Subtype.mli index 623a1ea1b..fc312813d 100644 --- a/infer/src/IR/Subtype.mli +++ b/infer/src/IR/Subtype.mli @@ -28,17 +28,16 @@ val subtypes_instof : t val join : t -> t -> t val case_analysis : Tenv.t -> Typ.Name.t * t -> Typ.Name.t * t -> t option * t option -(** [case_analysis tenv (c1, st1) (c2, st2)] performs case analysis on [c1 <: c2] according - to [st1] and [st2]. - [case_analysis] returns a pair: +(** [case_analysis tenv (c1, st1) (c2, st2)] performs case analysis on [c1 <: c2] according to [st1] + and [st2]. [case_analysis] returns a pair: + - whether [st1] and [st2] admit [c1 <: c2], and in case returns the updated subtype [st1] - whether [st1] and [st2] admit [not(c1 <: c2)], and in case returns the updated subtype [st1] *) val is_known_subtype : Tenv.t -> Typ.Name.t -> Typ.Name.t -> bool (** [is_known_subtype tenv c1 c2] returns true if there is enough information in [tenv] to prove - that [c1] is a subtype of [c2]. - Note that [not (is_known_subtype tenv c1 c2) == true] does not imply - that [is_known_not_subtype tenv c1 c2 == true] *) + that [c1] is a subtype of [c2]. Note that [not (is_known_subtype tenv c1 c2) == true] does not + imply that [is_known_not_subtype tenv c1 c2 == true] *) val is_cast : t -> bool diff --git a/infer/src/IR/Tenv.mli b/infer/src/IR/Tenv.mli index ecf7c9b16..e97ebdf01 100644 --- a/infer/src/IR/Tenv.mli +++ b/infer/src/IR/Tenv.mli @@ -63,6 +63,6 @@ val merge : src:t -> dst:t -> unit val merge_per_file : src:per_file -> dst:per_file -> per_file (** Best-effort merge of [src] into [dst]. If a procedure is both in [dst] and [src], the one in - [dst] will get overwritten. *) + [dst] will get overwritten. *) module SQLite : SqliteUtils.Data with type t = per_file diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 6a7797e4d..35774835d 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + (** The Smallfoot Intermediate Language: Types *) open! IStd diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index a747a3f63..bb2236a51 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + (** The Smallfoot Intermediate Language: Types *) open! IStd diff --git a/infer/src/IR/WeakTopologicalOrder.ml b/infer/src/IR/WeakTopologicalOrder.ml index 72290bb87..6b08a616d 100644 --- a/infer/src/IR/WeakTopologicalOrder.ml +++ b/infer/src/IR/WeakTopologicalOrder.ml @@ -112,11 +112,9 @@ module Bourdoncle_SCC (CFG : PreProcCfg) = struct module CFG = CFG module Dfn = CFG.Node.IdMap - (** - [dfn] contains a DFS pre-order indexing. A node is not in the map if it has never been visited. - A node's dfn is +oo if it has been fully visited (head of cross-edges) or we want to hide it - for building a subcomponent partition (head of highest back-edges). - *) + (** [dfn] contains a DFS pre-order indexing. A node is not in the map if it has never been + visited. A node's dfn is +oo if it has been fully visited (head of cross-edges) or we want to + hide it for building a subcomponent partition (head of highest back-edges). *) (* Unlike Bourdoncle's paper version or OCamlGraph implementation, this implementation handles diff --git a/infer/src/IR/WeakTopologicalOrder.mli b/infer/src/IR/WeakTopologicalOrder.mli index 33020eda5..a5a8c81d7 100644 --- a/infer/src/IR/WeakTopologicalOrder.mli +++ b/infer/src/IR/WeakTopologicalOrder.mli @@ -12,13 +12,10 @@ module F = Format by François Bourdoncle. *) -(** - A hierarchical ordering of a set is a well-parenthesized permutation of its elements without two - consecutive "(". I defines a total order <= over its elements. - The elements between two matching parentheses are called a Component. - The first element of a Component is called the head. - Let denote by H(v) the set of head of the nested components containing v. -*) +(** A hierarchical ordering of a set is a well-parenthesized permutation of its elements without two + consecutive "(". I defines a total order <= over its elements. The elements between two matching + parentheses are called a Component. The first element of a Component is called the head. Let + denote by H(v) the set of head of the nested components containing v. *) module Partition : sig type 'node t = private @@ -31,10 +28,8 @@ module Partition : sig val fold_heads : ('node t, 'node, _) Container.fold val expand : fold_right:('a, 'b, 'b t) Container.fold -> 'a t -> 'b t - (** Maps a partition nodes from ['a] to ['b] using the expansion [fold_right]. - [fold_right] should not return its [~init] directly but must always provide - a non-empty sequence. - *) + (** Maps a partition nodes from ['a] to ['b] using the expansion [fold_right]. [fold_right] should + not return its [~init] directly but must always provide a non-empty sequence. *) val pp : pp_node:(F.formatter -> 'node -> unit) -> F.formatter -> 'node t -> unit end @@ -57,18 +52,19 @@ module type PreProcCfg = sig val start_node : t -> Node.t end -(** - A weak topological ordering (WTO) of a directed graph is a hierarchical ordering of its vertices - such that for every edge u -> v, - u < v and v is not in H(u) (forward edge) - or - v <= u and v is in H(u) (feedback edge) +(** A weak topological ordering (WTO) of a directed graph is a hierarchical ordering of its vertices + such that for every edge u -> v, - where H(u) is the set of heads of the nested components containing u. + u < v and v is not in H(u) (forward edge) - A WTO of a directed graph is such that the head v of every feedback edge u -> v is the head of a - component containing its tail u. -*) + or + + v <= u and v is in H(u) (feedback edge) + + where H(u) is the set of heads of the nested components containing u. + + A WTO of a directed graph is such that the head v of every feedback edge u -> v is the head of a + component containing its tail u. *) module type S = sig module CFG : PreProcCfg @@ -79,7 +75,5 @@ end module type Make = functor (CFG : PreProcCfg) -> S with module CFG = CFG module Bourdoncle_SCC : Make -(** - Implementation of Bourdoncle's "Hierarchical decomposition of a directed graph into strongly - connected components and subcomponents". See [Bou] Figure 4, page 10. -*) +(** Implementation of Bourdoncle's "Hierarchical decomposition of a directed graph into strongly + connected components and subcomponents". See [Bou] Figure 4, page 10. *) diff --git a/infer/src/absint/AbstractDomain.mli b/infer/src/absint/AbstractDomain.mli index 2effa2b0c..223d9123b 100644 --- a/infer/src/absint/AbstractDomain.mli +++ b/infer/src/absint/AbstractDomain.mli @@ -97,7 +97,8 @@ end include sig [@@@warning "-60"] - (** Stacked abstract domain: tagged union of [Below] and [Above] domains where all elements of [Below] are strictly smaller than elements of [Above] *) + (** Stacked abstract domain: tagged union of [Below] and [Above] domains where all elements of + [Below] are strictly smaller than elements of [Above] *) module Stacked (Below : S) (Above : S) : S with type t = (Below.t, Above.t) below_above end @@ -135,8 +136,8 @@ module StackedUtils : sig ('b, 'a) below_above -> f_below:('b -> 'b2) -> f_above:('a -> 'a2) -> ('b2, 'a2) below_above end -(** Abstracts a set of [Element]s by keeping its smallest representative only. - The widening is terminating only if the order fulfills the descending chain condition. *) +(** Abstracts a set of [Element]s by keeping its smallest representative only. The widening is + terminating only if the order fulfills the descending chain condition. *) module MinReprSet (Element : PrettyPrintable.PrintableOrderedType) : sig type elt = Element.t @@ -166,8 +167,8 @@ end include sig [@@@warning "-60"] - (** Lift a PPSet to a powerset domain ordered by subset. The elements of the set should be drawn from - a *finite* collection of possible values, since the widening operator here is just union. *) + (** Lift a PPSet to a powerset domain ordered by subset. The elements of the set should be drawn + from a *finite* collection of possible values, since the widening operator here is just union. *) module FiniteSetOfPPSet (PPSet : PrettyPrintable.PPSet) : FiniteSetS with type elt = PPSet.elt end @@ -196,8 +197,8 @@ include sig [@@@warning "-60"] (** Map domain ordered by union over the set of bindings, so the bottom element is the empty map. - Every element implicitly maps to bottom unless it is explicitly bound to something else. - Uses PPMap as the underlying map *) + Every element implicitly maps to bottom unless it is explicitly bound to something else. Uses + PPMap as the underlying map *) module MapOfPPMap (PPMap : PrettyPrintable.PPMap) (ValueDomain : S) : MapS with type key = PPMap.key and type value = ValueDomain.t and type t = ValueDomain.t PPMap.t end @@ -218,9 +219,9 @@ end module InvertedMap (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : S) : InvertedMapS with type key = Key.t and type value = ValueDomain.t -(** Similar to [InvertedMap] but it guarantees that it has a canonical form. For example, both [{a - -> top_v}] and [empty] represent the same abstract value [top] in [InvertedMap], but in this - implementation, [top] is always implemented as [empty] by not adding the [top_v] explicitly. *) +(** Similar to [InvertedMap] but it guarantees that it has a canonical form. For example, both + [{a -> top_v}] and [empty] represent the same abstract value [top] in [InvertedMap], but in this + implementation, [top] is always implemented as [empty] by not adding the [top_v] explicitly. *) module SafeInvertedMap (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : WithTop) : InvertedMapS with type key = Key.t and type value = ValueDomain.t @@ -273,8 +274,8 @@ module CountDomain (MaxCount : MaxCount) : sig (** capped sum of two states *) end -(** Domain keeping a non-negative count with a bounded maximum value. - [join] is minimum and [top] is zero. *) +(** Domain keeping a non-negative count with a bounded maximum value. [join] is minimum and [top] is + zero. *) module DownwardIntDomain (MaxCount : MaxCount) : sig include WithTop with type t = private int (** top is zero *) diff --git a/infer/src/absint/AbstractInterpreter.mli b/infer/src/absint/AbstractInterpreter.mli index 050c12357..59be50d28 100644 --- a/infer/src/absint/AbstractInterpreter.mli +++ b/infer/src/absint/AbstractInterpreter.mli @@ -62,7 +62,9 @@ module type Make = functor (TransferFunctions : TransferFunctions.SIL) -> S with module TransferFunctions = TransferFunctions module MakeRPO : Make -(** create an intraprocedural abstract interpreter from transfer functions using the reverse post-order scheduler *) +(** create an intraprocedural abstract interpreter from transfer functions using the reverse + post-order scheduler *) module MakeWTO : Make -(** create an intraprocedural abstract interpreter from transfer functions using Bourdoncle's strongly connected component weak topological order *) +(** create an intraprocedural abstract interpreter from transfer functions using Bourdoncle's + strongly connected component weak topological order *) diff --git a/infer/src/absint/LowerHil.mli b/infer/src/absint/LowerHil.mli index ef7d584b1..9c6a4093d 100644 --- a/infer/src/absint/LowerHil.mli +++ b/infer/src/absint/LowerHil.mli @@ -46,23 +46,26 @@ end (** Wrapper around Interpreter to prevent clients from having to deal with IdAccessPathMapDomain. - CAVEAT: the translation does not attempt to preserve the semantics in the case where side-effects - happen between an assignment to a logical variable and the assignement of that logical variable - to a program variable. For instance the following SIL program + CAVEAT: the translation does not attempt to preserve the semantics in the case where + side-effects happen between an assignment to a logical variable and the assignement of that + logical variable to a program variable. For instance the following SIL program + {v n$0 = *&x.f _ = delete(&x) *&y = n$0 + v} becomes + {v _ = delete(&x) *&y = *&x.f + v} The latter is a use-after-delete of &x whereas the original SIL program is well behaved. - Only use HIL if that is not something your checker needs to care about. - *) + Only use HIL if that is not something your checker needs to care about. *) module MakeAbstractInterpreterWithConfig (MakeAbstractInterpreter : AbstractInterpreter.Make) (HilConfig : HilConfig) diff --git a/infer/src/absint/NodePrinter.mli b/infer/src/absint/NodePrinter.mli index 4e29d8711..cd7bcb2ab 100644 --- a/infer/src/absint/NodePrinter.mli +++ b/infer/src/absint/NodePrinter.mli @@ -15,7 +15,5 @@ val with_session : -> Procdesc.Node.t -> f:(unit -> 'a) -> 'a -(** - Wraps [f] in an html debug session. - Will swallow timeouts so do *not* use from within biabduction. -*) +(** Wraps [f] in an html debug session. Will swallow timeouts so do *not* use from within + biabduction. *) diff --git a/infer/src/absint/PatternMatch.ml b/infer/src/absint/PatternMatch.ml index a778775cb..04d1352cd 100644 --- a/infer/src/absint/PatternMatch.ml +++ b/infer/src/absint/PatternMatch.ml @@ -418,8 +418,8 @@ let get_fields_nullified procdesc = (** Checks if the class name is a Java exception *) let is_throwable tenv typename = is_subtype_of_str tenv typename "java.lang.Throwable" -(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, - including for supertypes*) +(** 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 -> let check_class_annots _ {Typ.Struct.annots} = check annots in @@ -428,8 +428,8 @@ let check_class_attributes check tenv = function false -(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, - for the current class only*) +(** 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 @@ -441,7 +441,7 @@ let check_current_class_attributes check tenv = function false -(** find superclasss with attributes (e.g., @ThreadSafe), including current class*) +(** find superclasss with attributes (e.g., [@ThreadSafe]), including current class*) let rec find_superclasses_with_attributes check tenv tname = match Tenv.lookup tenv tname with | Some struct_typ -> diff --git a/infer/src/absint/PatternMatch.mli b/infer/src/absint/PatternMatch.mli index 495c656c0..c10d1be45 100644 --- a/infer/src/absint/PatternMatch.mli +++ b/infer/src/absint/PatternMatch.mli @@ -10,7 +10,8 @@ open! IStd (** Module for Pattern matching. *) val get_this_type_nonstatic_methods_only : ProcAttributes.t -> Typ.t option -(** Get the `this` type of a procedure. Should not be called on non-static methods, otherwise it can return a wrong type *) +(** Get the `this` type of a procedure. Should not be called on non-static methods, otherwise it can + return a wrong type *) val get_type_name : Typ.t -> string (** Get the name of a type *) @@ -46,8 +47,7 @@ val implements_collections : Tenv.t -> string -> bool (** Check whether class implements a Java's Collections *) val implements_pseudo_collection : Tenv.t -> string -> bool -(** Check whether class implements a pseudo Collection with support - for get() and size() methods *) +(** Check whether class implements a pseudo Collection with support for get() and size() methods *) val implements_enumeration : Tenv.t -> string -> bool (** Check whether class implements a Java's Enumeration *) @@ -89,13 +89,13 @@ val implements_list : Tenv.t -> string -> bool (** Check whether class implements a Java's list *) val implements_google : string -> Tenv.t -> string -> bool -(** Check whether class implements a class of Google *) +(** Check whether class implements a class of Google *) val implements_android : string -> Tenv.t -> string -> bool -(** Check whether class implements a class of Android *) +(** Check whether class implements a class of Android *) val implements_xmob_utils : string -> Tenv.t -> string -> bool -(** Check whether class implements a class of xmod.utils *) +(** Check whether class implements a class of xmod.utils *) val supertype_exists : Tenv.t -> (Typ.Name.t -> Typ.Struct.t -> bool) -> Typ.Name.t -> bool (** Holds iff the predicate holds on a supertype of the named type, including the type itself *) @@ -116,7 +116,8 @@ val proc_calls : val override_exists : ?check_current_type:bool -> (Typ.Procname.t -> bool) -> Tenv.t -> Typ.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. *) +(** 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 (** Apply the given predicate to procname and each override of [procname]. For the moment, this only @@ -139,15 +140,15 @@ val is_throwable : Tenv.t -> Typ.Name.t -> bool (** [is_throwable tenv class_name] checks if class_name is of type java.lang.Throwable *) val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Typ.Procname.t -> bool -(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, - including supertypes*) +(** 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 -(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument, - for current class only*) +(** tests whether any class attributes (e.g., [@ThreadSafe]) pass check of first argument, for + current class only*) 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*) +(** find superclasss with attributes (e.g., [@ThreadSafe]), including current class*) val is_override_of : Typ.Procname.t -> (Typ.Procname.t -> bool) Staged.t diff --git a/infer/src/absint/Scheduler.ml b/infer/src/absint/Scheduler.ml index 0d82b402d..c4cf0ebaf 100644 --- a/infer/src/absint/Scheduler.ml +++ b/infer/src/absint/Scheduler.ml @@ -16,8 +16,8 @@ module type S = sig (** schedule the successors of [node] *) val pop : t -> (CFG.Node.t * CFG.Node.id list * t) option - (** remove and return the node with the highest priority, the ids of its visited - predecessors, and the new schedule *) + (** remove and return the node with the highest priority, the ids of its visited predecessors, and + the new schedule *) val empty : CFG.t -> t end @@ -90,7 +90,7 @@ module ReversePostorder (CFG : ProcCfg.S) = struct quick popping, and do a linear search only when this list is empty *) (** remove and return the node with the highest priority (note that smaller integers have higher - priority), the ids of its visited predecessors, and new schedule *) + priority), the ids of its visited predecessors, and new schedule *) let pop t = try let init_id, init_work = M.min_binding t.worklist in diff --git a/infer/src/absint/SummaryPayload.mli b/infer/src/absint/SummaryPayload.mli index c4f269372..b6a5696e9 100644 --- a/infer/src/absint/SummaryPayload.mli +++ b/infer/src/absint/SummaryPayload.mli @@ -24,7 +24,7 @@ module type S = sig val read_full : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> (Procdesc.t * t) option (** Return the proc desc and payload for the given procedure. Runs the analysis on-demand if - necessary. *) + necessary. *) val read : caller_summary:Summary.t -> callee_pname:Typ.Procname.t -> t option (** Return the payload for the given procedure. Runs the analysis on-demand if necessary. *) diff --git a/infer/src/absint/TransferFunctions.mli b/infer/src/absint/TransferFunctions.mli index da71fc140..8e779ede5 100644 --- a/infer/src/absint/TransferFunctions.mli +++ b/infer/src/absint/TransferFunctions.mli @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (** Transfer functions that push abstract states across instructions. A typical client should diff --git a/infer/src/al/ALIssues.ml b/infer/src/al/ALIssues.ml index d683f5baf..2c36bd319 100644 --- a/infer/src/al/ALIssues.ml +++ b/infer/src/al/ALIssues.ml @@ -202,7 +202,8 @@ let string_to_issue_mode m = type parsed_issue_type = { name: string option - (** issue name, if no name is given name will be a readable version of id, by removing underscores and capitalizing first letters of words *) + (** issue name, if no name is given name will be a readable version of id, by removing + underscores and capitalizing first letters of words *) ; doc_url: string option } (** Convert a parsed checker in list of linters *) diff --git a/infer/src/al/ALIssues.mli b/infer/src/al/ALIssues.mli index 65b73d737..bb4ed4f47 100644 --- a/infer/src/al/ALIssues.mli +++ b/infer/src/al/ALIssues.mli @@ -19,13 +19,12 @@ val filter_parsed_linters : linter list -> SourceFile.t -> linter list val pp_linters : Format.formatter -> linter list -> unit -(** map used to expand macro. It maps a formula id to a triple - (visited, parameters, definition). - Visited is used during the expansion phase to understand if the - formula was already expanded and, if yes we have a cyclic definifion *) +(** map used to expand macro. It maps a formula id to a triple (visited, parameters, definition). + Visited is used during the expansion phase to understand if the formula was already expanded + and, if yes we have a cyclic definifion *) type macros_map = (bool * ALVar.t list * CTLTypes.t) ALVar.FormulaIdMap.t -(** Map a path name to a list of paths. *) +(** Map a path name to a list of paths. *) type paths_map = ALVar.t list ALVar.VarMap.t (* Module for warnings detected at translation time by the frontend *) diff --git a/infer/src/al/CLintersContext.ml b/infer/src/al/CLintersContext.ml index 13f42db52..9ec94160c 100644 --- a/infer/src/al/CLintersContext.ml +++ b/infer/src/al/CLintersContext.ml @@ -18,8 +18,8 @@ type context = ; parent_methods: Clang_ast_t.decl list ; in_synchronized_block: bool ; is_ck_translation_unit: bool - (** True if the translation unit contains an ObjC class impl that's a subclass - of CKComponent or CKComponentController. *) + (** True if the translation unit contains an ObjC class impl that's a subclass of + CKComponent or CKComponentController. *) ; current_objc_class: Clang_ast_t.decl option (** If inside an objc class, contains the objc class (impl or interface) decl. *) ; current_objc_category: Clang_ast_t.decl option diff --git a/infer/src/al/CLintersContext.mli b/infer/src/al/CLintersContext.mli index bcf3a2df0..55d5cb535 100644 --- a/infer/src/al/CLintersContext.mli +++ b/infer/src/al/CLintersContext.mli @@ -18,8 +18,8 @@ type context = ; parent_methods: Clang_ast_t.decl list ; in_synchronized_block: bool ; is_ck_translation_unit: bool - (** True if the translation unit contains an ObjC class impl that's a subclass - of CKComponent or CKComponentController. *) + (** True if the translation unit contains an ObjC class impl that's a subclass of + CKComponent or CKComponentController. *) ; current_objc_class: Clang_ast_t.decl option (** If inside an objc class, contains the objc class (impl or interface) decl. *) ; current_objc_category: Clang_ast_t.decl option diff --git a/infer/src/al/CTL.mli b/infer/src/al/CTL.mli index 443528a44..4c8b070a4 100644 --- a/infer/src/al/CTL.mli +++ b/infer/src/al/CTL.mli @@ -7,31 +7,27 @@ open! IStd -(** - This module defines a language to define checkers. These checkers are interpreted over the AST of - the program. A checker is defined by a CTL formula which expresses a condition saying when the - checker should report a problem. -*) +(** This module defines a language to define checkers. These checkers are interpreted over the AST + of the program. A checker is defined by a CTL formula which expresses a condition saying when + the checker should report a problem. *) -(** "set" clauses are used for defining mandatory variables that will be used - by when reporting issues: eg for defining the condition. +(** "set" clauses are used for defining mandatory variables that will be used by when reporting + issues: eg for defining the condition. - "desc" clauses are used for defining the error message, - the suggestion, the severity. + "desc" clauses are used for defining the error message, the suggestion, the severity. - "let" clauses are used to define temporary formulas which are then - used to abbreviate the another formula. For example + "let" clauses are used to define temporary formulas which are then used to abbreviate the + another formula. For example - let f = a And B + {v + let f = a And B - set formula = f OR f - - set message = "bla" - -*) + set formula = f OR f + set message = "bla" + v} *) type clause = - | CLet of ALVar.formula_id * ALVar.t list * CTLTypes.t (** Let clause: let id = definifion; *) + | CLet of ALVar.formula_id * ALVar.t list * CTLTypes.t (** Let clause: let id = definifion; *) | CSet of ALVar.keyword * CTLTypes.t (** Set clause: set id = definition *) | CDesc of ALVar.keyword * string (** Description clause eg: set message = "..." *) | CPath of [`WhitelistPath | `BlacklistPath] * ALVar.t list diff --git a/infer/src/al/CTLExceptions.mli b/infer/src/al/CTLExceptions.mli index 8d21a1d47..cccd15fce 100644 --- a/infer/src/al/CTLExceptions.mli +++ b/infer/src/al/CTLExceptions.mli @@ -8,7 +8,7 @@ open! IStd exception ALParserInvariantViolationException of string -(** Raised when the parser encounters a violation of a certain invariant *) +(** Raised when the parser encounters a violation of a certain invariant *) type exc_info diff --git a/infer/src/al/CTLTypes.mli b/infer/src/al/CTLTypes.mli index 382bcb132..2f511c901 100644 --- a/infer/src/al/CTLTypes.mli +++ b/infer/src/al/CTLTypes.mli @@ -47,16 +47,20 @@ type t = (** EF phi <=> there exits a a path from the current node with a descendant where phi hold *) | AG of transitions option * t (** AG phi <=> for all discendant of the current node phi hold *) | EG of transitions option * t - (** EG phi <=> there exists a path (of descendants) from the current node where phi hold at each node of the path *) + (** EG phi <=> there exists a path (of descendants) from the current node where phi hold at + each node of the path *) | AU of transitions option * t * t - (** AU(phi1, phi2) <=> for all paths from the current node phi1 holds in every node until ph2 holds *) + (** AU(phi1, phi2) <=> for all paths from the current node phi1 holds in every node until ph2 + holds *) | EU of transitions option * t * t - (** EU(phi1, phi2) <=> there exists a path from the current node such that phi1 holds until phi2 holds *) + (** EU(phi1, phi2) <=> there exists a path from the current node such that phi1 holds until + phi2 holds *) | EH of ALVar.alexp list * t - (** EH[classes]phi <=> there exists a node defining a super class in the hierarchy of the class defined by the current node (if any) where phi holds *) + (** EH[classes]phi <=> there exists a node defining a super class in the hierarchy of the + class defined by the current node (if any) where phi holds *) | ET of ALVar.alexp list * transitions option * t - (** ET [T] [l] phi <=> there exists a descentant an of the current node such that an is of type in set T - making a transition to a node an' via label l, such that in an phi holds. *) + (** ET [T] [l] phi <=> there exists a descentant an of the current node such that an is of + type in set T making a transition to a node an' via label l, such that in an phi holds. *) | InObjCClass of t * t [@@deriving compare] diff --git a/infer/src/al/ComponentKit.ml b/infer/src/al/ComponentKit.ml index 04f3ed790..3b6202c4b 100644 --- a/infer/src/al/ComponentKit.ml +++ b/infer/src/al/ComponentKit.ml @@ -36,15 +36,15 @@ let is_ck_context (context : CLintersContext.context) an = && CGeneral_utils.is_objc_extension context.translation_unit_context -(** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl. - (Returns false on decls other than that one.) *) +(** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl. (Returns false on + decls other than that one.) *) let is_component_or_controller_if decl = let open CFrontend_config in CAst_utils.is_objc_if_descendant decl [ckcomponent_cl; ckcomponentcontroller_cl] -(** True if it's an objc class impl that extends from CKComponent or - CKComponentController, false otherwise *) +(** True if it's an objc class impl that extends from CKComponent or CKComponentController, false + otherwise *) let rec is_component_or_controller_descendant_impl decl = match decl with | Clang_ast_t.ObjCImplementationDecl _ -> @@ -55,9 +55,8 @@ let rec is_component_or_controller_descendant_impl decl = false -(** Returns true if the passed-in list of decls contains an - ObjCImplementationDecl of a descendant of CKComponent or - CKComponentController. +(** Returns true if the passed-in list of decls contains an ObjCImplementationDecl of a descendant + of CKComponent or CKComponentController. Does not recurse into hierarchy. *) and contains_ck_impl decl_list = List.exists ~f:is_component_or_controller_descendant_impl decl_list @@ -65,27 +64,27 @@ and contains_ck_impl decl_list = List.exists ~f:is_component_or_controller_desce (** An easy way to fix the component kit best practice http://componentkit.org/docs/avoid-local-variables.html - Local variables that are const or const pointers by definition cannot be - assigned to after declaration, which means the entire class of bugs stemming - from value mutation after assignment are gone. + Local variables that are const or const pointers by definition cannot be assigned to after + declaration, which means the entire class of bugs stemming from value mutation after assignment + are gone. Note we want const pointers, not mutable pointers to const instances. OK: - ``` + {v const int a; int *const b; NSString *const c; const int *const d; - ``` + v} Not OK: - ``` + {v const int *z; const NSString *y; - ``` *) + v} *) let mutable_local_vars_advice context an = try let rec get_referenced_type (qual_type : Clang_ast_t.qual_type) : Clang_ast_t.decl option = @@ -202,9 +201,9 @@ let component_factory_function_advice context an = (* Should only be called with FunctionDecl *) -(** Components should not inherit from each other. They should instead - inherit from CKComponent, CKCompositeComponent, or - CKStatefulViewComponent. (Similar rule applies to component controllers.) *) +(** Components should not inherit from each other. They should instead inherit from CKComponent, + CKCompositeComponent, or CKStatefulViewComponent. (Similar rule applies to component + controllers.) *) let component_with_unconventional_superclass_advice context an = let check_interface if_decl = match if_decl with @@ -265,17 +264,15 @@ let component_with_unconventional_superclass_advice context an = (** Components should only have one factory method. - (They could technically have none if they re-use the parent class's factory - method.) + (They could technically have none if they re-use the parent class's factory method.) - We care about ones that are declared in the interface. In other words, if - additional factory methods are implementation-only, the rule doesn't catch - it. While its existence is probably not good, I can't think of any reason - there would be factory methods that aren't exposed outside of a class is - not useful if there's only one public factory method. + We care about ones that are declared in the interface. In other words, if additional factory + methods are implementation-only, the rule doesn't catch it. While its existence is probably not + good, I can't think of any reason there would be factory methods that aren't exposed outside of + a class is not useful if there's only one public factory method. - Given n factory methods, the rule should emit n-1 issues. Each issue's - location should point to the method declaration. *) + Given n factory methods, the rule should emit n-1 issues. Each issue's location should point to + the method declaration. *) let component_with_multiple_factory_methods_advice context an = let is_unavailable_attr attr = match attr with `UnavailableAttr _ -> true | _ -> false in let is_available_factory_method if_decl (decl : Clang_ast_t.decl) = @@ -347,11 +344,10 @@ let is_in_factory_method (context : CLintersContext.context) = http://componentkit.org/docs/no-side-effects.html - The only current way we look for side-effects is by looking for - asynchronous execution (dispatch_async, dispatch_after) and execution that - relies on other threads (dispatch_sync). Other side-effects, like reading - of global variables, is not checked by this analyzer, although still an - infraction of the rule. *) + The only current way we look for side-effects is by looking for asynchronous execution + (dispatch_async, dispatch_after) and execution that relies on other threads (dispatch_sync). + Other side-effects, like reading of global variables, is not checked by this analyzer, although + still an infraction of the rule. *) let rec component_initializer_with_side_effects_advice_ (context : CLintersContext.context) call_stmt = let condition = @@ -398,8 +394,8 @@ let component_initializer_with_side_effects_advice (context : CLintersContext.co (** Returns one issue per line of code, with the column set to 0. - This still needs to be in infer b/c only files that have a valid component - kit class impl should be analyzed. *) + This still needs to be in infer b/c only files that have a valid component kit class impl should + be analyzed. *) let component_file_line_count_info (context : CLintersContext.context) dec = let condition = Config.compute_analytics && context.is_ck_translation_unit in match dec with diff --git a/infer/src/al/ComponentKit.mli b/infer/src/al/ComponentKit.mli index 4d15db1df..e014500ff 100644 --- a/infer/src/al/ComponentKit.mli +++ b/infer/src/al/ComponentKit.mli @@ -8,9 +8,8 @@ open! IStd val contains_ck_impl : Clang_ast_t.decl list -> bool -(** Returns true if the passed-in list of decls contains an - ObjCImplementationDecl of a descendant of CKComponent or - CKComponentController. +(** Returns true if the passed-in list of decls contains an ObjCImplementationDecl of a descendant + of CKComponent or CKComponentController. Does not recurse into hierarchy. *) diff --git a/infer/src/al/cPredicates.mli b/infer/src/al/cPredicates.mli index 214e117e3..2fba722bf 100644 --- a/infer/src/al/cPredicates.mli +++ b/infer/src/al/cPredicates.mli @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd type t = ALVar.formula_id * ALVar.alexp list [@@deriving compare] diff --git a/infer/src/al/ctl_parser_types.ml b/infer/src/al/ctl_parser_types.ml index 100899cb8..d913a9828 100644 --- a/infer/src/al/ctl_parser_types.ml +++ b/infer/src/al/ctl_parser_types.ml @@ -263,11 +263,8 @@ let get_direct_successor_nodes an = let infer_prefix = "__infer_ctl_" -(** Data structures for type parser. - Correspondence with clang types inferred from - StringRef BuiltinType::getName in - https://clang.llvm.org/doxygen/Type_8cpp_source.html -*) +(** Data structures for type parser. Correspondence with clang types inferred from StringRef + BuiltinType::getName in https://clang.llvm.org/doxygen/Type_8cpp_source.html *) type builtin_kind = | Void (** void *) | Bool (** bool *) diff --git a/infer/src/al/ctl_parser_types.mli b/infer/src/al/ctl_parser_types.mli index edc7ac4bd..c85363017 100644 --- a/infer/src/al/ctl_parser_types.mli +++ b/infer/src/al/ctl_parser_types.mli @@ -37,11 +37,8 @@ val get_direct_successor_nodes : ast_node -> ast_node list val infer_prefix : string -(** Data structures for type parser. - Correspondence with clang types inferred from - StringRef BuiltinType::getName in - https://clang.llvm.org/doxygen/Type_8cpp_source.html -*) +(** Data structures for type parser. Correspondence with clang types inferred from StringRef + BuiltinType::getName in https://clang.llvm.org/doxygen/Type_8cpp_source.html *) type builtin_kind = | Void (** void *) | Bool (** bool *) diff --git a/infer/src/atd/InferCommand.mli b/infer/src/atd/InferCommand.mli index b2f00224c..cc1bb976b 100644 --- a/infer/src/atd/InferCommand.mli +++ b/infer/src/atd/InferCommand.mli @@ -9,11 +9,10 @@ type t = | Analyze (** analyze previously captured source files *) | Capture - (** capture compilation commands and translate source files into infer's intermediate - language *) + (** capture compilation commands and translate source files into infer's intermediate language *) | Compile (** set up the infer environment then run the compilation commands without capturing the - source files *) + source files *) | Events (** dump logged events into stdout *) | Explore (** explore infer reports *) | Report (** post-process infer results and reports *) diff --git a/infer/src/backend/CallGraph.ml b/infer/src/backend/CallGraph.ml index c0ac1276b..9f8afd95e 100644 --- a/infer/src/backend/CallGraph.ml +++ b/infer/src/backend/CallGraph.ml @@ -46,9 +46,9 @@ end module IdMap = Typ.Procname.Hash module NodeMap = Caml.Hashtbl.Make (Int) -(** [node_map] is a map from ids (unique ints) to nodes corresponding to defined procedures. - [id_map] is a map from all encountered (not necessarily defined) procnames to their ids, - and thus its image is a superset of the domain of [node_map], and usually a strict superset. +(** [node_map] is a map from ids (unique ints) to nodes corresponding to defined procedures. + [id_map] is a map from all encountered (not necessarily defined) procnames to their ids, and + thus its image is a superset of the domain of [node_map], and usually a strict superset. [trim_id_map] makes the image equal to the domain of [node_map]. *) type t = {id_map: int IdMap.t; node_map: Node.t NodeMap.t} diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index a7efa9e09..e5702f6f6 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -321,11 +321,11 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; zero_issue; infini else None -(** Differential of cost reports, based on degree variations. - Compare degree_before (DB), and degree_after (DA): - DB > DA => fixed - DB < DA => introduced - *) +(** Differential of cost reports, based on degree variations. Compare degree_before (DB), and + degree_after (DA): + + - DB > DA => fixed + - DB < DA => introduced *) let of_costs ~(current_costs : Jsonbug_t.costs_report) ~(previous_costs : Jsonbug_t.costs_report) = let fold_aux kind issue_spec ~key:_ ~data (left, both, right) = match data with diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 998484989..6df74ac5c 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -1064,8 +1064,8 @@ let process_summary filters formats_by_report_kind linereader stats summary issu issues_acc' -(** Although the out_file is an Option type, the None option is strictly meant for the - logs format_kind, and all other formats should contain an outfile value. *) +(** Although the out_file is an Option type, the None option is strictly meant for the logs + format_kind, and all other formats should contain an outfile value. *) let mk_format format_kind fname = Option.value_map ~f:(fun out_file -> [(format_kind, Some out_file)]) diff --git a/infer/src/backend/OndemandCapture.ml b/infer/src/backend/OndemandCapture.ml index f4c989f30..0df762149 100644 --- a/infer/src/backend/OndemandCapture.ml +++ b/infer/src/backend/OndemandCapture.ml @@ -10,8 +10,8 @@ module L = Logging let compilation_db = lazy (CompilationDatabase.from_json_files !Config.clang_compilation_dbs) (** Given proc_attributes try to produce proc_attributes' where proc_attributes'.is_defined = true - It may trigger capture of extra files to do so and when it does, it waits for - frontend to finish before returning *) + It may trigger capture of extra files to do so and when it does, it waits for frontend to finish + before returning *) let try_capture (attributes : ProcAttributes.t) : ProcAttributes.t option = let (lazy cdb) = compilation_db in ( if Option.is_none (Attributes.load_defined attributes.proc_name) then diff --git a/infer/src/backend/Summary.ml b/infer/src/backend/Summary.ml index 6ae8b608c..b515af5d0 100644 --- a/infer/src/backend/Summary.ml +++ b/infer/src/backend/Summary.ml @@ -222,19 +222,15 @@ module OnDisk = struct load_summary_to_spec_table proc_name - (** Check if the procedure is from a library: - It's not defined, and there is no spec file for it. *) + (** Check if the procedure is from a library: It's not defined, and there is no spec file for it. *) let proc_is_library proc_attributes = if not proc_attributes.ProcAttributes.is_defined then match get proc_attributes.ProcAttributes.proc_name with None -> true | Some _ -> false else false - (** 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. -*) + (** 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. *) let proc_resolve_attributes proc_name = match get proc_name with | Some summary -> diff --git a/infer/src/backend/Summary.mli b/infer/src/backend/Summary.mli index bba84bc11..4402f689b 100644 --- a/infer/src/backend/Summary.mli +++ b/infer/src/backend/Summary.mli @@ -9,7 +9,7 @@ open! IStd (** Procedure summaries: the results of the capture and all the analysis for a single procedure, - plus some statistics *) + plus some statistics *) module Stats : sig (** Execution statistics *) @@ -86,8 +86,8 @@ module OnDisk : sig (** Remove all the elements from the cache of summaries *) val remove_from_cache : Typ.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. *) + (** 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 (** Return the summary option for the procedure name *) @@ -102,15 +102,11 @@ module OnDisk : sig (** Load procedure summary from the given file *) val proc_resolve_attributes : Typ.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. - *) + (** 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. *) val proc_is_library : ProcAttributes.t -> bool - (** Check if the procedure is from a library: - It's not defined, and there is no spec file for it. *) + (** Check if the procedure is from a library: It's not defined, and there is no spec file for it. *) val store : t -> unit (** Save summary for the procedure into the spec database *) diff --git a/infer/src/backend/SyntacticCallGraph.mli b/infer/src/backend/SyntacticCallGraph.mli index 83fe5d829..5c2ffcb73 100644 --- a/infer/src/backend/SyntacticCallGraph.mli +++ b/infer/src/backend/SyntacticCallGraph.mli @@ -7,8 +7,8 @@ open! IStd val bottom_up : SourceFile.t list -> SchedulerTypes.target ProcessPool.TaskGenerator.t -(** task generator that works by - - loading the syntactic call graph from the capture DB +(** task generator that works by + + - loading the syntactic call graph from the capture DB - restricting it to the reachable procs from the modified files - - scheduling leaves only and removing them from the graph when analysed. -*) + - scheduling leaves only and removing them from the graph when analysed. *) diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index e26d2550a..8abec2e34 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -13,6 +13,7 @@ type proc_callback_args = {get_procs_in_file: Typ.Procname.t -> Typ.Procname.t list; summary: Summary.t; exe_env: Exe_env.t} (** Type of a procedure callback: + - List of all the procedures the callback will be called on. - get_proc_desc to get a proc desc from a proc name - Type environment. diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index f34ab5df0..f0d9d8722 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (** Create descriptions of analysis errors *) diff --git a/infer/src/backend/errdesc.mli b/infer/src/backend/errdesc.mli index ce3aa2004..312b0412e 100644 --- a/infer/src/backend/errdesc.mli +++ b/infer/src/backend/errdesc.mli @@ -11,16 +11,16 @@ open! IStd (** Create descriptions of analysis errors *) val vpath_find : Tenv.t -> 'a Prop.t -> Exp.t -> DecompiledExp.vpath * Typ.t option -(** find the dexp, if any, where the given value is stored - also return the type of the value if found *) +(** find the dexp, if any, where the given value is stored also return the type of the value if + found *) val hpred_is_open_resource : Tenv.t -> 'a Prop.t -> Sil.hpred -> PredSymb.resource option (** Check whether the hpred is a |-> representing a resource in the Racquire state *) val find_normal_variable_funcall : Procdesc.Node.t -> Ident.t -> (Exp.t * Exp.t list * Location.t * CallFlags.t) option -(** Find the function call instruction used to initialize normal variable [id], - and return the function name and arguments *) +(** Find the function call instruction used to initialize normal variable [id], and return the + function name and arguments *) val find_program_variable_assignment : Procdesc.Node.t -> Pvar.t -> (Procdesc.Node.t * Ident.t) option @@ -30,8 +30,8 @@ val find_ident_assignment : Procdesc.Node.t -> Ident.t -> (Procdesc.Node.t * Exp (** Find a program variable assignment to id in the current node or predecessors. *) val find_boolean_assignment : Procdesc.Node.t -> Pvar.t -> bool -> Procdesc.Node.t option -(** Find a boolean assignment to a temporary variable holding a boolean condition. - The boolean parameter indicates whether the true or false branch is required. *) +(** Find a boolean assignment to a temporary variable holding a boolean condition. The boolean + parameter indicates whether the true or false branch is required. *) val exp_rv_dexp : Tenv.t -> Procdesc.Node.t -> Exp.t -> DecompiledExp.t option (** describe rvalue [e] as a dexp *) @@ -84,8 +84,8 @@ val explain_dereference_as_caller_expression : -> Location.t -> Pvar.t list -> Localise.error_desc -(** return a description explaining value [exp] in [prop] in terms of a source expression - using the formal parameters of the call *) +(** return a description explaining value [exp] in [prop] in terms of a source expression using the + formal parameters of the call *) val explain_divide_by_zero : Tenv.t -> Exp.t -> Procdesc.Node.t -> Location.t -> Localise.error_desc (** explain a division by zero *) @@ -112,10 +112,9 @@ val explain_leak : -> PredSymb.t option -> string option -> Exceptions.visibility * Localise.error_desc -(** Produce a description of a leak by looking at the current state. - If the current instruction is a variable nullify, blame the variable. - If it is an abstraction, blame any variable nullify at the current node. - If there is an alloc attribute, print the function call and line number. *) +(** Produce a description of a leak by looking at the current state. If the current instruction is a + variable nullify, blame the variable. If it is an abstraction, blame any variable nullify at the + current node. If there is an alloc attribute, print the function call and line number. *) val explain_null_test_after_dereference : Tenv.t -> Exp.t -> Procdesc.Node.t -> int -> Location.t -> Localise.error_desc diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index 71324456a..e03f97f50 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -10,7 +10,7 @@ open! IStd module F = Format (** Execution environments: basically a cache of where procedures are and what is their CFG and type - environment *) + environment *) module L = Logging diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index 58dfc3c3d..cec1685ba 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -9,7 +9,7 @@ open! IStd (** Execution environments: basically a cache of where procedures are and what is their type - environment *) + environment *) type file_data diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index cde2292f1..a14aa067b 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -325,8 +325,8 @@ let create_filters () = (** This function loads and list the path that are being filtered by the analyzer. The results are - of the form: path/to/file.java -> true/false meaning that analysis results will be reported on - path/to/file.java or not *) + of the form: path/to/file.java -> true/false meaning that analysis results will be reported on + path/to/file.java or not *) let test () = let filters = create_filters () in let matches path = filters.path_filter path in diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index 24e09bbdc..e47e33c77 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -14,11 +14,11 @@ val get_proc_desc : Typ.Procname.t -> Procdesc.t option 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 *) + triggered during the analysis of caller_summary *) val analyze_proc_name : caller_summary:Summary.t -> Typ.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 *) + triggered during the analysis of caller_summary *) val analyze_proc_name_no_caller : Typ.Procname.t -> Summary.t option (** [analyze_proc_name_no_caller callee_pname] performs an on-demand analysis of callee_pname diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 4b4309ec7..2fd24d938 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -9,8 +9,7 @@ open! IStd module L = Logging -(** add Abstract instructions into the IR to give hints about when abstraction should be - performed *) +(** add Abstract instructions into the IR to give hints about when abstraction should be performed *) module AddAbstractionInstructions = struct let process pdesc = let open Procdesc in @@ -45,16 +44,16 @@ module Liveness = struct module VarDomain = Liveness.Domain (** computes the non-nullified reaching definitions at the end of each node by building on the - results of a liveness analysis to be precise, what we want to compute is: + results of a liveness analysis to be precise, what we want to compute is: - to_nullify := (live_before U non_nullifed_reaching_defs) - live_after + to_nullify := (live_before U non_nullifed_reaching_defs) - live_after - non_nullified_reaching_defs := non_nullified_reaching_defs - to_nullify + non_nullified_reaching_defs := non_nullified_reaching_defs - to_nullify - Note that this can't be done with by combining the results of reaching definitions and liveness - after the fact, nor can it be done with liveness alone. We will insert nullify instructions for - each pvar in to_nullify afer we finish the analysis. Nullify instructions speed up the analysis - by enabling it to GC state that will no longer be read. *) + Note that this can't be done with by combining the results of reaching definitions and + liveness after the fact, nor can it be done with liveness alone. We will insert nullify + instructions for each pvar in to_nullify afer we finish the analysis. Nullify instructions + speed up the analysis by enabling it to GC state that will no longer be read. *) module NullifyTransferFunctions = struct module Domain = AbstractDomain.Pair (VarDomain) (VarDomain) (** (reaching non-nullified vars) * (vars to nullify) *) diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 84d425f9e..a9263c218 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -14,8 +14,8 @@ module Hashtbl = Caml.Hashtbl module L = Logging module F = Format -(** Module to read specific lines from files. - The data from any file will stay in memory until the handle is collected by the gc. *) +(** Module to read specific lines from files. The data from any file will stay in memory until the + handle is collected by the gc. *) module LineReader = struct (** Map a file name to an array of string, one for each line in the file. *) type t = (SourceFile.t, string array) Hashtbl.t @@ -100,8 +100,7 @@ let pp_node_link_seq = Pp.seq pp_one fmt nodes -(** Print information into html files for nodes - when starting and finishing the processing of a node *) +(** Print information into html files for nodes when starting and finishing the processing of a node *) module NodesHtml : sig val start_session : pp_name:(Format.formatter -> unit) -> Procdesc.Node.t -> int -> unit diff --git a/infer/src/backend/printer.mli b/infer/src/backend/printer.mli index d03b960d9..cc004d8f4 100644 --- a/infer/src/backend/printer.mli +++ b/infer/src/backend/printer.mli @@ -10,8 +10,8 @@ open! IStd (** Printers for the analysis results *) -(** Module to read specific lines from files. - The data from any file will stay in memory until the handle is collected by the gc *) +(** Module to read specific lines from files. The data from any file will stay in memory until the + handle is collected by the gc *) module LineReader : sig type t diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index cf2d3b4ce..a51f7bd61 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -20,8 +20,7 @@ val log_issue_deprecated_using_state : -> exn -> unit (** Report an issue in the given procedure using biabduction state (DO NOT USE ELSEWHERE). - DEPRECATED as it can create race conditions between checkers. - Use log_error/warning instead *) + DEPRECATED as it can create race conditions between checkers. Use log_error/warning instead *) val log_frontend_issue : Typ.Procname.t diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 5bf30fa45..36b019032 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -912,7 +912,7 @@ let decode_env_to_argv env = String.split ~on:env_var_sep env |> List.filter ~f:(Fn.non String.is_empty) -(** [prefix_before_rest (prefix @ ["--" :: rest])] is [prefix] where "--" is not in [prefix]. *) +(** [prefix_before_rest (prefix @ \["--" :: rest\])] is [prefix] where "--" is not in [prefix]. *) let rev_prefix_before_rest args = let rec rev_prefix_before_rest_ rev_keep = function | [] | "--" :: _ -> diff --git a/infer/src/base/CommandLineOption.mli b/infer/src/base/CommandLineOption.mli index d6a2b9685..aa0af1dc7 100644 --- a/infer/src/base/CommandLineOption.mli +++ b/infer/src/base/CommandLineOption.mli @@ -26,6 +26,7 @@ val init_work_dir : string declared options. The arguments of the declaration functions are largely treated uniformly: + - [long] declares the option [--long] - [short] declares the option [-short] as an alias - [deprecated] declares the option [-key] as an alias, for each [key] in [deprecated] @@ -38,8 +39,7 @@ val init_work_dir : string - [in_help] indicates the man pages in which the command should be documented, as generated by calling infer with --help. Otherwise it appears only in --help-full. - [meta] is a meta-variable naming the parsed value for documentation purposes - - a documentation string -*) + - a documentation string *) type 'a t = ?deprecated:string list -> long:string @@ -54,11 +54,11 @@ val mk_set : 'a ref -> 'a -> unit t (** [mk_set variable value] defines a command line option which sets [variable] to [value]. *) val mk_bool : ?deprecated_no:string list -> ?default:bool -> ?f:(bool -> bool) -> bool ref t -(** [mk_bool long short doc] defines a [bool ref] set by the command line flag [--long] (and - [-s]), and cleared by the flag [--no-long] (and [-S]). If [long] already has a "no-" prefix, - or [s] is capital, then the existing prefixes will instead be removed. The default - value is [false] unless overridden by [~default:true]. The [doc] string will be prefixed with - either "Activates:" or "Deactivates:", so should be phrased accordingly. *) +(** [mk_bool long short doc] defines a [bool ref] set by the command line flag [--long] (and [-s]), + and cleared by the flag [--no-long] (and [-S]). If [long] already has a "no-" prefix, or [s] is + capital, then the existing prefixes will instead be removed. The default value is [false] unless + overridden by [~default:true]. The [doc] string will be prefixed with either "Activates:" or + "Deactivates:", so should be phrased accordingly. *) val mk_bool_group : ?deprecated_no:string list @@ -87,19 +87,19 @@ val mk_string_opt : -> ?mk_reset:bool -> string option ref t (** An option "--[long]-reset" is automatically created that resets the reference to None when found - on the command line, unless [mk_reset] is false. *) + on the command line, unless [mk_reset] is false. *) val mk_string_list : ?default:string list -> ?default_to_string:(string list -> string) -> ?f:(string -> string) -> string list ref t -(** [mk_string_list] defines a [string list ref], initialized to [[]] unless overridden by - [~default]. Each argument of an occurrence of the option will be prepended to the list, so the +(** [mk_string_list] defines a [string list ref], initialized to [\[\]] unless overridden by + [~default]. Each argument of an occurrence of the option will be prepended to the list, so the final value will be in the reverse order they appeared on the command line. An option "--[long]-reset" is automatically created that resets the list to [] when found on the - command line. *) + command line. *) val mk_string_map : ?default:string String.Map.t @@ -125,7 +125,8 @@ val mk_symbol : an element of [symbols]. *) val mk_symbol_opt : symbols:(string * 'a) list -> ?f:('a -> 'a) -> ?mk_reset:bool -> 'a option ref t -(** [mk_symbol_opt] is similar to [mk_symbol] but defaults to [None]. If [mk_reset] is false then do not create an additional --[long]-reset option to reset the value of the option to [None]. *) +(** [mk_symbol_opt] is similar to [mk_symbol] but defaults to [None]. If [mk_reset] is false then do + not create an additional --[long]-reset option to reset the value of the option to [None]. *) val mk_symbol_seq : ?default:'a list -> symbols:(string * 'a) list -> eq:('a -> 'a -> bool) -> 'a list ref t @@ -148,9 +149,9 @@ val mk_rest_actions : -> string list ref (** [mk_rest_actions doc ~usage command_to_parse_mode] defines a [string list ref] of the command line arguments following ["--"], in the reverse order they appeared on the command line. [usage] - is the usage message in case of parse errors or if --help is passed. For example, calling + is the usage message in case of parse errors or if --help is passed. For example, calling [mk_action] and parsing [exe -opt1 -opt2 -- arg1 arg2] will result in the returned ref - containing [arg2; arg1]. Additionally, the first arg following ["--"] is passed to + containing [arg2; arg1]. Additionally, the first arg following ["--"] is passed to [command_to_parse_mode] to obtain the parse action that will be used to parse the remaining arguments. *) @@ -185,11 +186,10 @@ val mk_command_doc : - [date] is the date of the last modification of the manual - [short_description] is a one-line description of the command - [options] can be either [`Replace blocks], which populates the OPTIONS section with [blocks], - or [`Prepend blocks], in which case the options from the command are used, prepended by - [blocks]. If unspecified it defaults to [`Prepend []]. + or [`Prepend blocks], in which case the options from the command are used, prepended by + [blocks]. If unspecified it defaults to [`Prepend \[\]]. - All the other [section_name] options correspond to the contents of the section [section_name]. - Some are mandatory and some are not. -*) + Some are mandatory and some are not. *) val mk_subcommand : InferCommand.t @@ -203,9 +203,8 @@ val mk_subcommand : (** [mk_subcommand command ~long command_doc] defines the subcommand [command]. A subcommand is activated by passing [name], and by passing [--deprecated_long] if specified. A man page is automatically generated for [command] based on the information in [command_doc], if available - (otherwise the command is considered internal). [on_unknown_arg] is the action taken on unknown - anonymous arguments; it is `Reject by default. -*) + (otherwise the command is considered internal). [on_unknown_arg] is the action taken on unknown + anonymous arguments; it is `Reject by default. *) val args_env_var : string (** environment variable use to pass arguments from parent to child processes *) @@ -228,6 +227,7 @@ val parse : -> InferCommand.t option * (int -> 'a) (** [parse ~usage parse_mode command] parses command line arguments as specified by preceding calls to the [mk_*] functions, and returns: + - the command selected by the user on the command line, except if [command] is not None in which case it is considered "pre-selected" for the user; - a function that prints the usage message and help text then exits with the code passed as @@ -255,8 +255,8 @@ val show_manual : -> InferCommand.t option -> unit (** Display the manual of [command] to the user, or [command_doc] if [command] is None. [format] is - used as for [Cmdliner.Manpage.print]. If [internal_section] is specified, add a section titled - [internal_section] about internal (hidden) options. If [scrub_defaults] then do not print default - values for options. *) + used as for [Cmdliner.Manpage.print]. If [internal_section] is specified, add a section titled + [internal_section] about internal (hidden) options. If [scrub_defaults] then do not print + default values for options. *) val keep_args_file : bool ref diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 58d440e28..8020e9288 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -9,8 +9,8 @@ open! IStd open PolyVariantEqual -(** Configuration values: either constant, determined at compile time, or set at startup - time by system calls, environment variables, or command line options *) +(** Configuration values: either constant, determined at compile time, or set at startup time by + system calls, environment variables, or command line options *) module F = Format module CLOpt = CommandLineOption @@ -157,9 +157,8 @@ let assign = "<\"Assign\">" let backend_stats_dir_name = "backend_stats" -(** If true, a procedure call succeeds even when there is a bound error this mimics what - happens with a direct array access where an error is produced and the analysis - continues *) +(** If true, a procedure call succeeds even when there is a bound error this mimics what happens + with a direct array access where an error is produced and the analysis continues *) let bound_error_allowed_in_procedure_call = true let buck_infer_deps_file_name = "infer-deps.txt" @@ -254,10 +253,8 @@ let max_narrows = 5 operator *) let max_widens = 10000 -(** Flag to tune the level of applying the meet operator for - preconditions during the footprint analysis: - 0 = do not use the meet - 1 = use the meet to generate new preconditions *) +(** Flag to tune the level of applying the meet operator for preconditions during the footprint + analysis: 0 = do not use the meet 1 = use the meet to generate new preconditions *) let meet_level = 1 let nsnotification_center_checker_backend = false @@ -399,8 +396,7 @@ let version_string = F.asprintf "%a" pp_version () (** System call configuration values *) -(** Initial time of the analysis, i.e. when this module is loaded, gotten from - Unix.time *) +(** Initial time of the analysis, i.e. when this module is loaded, gotten from Unix.time *) let initial_analysis_time = Unix.time () let clang_exe_aliases = @@ -484,17 +480,15 @@ let locate_sdk_root () = let infer_sdkroot_env_var = "INFER_SDKROOT" -(** Try to locate current SDK root on MacOS *unless* [SDKROOT] is - explicitly provided. The implicit SDK root is propagated to child - processes using a custom [INFER_SDKROOT] env var. The reason for - this is twofold: +(** Try to locate current SDK root on MacOS *unless* [SDKROOT] is explicitly provided. The implicit + SDK root is propagated to child processes using a custom [INFER_SDKROOT] env var. The reason for + this is twofold: - 1. With make and buck integrations infer is exec'ed by make/buck - for each source file. That's why we propagate the value by using an - env var instead of calling [locate_sdk_root] each time. + 1. With make and buck integrations infer is exec'ed by make/buck for each source file. That's + why we propagate the value by using an env var instead of calling [locate_sdk_root] each time. - 2. We don't use [SDKROOT] because it can mess up with other parts - of the toolchain not owned by infer. *) + 2. We don't use [SDKROOT] because it can mess up with other parts of the toolchain not owned by + infer. *) let implicit_sdk_root = match Sys.getenv "SDKROOT" with | Some _ -> @@ -1076,8 +1070,8 @@ and compute_analytics = cyclomatic complexity" -(** Continue the capture for reactive mode: - If a procedure was changed beforehand, keep the changed marking. *) +(** Continue the capture for reactive mode: If a procedure was changed beforehand, keep the changed + marking. *) and continue = CLOpt.mk_bool ~deprecated:["continue"] ~long:"continue" ~in_help:InferCommand.[(Analyze, manual_generic)] @@ -2472,9 +2466,10 @@ and version = (** visit mode for the worklist: - 0 depth - fist visit - 1 bias towards exit node - 2 least visited first *) + + - 0 depth - fist visit + - 1 bias towards exit node + - 2 least visited first *) and worklist_mode = let var = ref 0 in CLOpt.mk_set var 2 ~long:"coverage" "analysis mode to maximize coverage (can take longer)" ; diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index d70e60693..a60df4a20 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -8,15 +8,15 @@ open! IStd -(** Configuration values: either constant, determined at compile time, or set at startup - time by system calls, environment variables, or command line options *) +(** Configuration values: either constant, determined at compile time, or set at startup time by + system calls, environment variables, or command line options *) type os_type = Unix | Win32 | Cygwin type compilation_database_dependencies = | Deps of int option - (** get the compilation database of the dependencies up to depth n - by [Deps (Some n)], or all by [Deps None] *) + (** get the compilation database of the dependencies up to depth n by [Deps (Some n)], or all + by [Deps None] *) | NoDeps [@@deriving compare] diff --git a/infer/src/base/DB.mli b/infer/src/base/DB.mli index 699301df6..f54d0de9c 100644 --- a/infer/src/base/DB.mli +++ b/infer/src/base/DB.mli @@ -56,10 +56,8 @@ module Results_dir : sig end val append_crc_cutoff : ?key:string -> ?crc_only:bool -> string -> string -(** Append a crc to the string, using string_crc_hex32. - Cut the string if it exceeds the cutoff limit. - Use an optional key to compute the crc. - Return only the crc if [crc_only] is true. *) +(** Append a crc to the string, using string_crc_hex32. Cut the string if it exceeds the cutoff + limit. Use an optional key to compute the crc. Return only the crc if [crc_only] is true. *) val source_file_encoding : SourceFile.t -> string (** string encoding of a source file (including path) as a single filename *) diff --git a/infer/src/base/DBWriter.ml b/infer/src/base/DBWriter.ml index 7dea5ceea..40b4a9fb7 100644 --- a/infer/src/base/DBWriter.ml +++ b/infer/src/base/DBWriter.ml @@ -251,9 +251,10 @@ module Server = struct let socket_domain = Unix.domain_of_sockaddr socket_addr - (** Unix socket *paths* have a historical length limit of ~100 chars (!?*@&*$). However, this only applies - to the argument passed in the system call to create the socket, not to the actual path. - Thus a workaround is to cd into the parent dir of the socket and then use it, hence this function. *) + (** Unix socket *paths* have a historical length limit of ~100 chars (!?*\@&*$). However, this + only applies to the argument passed in the system call to create the socket, not to the actual + path. Thus a workaround is to cd into the parent dir of the socket and then use it, hence this + function. *) let in_results_dir ~f = Utils.do_in_dir ~dir:Config.toplevel_results_dir ~f let rec server_loop socket = diff --git a/infer/src/base/Epilogues.mli b/infer/src/base/Epilogues.mli index 90c71202e..06c6a5f21 100644 --- a/infer/src/base/Epilogues.mli +++ b/infer/src/base/Epilogues.mli @@ -13,8 +13,8 @@ val register : f:(unit -> unit) -> description:string -> unit val register_late : f:(unit -> unit) -> description:string -> unit (** Register a function to run when the program exits or is interrupted. Registered functions are - run in the reverse order in which they were registered, but *after* the ones registered with - {!register}. *) + run in the reverse order in which they were registered, but *after* the ones registered with + {!register}. *) val run : unit -> unit diff --git a/infer/src/base/FileDiff.ml b/infer/src/base/FileDiff.ml index 3d98bbeff..2cf036317 100644 --- a/infer/src/base/FileDiff.ml +++ b/infer/src/base/FileDiff.ml @@ -83,7 +83,7 @@ module VISIBLE_FOR_TESTING_DO_NOT_USE_DIRECTLY = struct end (** Given a difference between two files, return the relevant lines in the new file; a line is - relevant when a change took place in it, or nearby. To generate a valid input for this - parser, use unix-diff command with the following formatter arguments: - diff --unchanged-line-format="U" --old-line-format="O" --new-line-format="N" File1 File2 *) + relevant when a change took place in it, or nearby. To generate a valid input for this parser, + use unix-diff command with the following formatter arguments: diff --unchanged-line-format="U" + \--old-line-format="O" --new-line-format="N" File1 File2 *) let parse_unix_diff str = UnixDiff.process_raw_directives str |> parse_directives diff --git a/infer/src/base/FileDiff.mli b/infer/src/base/FileDiff.mli index f0ad43103..dcee359bd 100644 --- a/infer/src/base/FileDiff.mli +++ b/infer/src/base/FileDiff.mli @@ -25,6 +25,6 @@ end val parse_unix_diff : string -> int list (** Given a difference between two files, return the relevant lines in the new file; a line is - relevant when a change took place in it, or nearby. To generate a valid input for this - parser, use unix-diff command with the following formatter arguments: - diff --unchanged-line-format="U" --old-line-format="O" --new-line-format="N" File1 File2 *) + relevant when a change took place in it, or nearby. To generate a valid input for this parser, + use unix-diff command with the following formatter arguments: diff --unchanged-line-format="U" + \--old-line-format="O" --new-line-format="N" File1 File2 *) diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 3ce3ec4c7..55511925c 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -61,15 +61,16 @@ end = struct let set_enabled issue b = issue.enabled <- b (** Avoid creating new issue types. The idea is that there are three types of issue types: - 1. Statically pre-defined issue types, namely the ones in this module - 2. Dynamically created ones, eg from custom errors defined in the models, or defined by the + + Statically pre-defined issue types, namely the ones in this module + + + Dynamically created ones, eg from custom errors defined in the models, or defined by the user in AL linters - 3. Issue types created at command-line-parsing time. These can mention issues of type 1. or - 2., but issues of type 2. have not yet been defined. Thus, we record only there [enabled] - status definitely. The [hum]an-readable description can be updated when we encounter the - definition of the issue type, eg in AL. *) + + Issue types created at command-line-parsing time. These can mention issues of type 1. or 2., + but issues of type 2. have not yet been defined. Thus, we record only there [enabled] status + definitely. The [hum]an-readable description can be updated when we encounter the definition + of the issue type, eg in AL. *) let register_from_string ?(enabled = true) ?hum:hum0 ?doc_url ?linters_def_file unique_id = let hum = match hum0 with Some str -> str | _ -> prettify unique_id in let issue = {unique_id; enabled; hum; doc_url; linters_def_file} in diff --git a/infer/src/base/IssueType.mli b/infer/src/base/IssueType.mli index cce13a494..c54a4dc13 100644 --- a/infer/src/base/IssueType.mli +++ b/infer/src/base/IssueType.mli @@ -26,14 +26,11 @@ val pp : Format.formatter -> t -> unit val register_from_string : ?enabled:bool -> ?hum:string -> ?doc_url:string -> ?linters_def_file:string -> string -> t -(** Create a new issue and register it in the list of all issues. - NOTE: if the issue with the same string id is already registered, - overrides `hum`, `doc_url`, and `linters_def_file`, but DOES NOT override - `enabled`. This trick allows to deal with disabling/enabling dynamic AL issues - from the config, when we don't know all params yet. - Thus, the human-readable description can be updated when we encounter the - definition of the issue type, eg in AL. - *) +(** Create a new issue and register it in the list of all issues. NOTE: if the issue with the same + string id is already registered, overrides `hum`, `doc_url`, and `linters_def_file`, but DOES + NOT override `enabled`. This trick allows to deal with disabling/enabling dynamic AL issues from + the config, when we don't know all params yet. Thus, the human-readable description can be + updated when we encounter the definition of the issue type, eg in AL. *) val set_enabled : t -> bool -> unit @@ -74,18 +71,18 @@ val buffer_overrun_u5 : t val cannot_star : t val checkers_allocates_memory : t -(** Warning name when a performance critical method directly or indirectly - calls a method allocating memory *) +(** Warning name when a performance critical method directly or indirectly calls a method allocating + memory *) val checkers_annotation_reachability_error : t val checkers_calls_expensive_method : t -(** Warning name when a performance critical method directly or indirectly - calls a method annotatd as expensive *) +(** Warning name when a performance critical method directly or indirectly calls a method annotatd + as expensive *) val checkers_expensive_overrides_unexpensive : t -(** Warning name for the subtyping rule: method not annotated as expensive cannot be overridden - by a method annotated as expensive *) +(** Warning name for the subtyping rule: method not annotated as expensive cannot be overridden by a + method annotated as expensive *) val checkers_fragment_retain_view : t diff --git a/infer/src/base/Logging.mli b/infer/src/base/Logging.mli index 235d3c6e4..89e85480a 100644 --- a/infer/src/base/Logging.mli +++ b/infer/src/base/Logging.mli @@ -32,8 +32,7 @@ val task_progress : f:(unit -> unit) -> (F.formatter -> 'a -> unit) -> 'a -> uni val result : ('a, F.formatter, unit) format -> 'a (** Emit a result to stdout. Use only if the output format is stable and useful enough that it may - conceivably get piped to another program, ie, almost never (use [progress] instead otherwise). -*) + conceivably get piped to another program, ie, almost never (use [progress] instead otherwise). *) val user_error : ('a, F.formatter, unit) format -> 'a (** bad input, etc. detected *) diff --git a/infer/src/base/MarkupFormatter.mli b/infer/src/base/MarkupFormatter.mli index a55267488..20d5f06a4 100644 --- a/infer/src/base/MarkupFormatter.mli +++ b/infer/src/base/MarkupFormatter.mli @@ -8,28 +8,28 @@ open! IStd val wrap_monospaced : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a -> unit -(** used to combine pp together, wrap content into a monospaced block *) +(** used to combine pp together, wrap content into a monospaced block *) val pp_monospaced : Format.formatter -> string -> unit -(** pp to wrap into a monospaced block *) +(** pp to wrap into a monospaced block *) val monospaced_to_string : string -> string (** wrap into a monospaced block *) val wrap_code : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a -> unit [@@warning "-32"] -(** used to combine pp together, wrap content into a code block *) +(** used to combine pp together, wrap content into a code block *) val pp_code : Format.formatter -> string -> unit [@@warning "-32"] -(** pp to wrap into a code block *) +(** pp to wrap into a code block *) val wrap_bold : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a -> unit [@@warning "-32"] -(** used to combine pp together, wrap content into a bold block *) +(** used to combine pp together, wrap content into a bold block *) val pp_bold : Format.formatter -> string -> unit -(** pp to wrap into a bold block *) +(** pp to wrap into a bold block *) val bold_to_string : string -> string [@@warning "-32"] (** wrap into a bold block *) diff --git a/infer/src/base/PerfEvent.ml b/infer/src/base/PerfEvent.ml index abc264592..0ba116c70 100644 --- a/infer/src/base/PerfEvent.ml +++ b/infer/src/base/PerfEvent.ml @@ -64,8 +64,8 @@ module JsonFragment = struct "InList" - (** for some limited (not thread-safe) form of safety, and to know when we need to print separators - *) + (** for some limited (not thread-safe) form of safety, and to know when we need to print + separators *) let pp_state = ref [Outside] let pp f json_fragment = diff --git a/infer/src/base/Process.ml b/infer/src/base/Process.ml index f8d81fd8c..6791d9c38 100644 --- a/infer/src/base/Process.ml +++ b/infer/src/base/Process.ml @@ -9,8 +9,8 @@ open! IStd module L = Logging module F = Format -(** Prints an error message to a log file, prints a message saying that the error can be - found in that file, and exits, with default code 1 or a given code. *) +(** Prints an error message to a log file, prints a message saying that the error can be found in + that file, and exits, with default code 1 or a given code. *) let print_error_and_exit ?(exit_code = 1) fmt = F.kfprintf (fun _ -> @@ -20,8 +20,8 @@ let print_error_and_exit ?(exit_code = 1) fmt = (** Given a command to be executed, create a process to execute this command, and wait for it to - terminate. The standard out and error are not redirected. If the command fails to execute, - print an error message and exit. *) + terminate. The standard out and error are not redirected. If the command fails to execute, print + an error message and exit. *) let create_process_and_wait ~prog ~args = Unix.fork_exec ~prog ~argv:(prog :: args) () |> Unix.waitpid diff --git a/infer/src/base/Process.mli b/infer/src/base/Process.mli index 6d30be017..0c6f9967e 100644 --- a/infer/src/base/Process.mli +++ b/infer/src/base/Process.mli @@ -8,13 +8,13 @@ open! IStd val create_process_and_wait : prog:string -> args:string list -> unit -(** Given an command to be executed, creates a process to execute this command, - and waits for its execution. The standard out and error are not redirected. - If the commands fails to execute, prints an error message and exits. *) +(** Given an command to be executed, creates a process to execute this command, and waits for its + execution. The standard out and error are not redirected. If the commands fails to execute, + prints an error message and exits. *) val print_error_and_exit : ?exit_code:int -> ('a, Format.formatter, unit, 'b) format4 -> 'a -(** Prints an error message to a log file, prints a message saying that the error can be - found in that file, and exist, with default code 1 or a given code. *) +(** Prints an error message to a log file, prints a message saying that the error can be found in + that file, and exist, with default code 1 or a given code. *) val pipeline : producer_prog:string diff --git a/infer/src/base/ProcessPool.ml b/infer/src/base/ProcessPool.ml index 905a67bef..67d2beb8f 100644 --- a/infer/src/base/ProcessPool.ml +++ b/infer/src/base/ProcessPool.ml @@ -50,12 +50,13 @@ let log_or_die fmt = if Config.keep_going then L.internal_error fmt else L.die I type child_info = {pid: Pid.t; down_pipe: Out_channel.t} -(** The master's abstraction of state for workers. - See [worker_message] and [boss_message] below for transitions between states. +(** The master's abstraction of state for workers. See [worker_message] and [boss_message] below for + transitions between states. + - [Initializing] is the state a newly-forked worker is in. - - [Idle] is the state a worker goes to after it finishes initializing, or finishes processing a work item. - - [Processing x] means the worker is currently processing [x]. -*) + - [Idle] is the state a worker goes to after it finishes initializing, or finishes processing a + work item. + - [Processing x] means the worker is currently processing [x]. *) type 'a child_state = Initializing | Idle | Processing of 'a (** the state of the pool *) @@ -74,9 +75,8 @@ type ('work, 'final) t = (** {2 Constants} *) -(** refresh rate of the task bar (worst case: it also refreshes on children updates) - this is now mandatory to allow checking for new work packets, when none were - previously available *) +(** refresh rate of the task bar (worst case: it also refreshes on children updates) this is now + mandatory to allow checking for new work packets, when none were previously available *) let refresh_timeout = let frames_per_second = 12 in `After (Time_ns.Span.of_int_ms (1_000 / frames_per_second)) @@ -99,14 +99,14 @@ type worker_message = (** [(i, t, status)]: starting a task from slot [i], at start time [t], with description [status]. Watch out that [status] must not be too close in length to [buffer_size]. *) | Ready of int - (** Sent after finishing initializing or after finishing a given task. - When received by master, this moves the worker state from [Initializing] or [Processing _] to [Idle]. *) + (** Sent after finishing initializing or after finishing a given task. When received by + master, this moves the worker state from [Initializing] or [Processing _] to [Idle]. *) | Crash of int (** there was an error and the child is no longer receiving messages *) (** messages from the parent process down to worker processes *) type 'a boss_message = | Do of 'a - (** [Do x] is sent only when the worker is [Idle], and moves worker state to [Processing x] *) + (** [Do x] is sent only when the worker is [Idle], and moves worker state to [Processing x] *) | GoHome (** all tasks done, prepare for teardown *) (** convenience function to send data down pipes without forgetting to flush *) @@ -132,8 +132,8 @@ let rec really_read ?(pos = 0) ~len fd ~buf = (** return a list of all updates coming from workers. The first update is expected for up to the - timeout [refresh_timeout]. After that, all already received updates are consumed but with zero timeout. - If there is none left, return the list. *) + timeout [refresh_timeout]. After that, all already received updates are consumed but with zero + timeout. If there is none left, return the list. *) let wait_for_updates pool buffer = let rec aux acc ~timeout = let file_descr = pool.children_updates in @@ -239,7 +239,7 @@ let send_work_to_child pool slot = (** main dispatch function that responds to messages from worker processes and updates the taskbar - periodically *) + periodically *) let process_updates pool buffer = (* abort everything if some child has died unexpectedly *) has_dead_child pool diff --git a/infer/src/base/ProcessPool.mli b/infer/src/base/ProcessPool.mli index a8ceb32ac..b41306ffc 100644 --- a/infer/src/base/ProcessPool.mli +++ b/infer/src/base/ProcessPool.mli @@ -11,18 +11,18 @@ module TaskGenerator : sig (** abstraction for generating jobs *) type 'a t = { remaining_tasks: unit -> int - (** number of tasks remaining to complete -- only used for reporting, so imprecision is not a bug *) + (** number of tasks remaining to complete -- only used for reporting, so imprecision is + not a bug *) ; is_empty: unit -> bool (** when should the main loop of the task manager stop expecting new tasks *) ; finished: 'a -> unit - (** Process pool calls [finished x] when a worker finishes item [x]. This is only called - if [next ()] has previously returned [Some x] and [x] was sent to a worker. *) + (** Process pool calls [finished x] when a worker finishes item [x]. This is only called + if [next ()] has previously returned [Some x] and [x] was sent to a worker. *) ; next: unit -> 'a option - (** [next ()] generates the next work item. If [is_empty ()] is true then [next ()] - must return [None]. However, it is OK to for [next ()] to return [None] when [is_empty] - is false. This corresponds to the case where there is more work to be done, - but it is not schedulable until some already scheduled work is finished. *) - } + (** [next ()] generates the next work item. If [is_empty ()] is true then [next ()] must + return [None]. However, it is OK to for [next ()] to return [None] when [is_empty] is + false. This corresponds to the case where there is more work to be done, but it is not + schedulable until some already scheduled work is finished. *) } val chain : 'a t -> 'a t -> 'a t (** chain two generators in order *) @@ -48,7 +48,7 @@ end See also {!module-ProcessPoolState}. *) (** A [('work, 'final) t] process pool accepts tasks of type ['work] and produces an array of - results of type ['final]. ['work] and ['final] will be marshalled over a Unix pipe.*) + results of type ['final]. ['work] and ['final] will be marshalled over a Unix pipe.*) type (_, _) t val create : diff --git a/infer/src/base/ResultsDatabase.mli b/infer/src/base/ResultsDatabase.mli index 3d1aec1ff..05b19dd14 100644 --- a/infer/src/base/ResultsDatabase.mli +++ b/infer/src/base/ResultsDatabase.mli @@ -14,7 +14,7 @@ val database_fullpath : string (** the absolute path to the database file *) val schema_hum : string -(** some human-readable string describing the tables *) +(** some human-readable string describing the tables *) val create_tables : ?prefix:string -> Sqlite3.db -> unit @@ -23,7 +23,8 @@ val get_database : unit -> Sqlite3.db connection to it may change during the execution (see [new_database_connection]). *) val new_database_connection : unit -> unit -(** Closes the previous connection to the database (if any), and opens a new one. Needed after calls to fork(2). *) +(** Closes the previous connection to the database (if any), and opens a new one. Needed after calls + to fork(2). *) val db_close : unit -> unit (** close the current connection to the database *) diff --git a/infer/src/base/Serialization.ml b/infer/src/base/Serialization.ml index d981acf4a..451de9537 100644 --- a/infer/src/base/Serialization.ml +++ b/infer/src/base/Serialization.ml @@ -23,7 +23,7 @@ module Key = struct } (** Current keys for various serializable objects. The keys are computed using the [generate_keys] - function below *) + function below *) let tenv, summary, issues = ( {name= "tenv"; key= 425184201} , {name= "summary"; key= 160179325} diff --git a/infer/src/base/Serialization.mli b/infer/src/base/Serialization.mli index 33dc52ad0..f30379cf5 100644 --- a/infer/src/base/Serialization.mli +++ b/infer/src/base/Serialization.mli @@ -28,8 +28,7 @@ end type 'a serializer val create_serializer : Key.t -> 'a serializer -(** create a serializer from a file name - given an integer key used as double-check of the file type *) +(** create a serializer from a file name given an integer key used as double-check of the file type *) val read_from_file : 'a serializer -> DB.filename -> 'a option (** Deserialize a file and check the keys *) diff --git a/infer/src/base/SourceFile.mli b/infer/src/base/SourceFile.mli index a7b1a888c..c387c1c41 100644 --- a/infer/src/base/SourceFile.mli +++ b/infer/src/base/SourceFile.mli @@ -21,9 +21,8 @@ val is_invalid : t -> bool (** Is the source file the invalid source file? *) val changed_sources_from_changed_files : string list -> Set.t -(** Set of files read from --changed-files-index file, None if option not specified - NOTE: it may include extra source_files if --changed-files-index contains paths to - header files *) +(** Set of files read from --changed-files-index file, None if option not specified NOTE: it may + include extra source_files if --changed-files-index contains paths to header files *) val invalid : string -> t (** Invalid source file *) @@ -32,14 +31,13 @@ val equal : t -> t -> bool (** equality of source files *) val from_abs_path : ?warn_on_error:bool -> string -> t -(** create source file from absolute path. - WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for - the given path (e.g. if it does not exist). *) +(** create source file from absolute path. WARNING: If warn_on_error is false, no warning will be + shown whenever an error occurs for the given path (e.g. if it does not exist). *) val create : ?warn_on_error:bool -> string -> t (** Create a SourceFile from a given path. If relative, it assumes it is w.r.t. project root. - WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for - the given path (e.g. if it does not exist). *) + WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for the + given path (e.g. if it does not exist). *) val is_biabduction_model : t -> bool @@ -50,10 +48,9 @@ val line_count : t -> int (** compute line count of a source file *) val of_header : ?warn_on_error:bool -> t -> t option -(** Return approximate source file corresponding to the parameter if it's header file and - file exists. returns None otherwise. - WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for - the given SourceFile (e.g. if it does not exist). *) +(** Return approximate source file corresponding to the parameter if it's header file and file + exists. returns None otherwise. WARNING: If warn_on_error is false, no warning will be shown + whenever an error occurs for the given SourceFile (e.g. if it does not exist). *) val pp : Format.formatter -> t -> unit (** pretty print t *) @@ -65,8 +62,7 @@ val to_rel_path : t -> string (** get the relative path of a source file *) val to_string : ?force_relative:bool -> t -> string -(** convert a source file to a string - WARNING: result may not be valid file path, do not use this function to perform operations - on filenames *) +(** convert a source file to a string WARNING: result may not be valid file path, do not use this + function to perform operations on filenames *) module SQLite : SqliteUtils.Data with type t = t diff --git a/infer/src/base/SqliteUtils.mli b/infer/src/base/SqliteUtils.mli index 336fa9594..1f6089ce1 100644 --- a/infer/src/base/SqliteUtils.mli +++ b/infer/src/base/SqliteUtils.mli @@ -72,7 +72,8 @@ module type Data = sig val deserialize : Sqlite3.Data.t -> t end -(** A default implementation of the Data API that encodes every objects as marshalled blobs with no sharing *) +(** A default implementation of the Data API that encodes every objects as marshalled blobs with no + sharing *) module MarshalledDataForComparison (D : sig type t end) : Data with type t = D.t diff --git a/infer/src/base/SymOp.ml b/infer/src/base/SymOp.ml index 89bb7416a..ef1450366 100644 --- a/infer/src/base/SymOp.ml +++ b/infer/src/base/SymOp.ml @@ -74,9 +74,8 @@ type t = ; mutable last_wallclock: float option (** last wallclock set by an alarm, if any *) ; mutable symop_count: int (** Number of symop's *) ; symop_total: int ref - (** Counter for the total number of symop's. - The new state created when save_state is called shares this counter - if keep_symop_total is true. Otherwise, a new counter is created. *) + (** Counter for the total number of symop's. The new state created when save_state is called + shares this counter if keep_symop_total is true. Otherwise, a new counter is created. *) } let initial () : t = {alarm_active= false; last_wallclock= None; symop_count= 0; symop_total= ref 0} @@ -87,8 +86,8 @@ let gs : t ref = ref (initial ()) (** Restore the old state. *) let restore_state state = gs := state -(** Return the old state, and revert the current state to the initial one. - If keep_symop_total is true, share the total counter. *) +(** Return the old state, and revert the current state to the initial one. If keep_symop_total is + true, share the total counter. *) let save_state ~keep_symop_total = let old_state = !gs in let new_state = diff --git a/infer/src/base/SymOp.mli b/infer/src/base/SymOp.mli index 0e841de46..fa895451e 100644 --- a/infer/src/base/SymOp.mli +++ b/infer/src/base/SymOp.mli @@ -35,8 +35,8 @@ val restore_state : t -> unit (** Restore the old state. *) val save_state : keep_symop_total:bool -> t -(** Return the old state, and revert the current state to the initial one. - If keep_symop_total is true, share the total counter. *) +(** Return the old state, and revert the current state to the initial one. If keep_symop_total is + true, share the total counter. *) val set_alarm : unit -> unit (** Reset the counter and activate the alarm *) @@ -67,9 +67,9 @@ val exn_not_failure : exn -> bool val try_finally : f:(unit -> 'a) -> finally:(unit -> unit) -> 'a (** [try_finally ~f ~finally] executes [f] and then [finally] even if [f] raises an exception. - Assuming that [finally ()] terminates quickly [Analysis_failure_exe] exceptions are handled correctly. - In particular, an exception raised by [f ()] is delayed until [finally ()] finishes, so [finally ()] should - return reasonably quickly. *) + Assuming that [finally ()] terminates quickly [Analysis_failure_exe] exceptions are handled + correctly. In particular, an exception raised by [f ()] is delayed until [finally ()] finishes, + so [finally ()] should return reasonably quickly. *) val pp_failure_kind : Format.formatter -> failure_kind -> unit diff --git a/infer/src/base/TaskBar.ml b/infer/src/base/TaskBar.ml index 6dafbf309..4ff9d5128 100644 --- a/infer/src/base/TaskBar.ml +++ b/infer/src/base/TaskBar.ml @@ -8,7 +8,7 @@ open! IStd module F = Format -(** {2 arbitrary constants } *) +(** {2 arbitrary constants} *) (** max size for the top bar of the multiline task bar *) let top_bar_size_default = 100 diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index e73e771d6..4c774f2dd 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -356,8 +356,8 @@ let unlink_file_on_exit temp_file = (** drop at most one layer of well-balanced first and last characters satisfying [drop] from the - string; for instance, [strip_balanced ~drop:(function | 'a' | 'x' -> true | _ -> false) "xaabax"] - returns "aaba" *) + string; for instance, + [strip_balanced ~drop:(function | 'a' | 'x' -> true | _ -> false) "xaabax"] returns "aaba" *) let strip_balanced_once ~drop s = let n = String.length s in if n < 2 then s diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index bea6ccbbe..4c42d58e3 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -15,7 +15,7 @@ val find_files : path:string -> extension:string -> string list (** recursively traverse a path for files ending with a given extension *) val string_crc_hex32 : string -> string -(** Compute a 32-character hexadecimal crc using the Digest module *) +(** Compute a 32-character hexadecimal crc using the Digest module *) val read_file : string -> (string list, string) Result.t (** read a source file and return a list of lines *) @@ -25,9 +25,9 @@ val filename_to_absolute : root:string -> string -> string val filename_to_relative : ?force_full_backtrack:bool -> ?backtrack:int -> root:string -> string -> string option -(** Convert an absolute filename to one relative to a root directory. Returns [None] if filename is - not under root. The backtrack level sets the maximum level of steps in the parent directories - to search for a common prefix *) +(** Convert an absolute filename to one relative to a root directory. Returns [None] if filename is + not under root. The backtrack level sets the maximum level of steps in the parent directories to + search for a common prefix *) (** type for files used for printing *) type outfile = @@ -36,7 +36,8 @@ type outfile = ; fmt: Format.formatter (** formatter for printing *) } val create_outfile : string -> outfile option -(** create an outfile for the command line, the boolean indicates whether to do demangling when closing the file *) +(** create an outfile for the command line, the boolean indicates whether to do demangling when + closing the file *) val close_outf : outfile -> unit (** close an outfile *) @@ -68,7 +69,8 @@ val create_file_lock : unit -> file_lock val with_file_lock : file_lock:file_lock -> f:(unit -> 'a) -> 'a val with_intermediate_temp_file_out : string -> f:(Out_channel.t -> 'a) -> 'a -(** like [with_file_out] but uses a fresh intermediate temporary file and rename to avoid write-write races *) +(** like [with_file_out] but uses a fresh intermediate temporary file and rename to avoid + write-write races *) val write_json_to_file : string -> Yojson.Basic.t -> unit @@ -89,32 +91,31 @@ val with_process_lines : -> f:(string list -> 'res) -> 'res (** Runs the command [cmd] and calls [f] on the output lines. Uses [debug] to print debug - information, and [tmp_prefix] as a prefix for temporary files. *) + information, and [tmp_prefix] as a prefix for temporary files. *) val create_dir : string -> unit (** create a directory if it does not exist already *) val realpath : ?warn_on_error:bool -> string -> string -(** [realpath warn_on_error path] returns path with all symbolic links resolved. - It caches results of previous calls to avoid expensive system calls. - WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for - the given path (e.g. if it does not exist). *) +(** [realpath warn_on_error path] returns path with all symbolic links resolved. It caches results + of previous calls to avoid expensive system calls. WARNING: If warn_on_error is false, no + warning will be shown whenever an error occurs for the given path (e.g. if it does not exist). *) val suppress_stderr2 : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c (** wraps a function expecting 2 arguments in another that temporarily redirects stderr to /dev/null for the duration of the function call *) val compare_versions : string -> string -> int -(** [compare_versions v1 v2] returns 1 if v1 is newer than v2, - -1 if v1 is older than v2 and 0 if they are the same version. - The versions are strings of the shape "n.m.t", the order is lexicographic. *) +(** [compare_versions v1 v2] returns 1 if v1 is newer than v2, -1 if v1 is older than v2 and 0 if + they are the same version. The versions are strings of the shape "n.m.t", the order is + lexicographic. *) val rmtree : string -> unit (** [rmtree path] removes [path] and, if [path] is a directory, recursively removes its contents *) val try_finally_swallow_timeout : f:(unit -> 'a) -> finally:(unit -> unit) -> 'a -(** Calls [f] then [finally] even if [f] raised an exception. The original exception is reraised afterwards. - Where possible use [SymOp.try_finally] to avoid swallowing timeouts. *) +(** Calls [f] then [finally] even if [f] raised an exception. The original exception is reraised + afterwards. Where possible use [SymOp.try_finally] to avoid swallowing timeouts. *) val better_hash : 'a -> Caml.Digest.t (** Hashtbl.hash only hashes the first 10 meaningful values, [better_hash] uses everything. *) @@ -124,17 +125,20 @@ val unlink_file_on_exit : string -> unit val strip_balanced_once : drop:(char -> bool) -> string -> string (** drop at most one layer of well-balanced first and last characters satisfying [drop] from the - string; for instance, [strip_balanced ~drop:(function | 'a' | 'x' -> true | _ -> false) "xaabax"] - returns "aaba" *) + string; for instance, + [strip_balanced ~drop:(function | 'a' | 'x' -> true | _ -> false) "xaabax"] returns "aaba" *) val assoc_of_yojson : Yojson.Basic.t -> src:string -> (string, Yojson.Basic.t) List.Assoc.t -(** Verify we have a json object (or empty list) and return the corresponding assoc list. Otherwise die with a message including src. *) +(** Verify we have a json object (or empty list) and return the corresponding assoc list. Otherwise + die with a message including src. *) val string_of_yojson : Yojson.Basic.t -> src:string -> string -(** Verify we have a json string and return the corresponding ocaml string. Otherwise die with a message including src. *) +(** Verify we have a json string and return the corresponding ocaml string. Otherwise die with a + message including src. *) val string_list_of_yojson : Yojson.Basic.t -> src:string -> string list -(** Verify we have a json list of strings and return the corresponding ocaml string list. Otherwise die with a message including src. *) +(** Verify we have a json list of strings and return the corresponding ocaml string list. Otherwise + die with a message including src. *) val yojson_lookup : (string, Yojson.Basic.t) List.Assoc.t @@ -143,7 +147,9 @@ val yojson_lookup : -> f:(Yojson.Basic.t -> src:string -> 'a) -> default:'a -> 'a -(** Lookup a json value on an assoc list. If not present, returns default. Otherwise returns (f json_value ~src) where src has element name appended. f is typically one of the above _of_yojson functions. *) +(** Lookup a json value on an assoc list. If not present, returns default. Otherwise returns (f + json_value ~src) where src has element name appended. f is typically one of the above _of_yojson + functions. *) val timeit : f:(unit -> 'a) -> 'a * int (** Returns the execution time of [f] in milliseconds together with its result *) @@ -152,9 +158,9 @@ val do_in_dir : dir:string -> f:(unit -> 'a) -> 'a (** executes [f] after cding into [dir] and then restores original cwd *) val get_available_memory_MB : unit -> int option -(** On Linux systems, return [Some x] where [MemAvailable x] is in [/proc/meminfo]. - Returns [None] in all other cases. *) +(** On Linux systems, return [Some x] where [MemAvailable x] is in [/proc/meminfo]. Returns [None] + in all other cases. *) val iter_infer_deps : project_root:string -> f:(string -> unit) -> string -> unit -(** Parse each line of the given infer_deps.txt file (split on tabs, assume 3 elements per line) - and run [f] on the third element. [project_root] is an argument to avoid dependency cycles. *) +(** Parse each line of the given infer_deps.txt file (split on tabs, assume 3 elements per line) and + run [f] on the third element. [project_root] is an argument to avoid dependency cycles. *) diff --git a/infer/src/base/ZipLib.mli b/infer/src/base/ZipLib.mli index 7a301a308..10fc420e5 100644 --- a/infer/src/base/ZipLib.mli +++ b/infer/src/base/ZipLib.mli @@ -8,6 +8,6 @@ open! IStd val load : 'a Serialization.serializer -> string -> 'a option -(** [load serializer path] searches for the file at the given path in the zip libraries. - If Config.infer_cache is set, already deserialized data will be saved there and [path] - will be searched from the cache first. *) +(** [load serializer path] searches for the file at the given path in the zip libraries. If + Config.infer_cache is set, already deserialized data will be saved there and [path] will be + searched from the cache first. *) diff --git a/infer/src/base/polyFields.mli b/infer/src/base/polyFields.mli index 0ef165272..58fab35eb 100644 --- a/infer/src/base/polyFields.mli +++ b/infer/src/base/polyFields.mli @@ -15,19 +15,13 @@ type 'r sub = S : ('r, 'f) Field.t * 'f t -> 'r sub type ('r, 'a) user = {f: 'f. string -> ('r -> 'f) -> 'a} [@@unboxed] val make : ?subfields:'r sub list -> ((_, 'r, 'r t) Field.user -> 'r t list) -> 'r t -(** - Pass [Fields.map_poly] generated by [@@deriving fields] for the record ['r] you are interested - in to get the polymorphic getters of the fields of ['r]. - A dummy field "ALL" is added too. +(** Pass [Fields.map_poly] generated by [@@deriving fields] for the record ['r] you are interested + in to get the polymorphic getters of the fields of ['r]. A dummy field "ALL" is added too. - Subfields appearing in [subfields] will be added too. - Each subfield is specified by [S (field, poly_fields)] where [field] is the corresponding - [Field.t] value (generated by [@@deriving fields]) and [poly_fields] is the result of this - function for the field record type. -*) + Subfields appearing in [subfields] will be added too. Each subfield is specified by + [S (field, poly_fields)] where [field] is the corresponding [Field.t] value (generated by + [@@deriving fields]) and [poly_fields] is the result of this function for the field record type. *) val map : 'r t -> ('r, 'a) user -> 'a list -(** - [map r f] maps each field of [r] with the function [f]. - [f] is called with two arguments: the name and the getter of the field. -*) +(** [map r f] maps each field of [r] with the function [f]. [f] is called with two arguments: the + name and the getter of the field. *) diff --git a/infer/src/biabduction/Abs.ml b/infer/src/biabduction/Abs.ml index 3c7507aa8..152765992 100644 --- a/infer/src/biabduction/Abs.ml +++ b/infer/src/biabduction/Abs.ml @@ -1152,8 +1152,8 @@ let check_junk pname tenv prop = else Prop.normalize tenv (Prop.set prop ~sigma:sigma_new ~sigma_fp:sigma_fp_new) -(** Check whether the prop contains junk. - If it does, and [Config.allowleak] is true, remove the junk, otherwise raise a Leak exception. *) +(** Check whether the prop contains junk. If it does, and [Config.allowleak] is true, remove the + junk, otherwise raise a Leak exception. *) let abstract_junk pname tenv prop = Absarray.array_abstraction_performed := false ; check_junk pname tenv prop @@ -1232,8 +1232,8 @@ let remove_local_stack sigma pvars = List.filter ~f:filter_non_stack sigma -(** [prop_set_fooprint p p_foot] removes a local stack from [p_foot], - and sets proposition [p_foot] as footprint of [p]. *) +(** [prop_set_fooprint p p_foot] removes a local stack from [p_foot], and sets proposition [p_foot] + as footprint of [p]. *) let set_footprint_for_abs (p : 'a Prop.t) (p_foot : 'a Prop.t) local_stack_pvars : Prop.exposed Prop.t = let p_foot_pure = Prop.get_pure p_foot in diff --git a/infer/src/biabduction/Abs.mli b/infer/src/biabduction/Abs.mli index 1463ba7df..e52e3a64f 100644 --- a/infer/src/biabduction/Abs.mli +++ b/infer/src/biabduction/Abs.mli @@ -17,9 +17,8 @@ val abstract : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Pro (** Abstract a proposition. *) val abstract_junk : Typ.Procname.t -> Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t -(** Check whether the prop contains junk. - If it does, and [Config.allowleak] is true, remove the junk, - otherwise raise a Leak exception. *) +(** 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 (** Abstract a proposition but don't pay a SymOp *) diff --git a/infer/src/biabduction/Absarray.ml b/infer/src/biabduction/Absarray.ml index c0dcf21e1..804c1c89f 100644 --- a/infer/src/biabduction/Absarray.ml +++ b/infer/src/biabduction/Absarray.ml @@ -10,8 +10,8 @@ open! IStd module L = Logging (** This function should be used before adding a new index to Earray. The [exp] is the newly created - index. This function "cleans" [exp] according to whether it is the footprint or current part of - the prop. The function faults in the re - execution mode, as an internal check of the tool. *) + index. This function "cleans" [exp] according to whether it is the footprint or current part of + the prop. The function faults in the re - execution mode, as an internal check of the tool. *) let array_clean_new_index footprint_part new_idx = assert (not (footprint_part && not !BiabductionConfig.footprint)) ; if @@ -294,8 +294,8 @@ end = struct replace_hpred (sigma, hpred, syn_offs) hpred' end -(** This function renames expressions in [p]. The renaming is, roughly - speaking, to replace [path.i] by [path.i'] for all (i, i') in [map]. *) +(** This function renames expressions in [p]. The renaming is, roughly speaking, to replace [path.i] + by [path.i'] for all (i, i') in [map]. *) let prop_replace_path_index tenv (p : Prop.exposed Prop.t) (path : StrexpMatch.path) (map : (Exp.t * Exp.t) list) : Prop.exposed Prop.t = let elist_path = StrexpMatch.path_to_exps path in @@ -320,8 +320,8 @@ let prop_replace_path_index tenv (p : Prop.exposed Prop.t) (path : StrexpMatch.p Prop.prop_expmap expmap_fun p -(** This function uses [update] and transforms the two sigma parts of [p], - the sigma of the current SH of [p] and that of the footprint of [p]. *) +(** This function uses [update] and transforms the two sigma parts of [p], the sigma of the current + SH of [p] and that of the footprint of [p]. *) let prop_update_sigma_and_fp_sigma tenv (p : Prop.normal Prop.t) (update : bool -> sigma -> sigma * bool) : Prop.normal Prop.t * bool = let sigma', changed = update false p.Prop.sigma in @@ -338,9 +338,9 @@ let prop_update_sigma_and_fp_sigma tenv (p : Prop.normal Prop.t) (** Remember whether array abstraction was performed (to be reset before calling Abs.abstract) *) let array_abstraction_performed = ref false -(** This function abstracts strexps. The parameter [can_abstract] spots strexps - where the abstraction might be applicable, and the parameter [do_abstract] does - the abstraction to those spotted strexps. *) +(** This function abstracts strexps. The parameter [can_abstract] spots strexps where the + abstraction might be applicable, and the parameter [do_abstract] does the abstraction to those + spotted strexps. *) let generic_strexp_abstract tenv (abstraction_name : string) (p_in : Prop.normal Prop.t) (can_abstract_ : StrexpMatch.strexp_data -> bool) (do_abstract : @@ -584,7 +584,8 @@ let report_error prop = assert false -(** Check performed after the array abstraction to see whether it was successful. Raise assert false in case of failure *) +(** Check performed after the array abstraction to see whether it was successful. Raise assert false + in case of failure *) let check_after_array_abstraction tenv prop = let lookup = Tenv.lookup tenv in let check_index root offs (ind, _) = diff --git a/infer/src/biabduction/Absarray.mli b/infer/src/biabduction/Absarray.mli index d96d81228..854da74f6 100644 --- a/infer/src/biabduction/Absarray.mli +++ b/infer/src/biabduction/Absarray.mli @@ -9,11 +9,9 @@ open! IStd val array_clean_new_index : bool -> Exp.t -> Exp.t -(** This function should be used before adding a new - index to Earray. The [exp] is the newly created - index. This function "cleans" [exp] according to whether it is the - footprint or current part of the prop. - The function faults in the re - execution mode, as an internal check of the tool. *) +(** This function should be used before adding a new index to Earray. The [exp] is the newly created + index. This function "cleans" [exp] according to whether it is the footprint or current part of + the prop. The function faults in the re - execution mode, as an internal check of the tool. *) (** Abstraction for Arrays *) diff --git a/infer/src/biabduction/Attribute.ml b/infer/src/biabduction/Attribute.ml index d1e2fced4..a2084db1d 100644 --- a/infer/src/biabduction/Attribute.ml +++ b/infer/src/biabduction/Attribute.ml @@ -189,10 +189,9 @@ let rec nullify_exp_with_objc_null tenv prop exp = prop -(** mark Exp.Var's or Exp.Lvar's as undefined -The annotations of the return type of the method get propagated to the return id, -with the exception of when the return type is a struct, and we translate it as passing a reference -to the method. *) +(** mark Exp.Var's or Exp.Lvar's as undefined The annotations of the return type of the method get + propagated to the return id, with the exception of when the return type is a struct, and we + translate it as passing a reference to the method. *) let mark_vars_as_undefined tenv prop ~ret_exp ~undefined_actuals_by_ref callee_pname ret_annots loc path_pos = let mark_var_as_undefined ~annot exp prop = @@ -278,8 +277,8 @@ let find_arithmetic_problem tenv proc_node_session prop exp = (problem_opt, !res) -(** Deallocate the stack variables in [pvars], and replace them by normal variables. - Return the list of stack variables whose address was still present after deallocation. *) +(** Deallocate the stack variables in [pvars], and replace them by normal variables. Return the list + of stack variables whose address was still present after deallocation. *) let deallocate_stack_vars tenv (p : 'a Prop.t) pvars = let filter = function | Sil.Hpointsto (Exp.Lvar v, _, _) -> @@ -334,9 +333,8 @@ let deallocate_stack_vars tenv (p : 'a Prop.t) pvars = (!stack_vars_address_in_post, List.fold ~f:(Prop.prop_atom_and tenv) ~init:p''' pi) -(** Input of this method is an exp in a prop. Output is a formal variable or path from a - formal variable that is equal to the expression, - or the OBJC_NULL attribute of the expression. *) +(** Input of this method is an exp in a prop. Output is a formal variable or path from a formal + variable that is equal to the expression, or the OBJC_NULL attribute of the expression. *) let find_equal_formal_path tenv e prop = let rec find_in_sigma e seen_hpreds = List.fold_right diff --git a/infer/src/biabduction/Attribute.mli b/infer/src/biabduction/Attribute.mli index 685bfab9e..41c4fc72d 100644 --- a/infer/src/biabduction/Attribute.mli +++ b/infer/src/biabduction/Attribute.mli @@ -32,8 +32,8 @@ val add_or_replace_check_changed : -> Prop.normal Prop.t -> Sil.atom -> Prop.normal Prop.t -(** Replace an attribute associated to the expression, and call the given function with new and - old attributes if they changed. *) +(** Replace an attribute associated to the expression, and call the given function with new and old + attributes if they changed. *) val get_all : 'a Prop.t -> Sil.atom list (** Get all the attributes of the prop *) @@ -77,12 +77,12 @@ val map_resource : (** Apply f to every resource attribute in the prop *) val replace_objc_null : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Exp.t -> Prop.normal Prop.t -(** [replace_objc_null lhs rhs]. - If rhs has the objc_null attribute, replace the attribute and set the lhs = 0 *) +(** [replace_objc_null lhs rhs]. If rhs has the objc_null attribute, replace the attribute and set + the lhs = 0 *) val nullify_exp_with_objc_null : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Prop.normal Prop.t -(** For each Var subexp of the argument with an Aobjc_null attribute, - remove the attribute and conjoin an equality to zero. *) +(** For each Var subexp of the argument with an Aobjc_null attribute, remove the attribute and + conjoin an equality to zero. *) val mark_vars_as_undefined : Tenv.t @@ -113,7 +113,7 @@ val find_arithmetic_problem : val deallocate_stack_vars : Tenv.t -> Prop.normal Prop.t -> Pvar.t list -> Pvar.t list * Prop.normal Prop.t -(** Deallocate the stack variables in [pvars], and replace them by normal variables. - Return the list of stack variables whose address was still present after deallocation. *) +(** Deallocate the stack variables in [pvars], and replace them by normal variables. Return the list + of stack variables whose address was still present after deallocation. *) val find_equal_formal_path : Tenv.t -> Exp.t -> 'a Prop.t -> Exp.t option diff --git a/infer/src/biabduction/BiabductionConfig.mli b/infer/src/biabduction/BiabductionConfig.mli index f895cee2d..37bfda3c6 100644 --- a/infer/src/biabduction/BiabductionConfig.mli +++ b/infer/src/biabduction/BiabductionConfig.mli @@ -13,12 +13,12 @@ open! IStd val footprint : bool ref val run_in_footprint_mode : ('a -> 'b) -> 'a -> 'b -(** Call f x with footprint set to true. - Restore the initial value of footprint also in case of exception. *) +(** Call f x with footprint set to true. Restore the initial value of footprint also in case of + exception. *) val run_in_re_execution_mode : ('a -> 'b) -> 'a -> 'b -(** Call f x with footprint set to false. - Restore the initial value of footprint also in case of exception. *) +(** Call f x with footprint set to false. Restore the initial value of footprint also in case of + exception. *) (** {2 Global variables with initial values specified by command-line options} *) @@ -27,7 +27,6 @@ val abs_val : int ref val reset_abs_val : unit -> unit val run_with_abs_val_equal_zero : ('a -> 'b) -> 'a -> 'b -(** Call f x with abs_val set to zero. - Restore the initial value also in case of exception. *) +(** Call f x with abs_val set to zero. Restore the initial value also in case of exception. *) val allow_leak : bool ref diff --git a/infer/src/biabduction/BiabductionSummary.ml b/infer/src/biabduction/BiabductionSummary.ml index 48df17370..76b11c2e4 100644 --- a/infer/src/biabduction/BiabductionSummary.ml +++ b/infer/src/biabduction/BiabductionSummary.ml @@ -65,7 +65,8 @@ module Jprop = struct (** Get identifies of the jprop *) let get_id = function Prop (n, _) -> n | Joined (n, _, _, _) -> n - (** Print a list of joined props, the boolean indicates whether to print subcomponents of joined props *) + (** Print a list of joined props, the boolean indicates whether to print subcomponents of joined + props *) let pp_list pe ~shallow f jplist = let rec pp_seq_newline f = function | [] -> @@ -155,9 +156,10 @@ module Visitedset = struct end (** A spec consists of: - pre: a joined prop - post: a list of props with path - visited: a list of pairs (node_id, line) for the visited nodes *) + + - pre: a joined prop + - post: a list of props with path + - visited: a list of pairs (node_id, line) for the visited nodes *) type 'a spec = {pre: 'a Jprop.t; posts: ('a Prop.t * Paths.Path.t) list; visited: Visitedset.t} (** encapsulate type for normalized specs *) diff --git a/infer/src/biabduction/BiabductionSummary.mli b/infer/src/biabduction/BiabductionSummary.mli index f14000ad6..3cb12d033 100644 --- a/infer/src/biabduction/BiabductionSummary.mli +++ b/infer/src/biabduction/BiabductionSummary.mli @@ -27,9 +27,9 @@ module Jprop : sig val free_vars : Prop.normal t -> Ident.t Sequence.t val filter : ('a t -> 'b option) -> 'a t list -> 'b list - (** [jprop_filter filter joinedprops] applies [filter] to the elements - of [joindeprops] and applies it to the subparts if the result is - [None]. Returns the most absract results which pass [filter]. *) + (** [jprop_filter filter joinedprops] applies [filter] to the elements of [joindeprops] and + applies it to the subparts if the result is [None]. Returns the most absract results which + pass [filter]. *) val jprop_sub : Sil.subst -> Prop.normal t -> Prop.exposed t (** apply a substitution to a jprop *) @@ -45,9 +45,10 @@ module Visitedset : Caml.Set.S with type elt = Procdesc.Node.id * int list (** set of visited nodes: node id and list of lines of all the instructions *) (** A spec consists of: - pre: a joined prop - posts: a list of props with path - visited: a list of pairs (node_id, line) for the visited nodes *) + + - pre: a joined prop + - posts: a list of props with path + - visited: a list of pairs (node_id, line) for the visited nodes *) type 'a spec = {pre: 'a Jprop.t; posts: ('a Prop.t * Paths.Path.t) list; visited: Visitedset.t} (** encapsulate type for normalized specs *) diff --git a/infer/src/biabduction/Buckets.ml b/infer/src/biabduction/Buckets.ml index 527939b18..55e963233 100644 --- a/infer/src/biabduction/Buckets.ml +++ b/infer/src/biabduction/Buckets.ml @@ -15,8 +15,8 @@ module L = Logging let verbose = Config.trace_error -(** check if the error was reported inside a nested loop - the implementation is approximate: check if the last two visits to a loop were entering loops *) +(** check if the error was reported inside a nested loop the implementation is approximate: check if + the last two visits to a loop were entering loops *) let check_nested_loop path pos_opt = let trace_length = ref 0 in let loop_visits_log = ref [] in @@ -56,8 +56,8 @@ let check_nested_loop path pos_opt = in_nested_loop () -(** Check that we know where the value was last assigned, - and that there is a local access instruction at that line. **) +(** Check that we know where the value was last assigned, and that there is a local access + instruction at that line. **) let check_access access_opt de_opt = let find_bucket line_number null_case_flag = let find_formal_ids node = diff --git a/infer/src/biabduction/BuiltinDefn.mli b/infer/src/biabduction/BuiltinDefn.mli index 737cf4e0d..d71ca847b 100644 --- a/infer/src/biabduction/BuiltinDefn.mli +++ b/infer/src/biabduction/BuiltinDefn.mli @@ -11,6 +11,5 @@ include BUILTINS.S with type t = Builtin.registered (** Models for the builtin functions supported *) val init : unit -> unit -(** Clients of Builtin module should call this before Builtin module is used. - WARNING: builtins are not guaranteed to be registered with the Builtin module - until after init has been called. *) +(** Clients of Builtin module should call this before Builtin module is used. WARNING: builtins are + not guaranteed to be registered with the Builtin module until after init has been called. *) diff --git a/infer/src/biabduction/Dom.ml b/infer/src/biabduction/Dom.ml index 526fb2809..06643fa31 100644 --- a/infer/src/biabduction/Dom.ml +++ b/infer/src/biabduction/Dom.ml @@ -2147,16 +2147,16 @@ let pathset_join pname tenv (pset1 : Paths.PathSet.t) (pset2 : Paths.PathSet.t) res -(** - The meet operator does two things: - 1) makes the result logically stronger (just like additive conjunction) - 2) makes the result spatially larger (just like multiplicative conjunction). - Assuming that the meet operator forms a partial commutative monoid (soft assumption: it means - that the results are more predictable), try to combine every element of plist with any other element. - Return a list of the same lenght, with each element maximally combined. The algorithm is quadratic. - The operation is dependent on the order in which elements are combined; there is a straightforward - order - independent algorithm but it is exponential. -*) +(** The meet operator does two things: + + + makes the result logically stronger (just like additive conjunction) + + makes the result spatially larger (just like multiplicative conjunction). + + Assuming that the meet operator forms a partial commutative monoid (soft assumption: it means + that the results are more predictable), try to combine every element of plist with any other + element. Return a list of the same lenght, with each element maximally combined. The algorithm + is quadratic. The operation is dependent on the order in which elements are combined; there is a + straightforward order - independent algorithm but it is exponential. *) let proplist_meet_generate tenv plist = let props_done = ref Propset.empty in let combine p (porig, pcombined) = diff --git a/infer/src/biabduction/Dom.mli b/infer/src/biabduction/Dom.mli index fde81d16c..308cf95ee 100644 --- a/infer/src/biabduction/Dom.mli +++ b/infer/src/biabduction/Dom.mli @@ -31,7 +31,6 @@ val pathset_collapse_impl : Typ.Procname.t -> Tenv.t -> Paths.PathSet.t -> Paths (** {2 Meet Operators} *) val propset_meet_generate_pre : Tenv.t -> Propset.t -> Prop.normal Prop.t list -(** [propset_meet_generate_pre] generates new symbolic heaps (i.e., props) - by applying the partial meet operator, adds the generated heaps - to the argument propset, and returns the resulting propset. This function - is tuned for combining preconditions. *) +(** [propset_meet_generate_pre] generates new symbolic heaps (i.e., props) by applying the partial + meet operator, adds the generated heaps to the argument propset, and returns the resulting + propset. This function is tuned for combining preconditions. *) diff --git a/infer/src/biabduction/Match.ml b/infer/src/biabduction/Match.ml index 877f8704c..faa432d57 100644 --- a/infer/src/biabduction/Match.ml +++ b/infer/src/biabduction/Match.ml @@ -14,13 +14,12 @@ module L = Logging let mem_idlist i l = List.exists ~f:(Ident.equal i) l -(** Type for a hpred pattern. flag=false means that the implication - between hpreds is not considered, and flag = true means that it is - considered during pattern matching *) +(** Type for a hpred pattern. flag=false means that the implication between hpreds is not + considered, and flag = true means that it is considered during pattern matching *) type hpred_pat = {hpred: Sil.hpred; flag: bool} -(** Checks [e1 = e2[sub ++ sub']] for some [sub'] with [dom(sub') subseteq vars]. - Returns [(sub ++ sub', vars - dom(sub'))]. *) +(** Checks [e1 = e2\[sub ++ sub'\]] for some [sub'] with [dom(sub') subseteq vars]. Returns + [(sub ++ sub', vars - dom(sub'))]. *) let rec exp_match e1 sub vars e2 : (Sil.subst * Ident.t list) option = let check_equal sub vars e1 e2 = let e2_inst = Sil.exp_sub sub e2 in @@ -95,10 +94,9 @@ let exp_list_match es1 sub vars es2 = None -(** Checks [sexp1 = sexp2[sub ++ sub']] for some [sub'] with - [dom(sub') subseteq vars]. Returns [(sub ++ sub', vars - dom(sub'))]. - WARNING: This function does not consider the fact that the analyzer - sometimes forgets fields of hpred. It can possibly cause a problem. *) +(** Checks [sexp1 = sexp2\[sub ++ sub'\]] for some [sub'] with [dom(sub') subseteq vars]. Returns + [(sub ++ sub', vars - dom(sub'))]. WARNING: This function does not consider the fact that the + analyzer sometimes forgets fields of hpred. It can possibly cause a problem. *) let rec strexp_match sexp1 sub vars sexp2 : (Sil.subst * Ident.t list) option = match (sexp1, sexp2) with | Sil.Eexp (exp1, _), Sil.Eexp (exp2, _) -> @@ -117,8 +115,8 @@ let rec strexp_match sexp1 sub vars sexp2 : (Sil.subst * Ident.t list) option = None ) -(** Checks [fsel1 = fsel2[sub ++ sub']] for some [sub'] with - [dom(sub') subseteq vars]. Returns [(sub ++ sub', vars - dom(sub'))]. *) +(** Checks [fsel1 = fsel2\[sub ++ sub'\]] for some [sub'] with [dom(sub') subseteq vars]. Returns + [(sub ++ sub', vars - dom(sub'))]. *) and fsel_match fsel1 sub vars fsel2 = match (fsel1, fsel2) with | [], [] -> @@ -141,8 +139,8 @@ and fsel_match fsel1 sub vars fsel2 = else None -(** Checks [isel1 = isel2[sub ++ sub']] for some [sub'] with - [dom(sub') subseteq vars]. Returns [(sub ++ sub', vars - dom(sub'))]. *) +(** Checks [isel1 = isel2\[sub ++ sub'\]] for some [sub'] with [dom(sub') subseteq vars]. Returns + [(sub ++ sub', vars - dom(sub'))]. *) and isel_match isel1 sub vars isel2 = match (isel1, isel2) with | [], [] -> @@ -543,11 +541,11 @@ and hpara_dll_match_with_impl tenv impl_ok para1 para2 : bool = hpara_common_match_with_impl tenv impl_ok ids1 para1.Sil.body_dll eids2 ids2 para2.Sil.body_dll -(** [prop_match_with_impl p condition vars hpat hpats] - returns [(subst, p_leftover)] such that +(** [prop_match_with_impl p condition vars hpat hpats] returns [(subst, p_leftover)] such that + + [dom(subst) = vars] - + [p |- (hpat.hpred * hpats.hpred)[subst] * p_leftover]. - Using the flag [field], we can control the strength of |-. *) + + [p |- (hpat.hpred * hpats.hpred)\[subst\] * p_leftover]. Using the flag [field], we can + control the strength of |-. *) let prop_match_with_impl tenv p condition vars hpat hpats = prop_match_with_impl_sub tenv p condition Sil.sub_empty vars hpat hpats @@ -673,11 +671,10 @@ let hpara_dll_iso tenv para1 para2 = && hpara_dll_match_with_impl tenv false para2 para1 -(** [generic_find_partial_iso] finds isomorphic subsigmas of [sigma_todo]. - The function [update] is used to get rid of hpred pairs from [sigma_todo]. - [sigma_corres] records the isormophic copies discovered so far. The first - parameter determines how much flexibility we will allow during this partial - isomorphism finding. *) +(** [generic_find_partial_iso] finds isomorphic subsigmas of [sigma_todo]. The function [update] is + used to get rid of hpred pairs from [sigma_todo]. [sigma_corres] records the isormophic copies + discovered so far. The first parameter determines how much flexibility we will allow during this + partial isomorphism finding. *) let rec generic_find_partial_iso tenv mode update corres sigma_corres todos sigma_todo = match todos with | [] -> @@ -780,12 +777,11 @@ let rec generic_find_partial_iso tenv mode update corres sigma_corres todos sigm None -(** [find_partial_iso] finds disjoint isomorphic sub-sigmas inside a given sigma. - The function returns a partial iso and three sigmas. The first sigma is the first - copy of the two isomorphic sigmas, so it uses expressions in the domain of - the returned isomorphism. The second is the second copy of the two isomorphic sigmas, - and it uses expressions in the range of the isomorphism. The third is the unused - part of the input sigma. *) +(** [find_partial_iso] finds disjoint isomorphic sub-sigmas inside a given sigma. The function + returns a partial iso and three sigmas. The first sigma is the first copy of the two isomorphic + sigmas, so it uses expressions in the domain of the returned isomorphism. The second is the + second copy of the two isomorphic sigmas, and it uses expressions in the range of the + isomorphism. The third is the unused part of the input sigma. *) let find_partial_iso tenv eq corres todos sigma = let update e1 e2 sigma0 = let hpredo1, sigma0_no_e1 = sigma_remove_hpred eq sigma0 e1 in @@ -811,13 +807,11 @@ let hpred_lift_to_pe hpred = (** Lift the kind of list segment predicates to PE in a given sigma *) let sigma_lift_to_pe sigma = List.map ~f:hpred_lift_to_pe sigma -(** [generic_para_create] takes a correspondence, and a sigma - and a list of expressions for the first part of this - correspondence. Then, it creates a renaming of expressions - in the domain of the given correspondence, and applies this - renaming to the given sigma. The result is a tuple of the renaming, - the renamed sigma, ids for existentially quantified expressions, - ids for shared expressions, and shared expressions. *) +(** [generic_para_create] takes a correspondence, and a sigma and a list of expressions for the + first part of this correspondence. Then, it creates a renaming of expressions in the domain of + the given correspondence, and applies this renaming to the given sigma. The result is a tuple of + the renaming, the renamed sigma, ids for existentially quantified expressions, ids for shared + expressions, and shared expressions. *) let generic_para_create tenv corres sigma1 elist1 = let corres_ids = let not_same_consts = function @@ -847,9 +841,8 @@ let generic_para_create tenv corres sigma1 elist1 = (renaming, body, ids_exists, ids_shared, es_shared) -(** [hpara_create] takes a correspondence, and a sigma, a root - and a next for the first part of this correspondence. Then, it creates a - hpara and discovers a list of shared expressions that are +(** [hpara_create] takes a correspondence, and a sigma, a root and a next for the first part of this + correspondence. Then, it creates a hpara and discovers a list of shared expressions that are passed as arguments to hpara. Both of them are returned as a result. *) let hpara_create tenv corres sigma1 root1 next1 = let renaming, body, ids_exists, ids_shared, es_shared = @@ -867,10 +860,9 @@ let hpara_create tenv corres sigma1 root1 next1 = (hpara, es_shared) -(** [hpara_dll_create] takes a correspondence, and a sigma, a root, - a blink and a flink for the first part of this correspondence. Then, it creates a - hpara_dll and discovers a list of shared expressions that are - passed as arguments to hpara. Both of them are returned as a result. *) +(** [hpara_dll_create] takes a correspondence, and a sigma, a root, a blink and a flink for the + first part of this correspondence. Then, it creates a hpara_dll and discovers a list of shared + expressions that are passed as arguments to hpara. Both of them are returned as a result. *) let hpara_dll_create tenv corres sigma1 root1 blink1 flink1 = let renaming, body, ids_exists, ids_shared, es_shared = generic_para_create tenv corres sigma1 [root1; blink1; flink1] diff --git a/infer/src/biabduction/Match.mli b/infer/src/biabduction/Match.mli index 12e9f7625..fa6009412 100644 --- a/infer/src/biabduction/Match.mli +++ b/infer/src/biabduction/Match.mli @@ -10,9 +10,10 @@ open! IStd (** Implementation of "Smart" Pattern Matching for higher order singly-linked list predicate. - Used for detecting on a given program if some data scructures are matching some predefined higher-order list predicates. When it is the case, these predicates can be used as possible candidates for abstracting the data-structures. - See {{: http://dx.doi.org/10.1007/978-3-540-73368-3_22 } CAV 2007 } for the therory involved. -*) + Used for detecting on a given program if some data scructures are matching some predefined + higher-order list predicates. When it is the case, these predicates can be used as possible + candidates for abstracting the data-structures. See + {{:http://dx.doi.org/10.1007/978-3-540-73368-3_22} CAV 2007} for the therory involved. *) (* TODO: missing documentation *) @@ -20,9 +21,8 @@ val hpara_match_with_impl : Tenv.t -> bool -> Sil.hpara -> Sil.hpara -> bool val hpara_dll_match_with_impl : Tenv.t -> bool -> Sil.hpara_dll -> Sil.hpara_dll -> bool -(** Type for a hpred pattern. [flag=false] means that the implication - between hpreds is not considered, and [flag = true] means that it is - considered during pattern matching. *) +(** Type for a hpred pattern. [flag=false] means that the implication between hpreds is not + considered, and [flag = true] means that it is considered during pattern matching. *) type hpred_pat = {hpred: Sil.hpred; flag: bool} type sidecondition = Prop.normal Prop.t -> Sil.subst -> bool @@ -35,10 +35,11 @@ val prop_match_with_impl : -> hpred_pat -> hpred_pat list -> (Sil.subst * Prop.normal Prop.t) option -(** [prop_match_with_impl p condition vars hpat hpats] - returns [(subst, p_leftover)] such that - 1) [dom(subst) = vars] - 2) [p |- (hpat.hpred * hpats.hpred)[subst] * p_leftover]. +(** [prop_match_with_impl p condition vars hpat hpats] returns [(subst, p_leftover)] such that + + + [dom(subst) = vars] + + [p |- (hpat.hpred * hpats.hpred)\[subst\] * p_leftover]. + Using the flag [field], we can control the strength of |-. *) val find_partial_iso : @@ -48,13 +49,11 @@ val find_partial_iso : -> (Exp.t * Exp.t) list -> Sil.hpred list -> ((Exp.t * Exp.t) list * Sil.hpred list * Sil.hpred list * Sil.hpred list) option -(** [find_partial_iso] finds disjoint isomorphic sub-sigmas inside a given sigma. - The first argument is an equality checker. - The function returns a partial iso and three sigmas. The first sigma is the first - copy of the two isomorphic sigmas, so it uses expressions in the domain of - the returned isomorphism. The second is the second copy of the two isomorphic sigmas, - and it uses expressions in the range of the isomorphism. The third is the unused - part of the input sigma. *) +(** [find_partial_iso] finds disjoint isomorphic sub-sigmas inside a given sigma. The first argument + is an equality checker. The function returns a partial iso and three sigmas. The first sigma is + the first copy of the two isomorphic sigmas, so it uses expressions in the domain of the + returned isomorphism. The second is the second copy of the two isomorphic sigmas, and it uses + expressions in the range of the isomorphism. The third is the unused part of the input sigma. *) val hpara_iso : Tenv.t -> Sil.hpara -> Sil.hpara -> bool (** [hpara_iso] soundly checks whether two hparas are isomorphic. *) @@ -64,9 +63,8 @@ val hpara_dll_iso : Tenv.t -> Sil.hpara_dll -> Sil.hpara_dll -> bool val hpara_create : Tenv.t -> (Exp.t * Exp.t) list -> Sil.hpred list -> Exp.t -> Exp.t -> Sil.hpara * Exp.t list -(** [hpara_create] takes a correspondence, and a sigma, a root - and a next for the first part of this correspondence. Then, it creates a - hpara and discovers a list of shared expressions that are +(** [hpara_create] takes a correspondence, and a sigma, a root and a next for the first part of this + correspondence. Then, it creates a hpara and discovers a list of shared expressions that are passed as arguments to hpara. Both of them are returned as a result. *) val hpara_dll_create : @@ -77,7 +75,6 @@ val hpara_dll_create : -> Exp.t -> Exp.t -> Sil.hpara_dll * Exp.t list -(** [hpara_dll_create] takes a correspondence, and a sigma, a root, - a blink and a flink for the first part of this correspondence. Then, - it creates a hpara_dll and discovers a list of shared expressions that are - passed as arguments to hpara. Both of them are returned as a result. *) +(** [hpara_dll_create] takes a correspondence, and a sigma, a root, a blink and a flink for the + first part of this correspondence. Then, it creates a hpara_dll and discovers a list of shared + expressions that are passed as arguments to hpara. Both of them are returned as a result. *) diff --git a/infer/src/biabduction/Paths.ml b/infer/src/biabduction/Paths.ml index 876c5ea98..8060924e6 100644 --- a/infer/src/biabduction/Paths.ml +++ b/infer/src/biabduction/Paths.ml @@ -21,10 +21,12 @@ module Path : sig type session = int val add_call : bool -> t -> Typ.Procname.t -> t -> t - (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) + (** 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 - (** add a call to a procname that's had to be skipped, along with the reason and the location of the procname when known *) + (** add a call to a procname that's had to be skipped, along with the reason and the location of + the procname when known *) val contains_position : t -> PredSymb.path_pos -> bool (** check wether the path contains the given position *) @@ -36,10 +38,12 @@ module Path : sig (** return the current node of the path *) val extend : Procdesc.Node.t -> Typ.Name.t option -> session -> t -> t - (** extend a path with a new node reached from the given session, with an optional string for exceptions *) + (** extend a path with a new node reached from the given session, with an optional string for + exceptions *) val add_description : t -> string -> t - (** extend a path with a new node reached from the given session, with an optional string for exceptions *) + (** extend a path with a new node reached from the given session, with an optional string for + exceptions *) val fold_all_nodes_nocalls : (t, Procdesc.Node.t, 'accum) Container.fold (** fold over each node in the path, excluding calls, once *) @@ -87,8 +91,8 @@ end = struct (* in particular: a new traversal cannot be initiated during an existing traversal *) | Pstart of Procdesc.Node.t * stats_ (** start node *) | Pnode of Procdesc.Node.t * Typ.Name.t option * session * t * stats_ * string_option_ - (** we got to [node] from last [session] perhaps propagating exception [exn_opt], - and continue with [path]. *) + (** we got to [node] from last [session] perhaps propagating exception [exn_opt], and + continue with [path]. *) | Pjoin of t * t * stats_ (** join of two paths *) | Pcall of t * procname_ * path_exec_ * stats_ (** add a sub-path originating from a call *) [@@deriving compare] @@ -178,11 +182,11 @@ end = struct (** Iterate [f] over the path and compute the stats, assuming the invariant: all the stats are - dummy. Function [f] (typically with side-effects) is applied once to every node, and + dummy. Function [f] (typically with side-effects) is applied once to every node, and max_length in the stats is the length of a longest sequence of nodes in the path where [f] - returned [true] on at least one node. max_length is 0 if the path was visited but no node - satisfying [f] was found. Assumes that the invariant holds beforehand, and ensures that all - the stats are computed afterwards. Since this breaks the invariant, it must be followed by + returned [true] on at least one node. max_length is 0 if the path was visited but no node + satisfying [f] was found. Assumes that the invariant holds beforehand, and ensures that all + the stats are computed afterwards. Since this breaks the invariant, it must be followed by reset_stats. *) let rec compute_stats do_calls (f : Procdesc.Node.t -> bool) = let nodes_found stats = stats.max_length > 0 in @@ -266,10 +270,9 @@ end = struct !found - (** iterate over the longest sequence belonging to the path, - restricting to those where [filter] holds of some element. - If a node is reached via an exception, - pass the exception information to [f] on the previous node *) + (** iterate over the longest sequence belonging to the path, restricting to those where [filter] + holds of some element. If a node is reached via an exception, pass the exception information + to [f] on the previous node *) let iter_shortest_sequence_filter (f : int -> t -> int -> Typ.Name.t option -> unit) (filter : Procdesc.Node.t -> bool) (path : t) : unit = let rec doit level session path prev_exn_opt = @@ -299,11 +302,10 @@ end = struct Invariant.reset_stats path - (** iterate over the shortest sequence belonging to the path, - restricting to those containing the given position if given. - Do not iterate past the last occurrence of the given position. - [f level path session exn_opt] is passed the current nesting [level] and [path] - and previous [session] and possible exception [exn_opt] *) + (** iterate over the shortest sequence belonging to the path, restricting to those containing the + given position if given. Do not iterate past the last occurrence of the given position. + [f level path session exn_opt] is passed the current nesting [level] and [path] and previous + [session] and possible exception [exn_opt] *) let iter_shortest_sequence (f : int -> t -> int -> Typ.Name.t option -> unit) (pos_opt : PredSymb.path_pos option) (path : t) : unit = let filter node = @@ -542,7 +544,8 @@ module PathSet : sig type t val add_renamed_prop : Prop.normal Prop.t -> Path.t -> t -> t - (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was called on the prop *) + (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was + called on the prop *) val diff : t -> t -> t (** difference between two pathsets *) @@ -560,7 +563,8 @@ module PathSet : sig (** fold over a pathset *) val from_renamed_list : (Prop.normal Prop.t * Path.t) list -> t - (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was called on the list *) + (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was + called on the list *) val is_empty : t -> bool (** check whether the pathset is empty *) @@ -572,7 +576,8 @@ module PathSet : sig (** map over the prop component of a pathset *) val map_option : (Prop.normal Prop.t -> Prop.normal Prop.t option) -> t -> t - (** map over the prop component of a pathset using a partial function; elements mapped to None are discarded *) + (** map over the prop component of a pathset using a partial function; elements mapped to None are + discarded *) val partition : (Prop.normal Prop.t -> bool) -> t -> t * t (** partition a pathset on the prop component *) @@ -618,7 +623,7 @@ end = struct (** It's the caller's responsibility to ensure that [Prop.prop_rename_primed_footprint_vars] was - called on the prop *) + called on the prop *) let add_renamed_prop (p : Prop.normal Prop.t) (path : Path.t) (ps : t) : t = let path_new = try @@ -686,7 +691,8 @@ end = struct iter f ps - (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was called on the list *) + (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was + called on the list *) let from_renamed_list (pl : ('a Prop.t * Path.t) list) : t = List.fold ~f:(fun ps (p, pa) -> add_renamed_prop p pa ps) ~init:empty pl end diff --git a/infer/src/biabduction/Paths.mli b/infer/src/biabduction/Paths.mli index 22d71ab42..e6dd5b115 100644 --- a/infer/src/biabduction/Paths.mli +++ b/infer/src/biabduction/Paths.mli @@ -17,10 +17,12 @@ module Path : sig type session = int val add_call : bool -> t -> Typ.Procname.t -> t -> t - (** add a call with its sub-path, the boolean indicates whether the subtrace for the procedure should be included *) + (** 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 - (** add a call to a procname that's had to be skipped, along with the reason and the location of the procname when known *) + (** add a call to a procname that's had to be skipped, along with the reason and the location of + the procname when known *) val contains_position : t -> PredSymb.path_pos -> bool (** check wether the path contains the given position *) @@ -32,7 +34,8 @@ module Path : sig (** return the current node of the path *) val extend : Procdesc.Node.t -> Typ.Name.t option -> session -> t -> t - (** extend a path with a new node reached from the given session, with an optional string for exceptions *) + (** extend a path with a new node reached from the given session, with an optional string for + exceptions *) val add_description : t -> string -> t @@ -41,11 +44,10 @@ module Path : sig val iter_shortest_sequence : (int -> t -> int -> Typ.Name.t option -> unit) -> PredSymb.path_pos option -> t -> unit - (** iterate over the shortest sequence belonging to the path, - restricting to those containing the given position if given. - Do not iterate past the last occurrence of the given position. - [f level path session exn_opt] is passed the current nesting [level] and [path] - and previous [session] and possible exception [exn_opt] *) + (** iterate over the shortest sequence belonging to the path, restricting to those containing the + given position if given. Do not iterate past the last occurrence of the given position. + [f level path session exn_opt] is passed the current nesting [level] and [path] and previous + [session] and possible exception [exn_opt] *) val join : t -> t -> t (** join two paths *) @@ -59,7 +61,8 @@ module PathSet : sig type t val add_renamed_prop : Prop.normal Prop.t -> Path.t -> t -> t - (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was called on the prop *) + (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was + called on the prop *) val diff : t -> t -> t (** difference between two pathsets *) @@ -77,7 +80,8 @@ module PathSet : sig (** fold over a pathset *) val from_renamed_list : (Prop.normal Prop.t * Path.t) list -> t - (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was called on the list *) + (** It's the caller's resposibility to ensure that Prop.prop_rename_primed_footprint_vars was + called on the list *) val is_empty : t -> bool (** check whether the pathset is empty *) @@ -89,7 +93,8 @@ module PathSet : sig (** map over the prop component of a pathset. *) val map_option : (Prop.normal Prop.t -> Prop.normal Prop.t option) -> t -> t - (** map over the prop component of a pathset using a partial function; elements mapped to None are discarded *) + (** map over the prop component of a pathset using a partial function; elements mapped to None are + discarded *) val partition : (Prop.normal Prop.t -> bool) -> t -> t * t (** partition a pathset on the prop component *) diff --git a/infer/src/biabduction/Prop.ml b/infer/src/biabduction/Prop.ml index 59c0e955e..a49c99d88 100644 --- a/infer/src/biabduction/Prop.ml +++ b/infer/src/biabduction/Prop.ml @@ -59,13 +59,11 @@ module Core : sig val unsafe_cast_to_sorted : exposed t -> sorted t end = struct - (** A proposition. The following invariants are mantained. [sub] is of - the form id1 = e1 ... idn = en where: the id's are distinct and do not - occur in the e's nor in [pi] or [sigma]; the id's are in sorted - order; the id's are not existentials; if idn = yn (for yn not - existential) then idn < yn in the order on ident's. [pi] is sorted - and normalized, and does not contain x = e. [sigma] is sorted and - normalized. *) + (** A proposition. The following invariants are mantained. [sub] is of the form id1 = e1 ... idn = + en where: the id's are distinct and do not occur in the e's nor in [pi] or [sigma]; the id's + are in sorted order; the id's are not existentials; if idn = yn (for yn not existential) then + idn < yn in the order on ident's. [pi] is sorted and normalized, and does not contain x = e. + [sigma] is sorted and normalized. *) type 'a t = { sigma: sigma (** spatial part *) ; sub: Sil.subst (** substitution *) @@ -160,8 +158,8 @@ let d_pi (pi : pi) = L.d_pp_with_pe pp_pi pi (** Pretty print a sigma. *) let pp_sigma pe = Pp.semicolon_seq ~print_env:pe (Sil.pp_hpred pe) -(** Split sigma into stack and nonstack parts. - The boolean indicates whether the stack should only include local variales. *) +(** Split sigma into stack and nonstack parts. The boolean indicates whether the stack should only + include local variales. *) let sigma_get_stack_nonstack only_local_vars sigma = let hpred_is_stack_var = function | Sil.Hpointsto (Lvar pvar, _, _) -> @@ -527,9 +525,9 @@ let sigma_get_unsigned_exps sigma = List.iter ~f:do_hpred sigma ; !uexps -(** Collapse consecutive indices that should be added. For instance, - this function reduces [x[1][1]] to [x[2]]. The [typ] argument is used - to ensure the soundness of this collapsing. *) +(** Collapse consecutive indices that should be added. For instance, this function reduces + [x\[1\]\[1\]] to [x\[2\]]. The [typ] argument is used to ensure the soundness of this + collapsing. *) let exp_collapse_consecutive_indices_prop (typ : Typ.t) exp = let typ_is_base (typ1 : Typ.t) = match typ1.desc with Tint _ | Tfloat _ | Tstruct _ | Tvoid | Tfun -> true | _ -> false @@ -576,13 +574,12 @@ let prop_sigma_star (p : 'a t) (sigma : sigma) : exposed t = (* Module for normalization *) module Normalize = struct - (** Eliminates all empty lsegs from sigma, and collect equalities - The empty lsegs include - (a) "lseg_pe para 0 e elist", - (b) "dllseg_pe para iF oB oF iB elist" with iF = 0 or iB = 0, - (c) "lseg_pe para e1 e2 elist" and the rest of sigma contains the "cell" e1, - (d) "dllseg_pe para iF oB oF iB elist" and the rest of sigma contains - cell iF or iB. *) + (** Eliminates all empty lsegs from sigma, and collect equalities The empty lsegs include + + - "lseg_pe para 0 e elist", + - "dllseg_pe para iF oB oF iB elist" with iF = 0 or iB = 0, + - "lseg_pe para e1 e2 elist" and the rest of sigma contains the "cell" e1, + - "dllseg_pe para iF oB oF iB elist" and the rest of sigma contains cell iF or iB. *) let sigma_remove_emptylseg sigma = let alloc_set = let rec f_alloc set (sigma1 : sigma) = @@ -1210,9 +1207,8 @@ module Normalize = struct a - (** Normalize an atom. - We keep the convention that inequalities with constants - are only of the form [e <= n] and [n < e]. *) + (** Normalize an atom. We keep the convention that inequalities with constants are only of the + form [e <= n] and [n < e]. *) let atom_normalize tenv sub a0 = let a = Sil.atom_sub sub a0 in let rec normalize_eq (eq : Exp.t * Exp.t) = @@ -1372,9 +1368,10 @@ module Normalize = struct (** Captured variables in the closures consist of expressions and variables, with the implicit - assumption that these two values are in the relation &var -> id. However, after bi-abduction, etc. - the constraint may not hold anymore, so this function ensures that it is always kept. - In particular, we have &var -> id iff we also have the pair (id, var) as part of captured variables. *) + assumption that these two values are in the relation &var -> id. However, after bi-abduction, + etc. the constraint may not hold anymore, so this function ensures that it is always kept. In + particular, we have &var -> id iff we also have the pair (id, var) as part of captured + variables. *) let make_captured_in_closures_consistent sigma = let open Sil in let find_correct_captured captured = @@ -1605,8 +1602,8 @@ module Normalize = struct (ineq_list', nonineq_list') - (** Normalization of pi. - The normalization filters out obviously - true disequalities, such as e <> e + 1. *) + (** Normalization of pi. The normalization filters out obviously - true disequalities, such as e + <> e + 1. *) let pi_normalize tenv sub sigma pi0 = let pi = List.map ~f:(atom_normalize tenv sub) pi0 in let ineq_list, nonineq_list = pi_tighten_ineq tenv pi in @@ -1640,8 +1637,8 @@ module Normalize = struct if equal_pi pi0 pi'' then pi0 else pi'' - (** normalize the footprint part, and rename any primed vars - in the footprint with fresh footprint vars *) + (** normalize the footprint part, and rename any primed vars in the footprint with fresh footprint + vars *) let footprint_normalize tenv prop = let nsigma = sigma_normalize tenv Sil.sub_empty prop.sigma_fp in let npi = pi_normalize tenv Sil.sub_empty nsigma prop.pi_fp in @@ -1809,8 +1806,8 @@ let mk_dllseg tenv k para exp_iF exp_oB exp_oF exp_iB exps_shared : Sil.hpred = Hdllseg (k, npara, exp_iF, exp_oB, exp_oF, exp_iB, exps_shared) -(** Construct a points-to predicate for a single program variable. - If [expand_structs] is [Fld_init], initialize the fields of structs with fresh variables. *) +(** Construct a points-to predicate for a single program variable. If [expand_structs] is + [Fld_init], initialize the fields of structs with fresh variables. *) let mk_ptsto_lvar tenv expand_structs inst ((pvar : Pvar.t), texp, expo) : Sil.hpred = Normalize.mk_ptsto_exp tenv expand_structs (Lvar pvar, texp, expo) inst @@ -1834,9 +1831,8 @@ let prop_reset_inst inst_map prop = (** {1 Functions for transforming footprints into propositions.} *) -(** The ones used for abstraction add/remove local stacks in order to - stop the firing of some abstraction rules. The other usual - transforation functions do not use this hack. *) +(** The ones used for abstraction add/remove local stacks in order to stop the firing of some + abstraction rules. The other usual transforation functions do not use this hack. *) (** Extract the footprint and return it as a prop *) let extract_footprint p = set prop_emp ~pi:p.pi_fp ~sigma:p.sigma_fp @@ -2239,7 +2235,7 @@ let prop_ren_sub tenv (ren_sub : Sil.subst) (prop : normal t) : normal t = (** Existentially quantify the [ids] in [prop]. [ids] should not contain any primed variables. If - [ids_queue] is passed then the function uses it instead of [ids] for membership tests. *) + [ids_queue] is passed then the function uses it instead of [ids] for membership tests. *) let exist_quantify tenv ?ids_queue ids (prop : normal t) : normal t = assert (not (List.exists ~f:Ident.is_primed ids)) ; (* sanity check *) @@ -2349,15 +2345,14 @@ let prop_iter_to_prop tenv iter = ~init:prop iter.pit_newpi -(** Add an atom to the pi part of prop iter. The - first parameter records whether it is done - during footprint or during re - execution. *) +(** Add an atom to the pi part of prop iter. The first parameter records whether it is done during + footprint or during re - execution. *) let prop_iter_add_atom footprint iter atom = {iter with pit_newpi= (footprint, atom) :: iter.pit_newpi} -(** Remove the current element of the iterator, and return the prop - associated to the resulting iterator *) +(** Remove the current element of the iterator, and return the prop associated to the resulting + iterator *) let prop_iter_remove_curr_then_to_prop tenv iter : normal t = let sigma = List.rev_append iter.pit_old iter.pit_new in let normalized_sigma = Normalize.sigma_normalize tenv iter.pit_sub sigma in @@ -2588,8 +2583,7 @@ end = struct !size - (** Compute a size value for the prop, which indicates its - complexity *) + (** Compute a size value for the prop, which indicates its complexity *) let prop_size p = let size_current = sigma_size p.sigma in let size_footprint = sigma_size p.sigma_fp in diff --git a/infer/src/biabduction/Prop.mli b/infer/src/biabduction/Prop.mli index e489a8b75..08b19aa1e 100644 --- a/infer/src/biabduction/Prop.mli +++ b/infer/src/biabduction/Prop.mli @@ -65,8 +65,8 @@ val d_pi_sigma : pi -> sigma -> unit (** Dump a pi and a sigma *) val sigma_get_stack_nonstack : bool -> sigma -> sigma * sigma -(** Split sigma into stack and nonstack parts. - The boolean indicates whether the stack should only include local variales. *) +(** Split sigma into stack and nonstack parts. The boolean indicates whether the stack should only + include local variales. *) val prop_update_obj_sub : Pp.env -> 'a t -> Pp.env (** Update the object substitution given the stack variables in the prop *) @@ -111,9 +111,8 @@ val prop_expmap : (Exp.t -> Exp.t) -> 'a t -> exposed t (** Apply the substitution to all the expressions in the prop. *) val sigma_replace_exp : Tenv.t -> (Exp.t * Exp.t) list -> hpred list -> hpred list -(** Relaces all expressions in the [hpred list] using the first argument. - Assume that the first parameter defines a partial function. - No expressions inside hpara are replaced. *) +(** Relaces all expressions in the [hpred list] using the first argument. Assume that the first + parameter defines a partial function. No expressions inside hpara are replaced. *) (** {2 Normalization} *) @@ -130,7 +129,7 @@ val atom_const_lt_exp : Sil.atom -> (IntLit.t * Exp.t) option (** If the atom is [n Tenv.t -> 'a t -> Exp.t -> Exp.t -(** Normalize [exp] using the pure part of [prop]. Later, we should change this such that the +(** Normalize [exp] using the pure part of [prop]. Later, we should change this such that the normalization exposes offsets of [exp] as much as possible. If [destructive] is true then normalize more aggressively, which may lose some useful structure @@ -140,13 +139,13 @@ val exp_normalize_noabs : Tenv.t -> Sil.subst -> Exp.t -> Exp.t (** Normalize the expression without abstracting complex subexpressions *) val exp_collapse_consecutive_indices_prop : Typ.t -> Exp.t -> Exp.t -(** Collapse consecutive indices that should be added. For instance, - this function reduces [x[1][1]] to [x[2]]. The [typ] argument is used - to ensure the soundness of this collapsing. *) +(** Collapse consecutive indices that should be added. For instance, this function reduces + [x\[1\]\[1\]] to [x\[2\]]. The [typ] argument is used to ensure the soundness of this + collapsing. *) val lexp_normalize_prop : Tenv.t -> 'a t -> Exp.t -> Exp.t -(** Normalize [exp] used for the address of a heap cell. - This normalization does not combine two offsets inside [exp]. *) +(** Normalize [exp] used for the address of a heap cell. This normalization does not combine two + offsets inside [exp]. *) val atom_normalize_prop : Tenv.t -> 'a t -> atom -> atom @@ -194,8 +193,8 @@ val mk_ptsto_exp : Tenv.t -> struct_init_mode -> Exp.t * Exp.t * Exp.t option -> base for fresh identifiers. *) val mk_ptsto_lvar : Tenv.t -> struct_init_mode -> Sil.inst -> Pvar.t * Exp.t * Exp.t option -> hpred -(** Construct a points-to predicate for a single program variable. - If [expand_structs] is true, initialize the fields of structs with fresh variables. *) +(** Construct a points-to predicate for a single program variable. If [expand_structs] is true, + initialize the fields of structs with fresh variables. *) val mk_lseg : Tenv.t -> lseg_kind -> hpara -> Exp.t -> Exp.t -> Exp.t list -> hpred (** Construct a lseg predicate *) @@ -274,13 +273,12 @@ val prop_iter_to_prop : Tenv.t -> 'a prop_iter -> normal t (** Return the prop associated to the iterator. *) val prop_iter_add_atom : bool -> 'a prop_iter -> atom -> 'a prop_iter -(** Add an atom to the pi part of prop iter. The - first parameter records whether it is done - during footprint or during re - execution. *) +(** Add an atom to the pi part of prop iter. The first parameter records whether it is done during + footprint or during re - execution. *) val prop_iter_remove_curr_then_to_prop : Tenv.t -> 'a prop_iter -> normal t -(** Remove the current element from the iterator, and return the prop - associated to the resulting iterator. *) +(** Remove the current element from the iterator, and return the prop associated to the resulting + iterator. *) val prop_iter_current : Tenv.t -> 'a prop_iter -> hpred * 'a (** Return the current hpred and state. *) diff --git a/infer/src/biabduction/PropUtil.ml b/infer/src/biabduction/PropUtil.ml index 7fd4ae532..2b73cb2f3 100644 --- a/infer/src/biabduction/PropUtil.ml +++ b/infer/src/biabduction/PropUtil.ml @@ -169,8 +169,8 @@ let remove_locals_ret tenv (curr_f : Procdesc.t) p = snd (remove_locals tenv curr_f (remove_ret tenv curr_f p)) -(** Remove locals and formal parameters from the prop. - Return the list of stack variables whose address was still present after deallocation. *) +(** Remove locals and formal parameters from the prop. Return the list of stack variables whose + address was still present after deallocation. *) let remove_locals_formals tenv (curr_f : Procdesc.t) p = let pvars1, p1 = remove_locals tenv curr_f p in let pvars2, p2 = remove_formals tenv curr_f p1 in diff --git a/infer/src/biabduction/PropUtil.mli b/infer/src/biabduction/PropUtil.mli index 6986717d8..1b1eda58a 100644 --- a/infer/src/biabduction/PropUtil.mli +++ b/infer/src/biabduction/PropUtil.mli @@ -12,8 +12,8 @@ val remove_locals_ret : Tenv.t -> Procdesc.t -> Prop.normal Prop.t -> Prop.norma val remove_locals_formals : Tenv.t -> Procdesc.t -> Prop.normal Prop.t -> Pvar.t list * Prop.normal Prop.t -(** Deallocate the stack variables in [pvars], and replace them by normal variables. - Return the list of stack variables whose address was still present after deallocation. *) +(** Deallocate the stack variables in [pvars], and replace them by normal variables. Return the list + of stack variables whose address was still present after deallocation. *) val remove_seed_vars : Tenv.t -> 'a Prop.t -> Prop.normal Prop.t (** remove seed vars from a prop *) diff --git a/infer/src/biabduction/Propgraph.ml b/infer/src/biabduction/Propgraph.ml index 8ace302d1..4b3add06f 100644 --- a/infer/src/biabduction/Propgraph.ml +++ b/infer/src/biabduction/Propgraph.ml @@ -50,8 +50,9 @@ let get_pi footprint_part g = if footprint_part then g.Prop.pi_fp else g.Prop.pi let get_subl footprint_part g = if footprint_part then [] else Sil.sub_to_list g.Prop.sub -(** [edge_from_source g n footprint_part is_hpred] finds and edge with the given source [n] in prop [g]. - [footprint_part] indicates whether to search the edge in the footprint part, and [is_pred] whether it is an hpred edge. *) +(** [edge_from_source g n footprint_part is_hpred] finds and edge with the given source [n] in prop + [g]. [footprint_part] indicates whether to search the edge in the footprint part, and [is_pred] + whether it is an hpred edge. *) let edge_from_source g n footprint_part is_hpred = let edges = if is_hpred then List.map ~f:(fun hpred -> Ehpred hpred) (get_sigma footprint_part g) @@ -65,7 +66,8 @@ let edge_from_source g n footprint_part is_hpred = match List.filter ~f:starts_from edges with [] -> None | edge :: _ -> Some edge -(** [get_edges footprint_part g] returns the list of edges in [g], in the footprint part if [fotprint_part] is true *) +(** [get_edges footprint_part g] returns the list of edges in [g], in the footprint part if + [fotprint_part] is true *) let get_edges footprint_part g = let hpreds = get_sigma footprint_part g in let atoms = get_pi footprint_part g in @@ -87,8 +89,8 @@ let edge_equal e1 e2 = false -(** [contains_edge footprint_part g e] returns true if the graph [g] contains edge [e], - searching the footprint part if [footprint_part] is true. *) +(** [contains_edge footprint_part g e] returns true if the graph [g] contains edge [e], searching + the footprint part if [footprint_part] is true. *) let contains_edge (footprint_part : bool) (g : _ t) (e : edge) = List.exists ~f:(fun e' -> edge_equal e e') (get_edges footprint_part g) @@ -210,15 +212,15 @@ let compute_diff default_color oldgraph newgraph : _ diff = ; diff_cmap_foot= colormap_foot } -(** [diff_get_colormap footprint_part diff] returns the colormap of a computed diff, - selecting the footprint colormap if [footprint_part] is true. *) +(** [diff_get_colormap footprint_part diff] returns the colormap of a computed diff, selecting the + footprint colormap if [footprint_part] is true. *) let diff_get_colormap footprint_part diff = if footprint_part then diff.diff_cmap_foot else diff.diff_cmap_norm -(** Print a list of propositions, prepending each one with the given string. - If !Config.pring_using_diff is true, print the diff w.r.t. the given prop, - extracting its local stack vars if the boolean is true. *) +(** Print a list of propositions, prepending each one with the given string. If + !Config.pring_using_diff is true, print the diff w.r.t. the given prop, extracting its local + stack vars if the boolean is true. *) let pp_proplist pe0 s (base_prop, extract_stack) f plist = let num = List.length plist in let base_stack = fst (Prop.sigma_get_stack_nonstack true base_prop.Prop.sigma) in diff --git a/infer/src/biabduction/Propgraph.mli b/infer/src/biabduction/Propgraph.mli index 16818f74b..05aff0b2e 100644 --- a/infer/src/biabduction/Propgraph.mli +++ b/infer/src/biabduction/Propgraph.mli @@ -20,17 +20,17 @@ val from_prop : 'a Prop.t -> 'a t type 'a diff val compute_diff : Pp.color -> 'a t -> 'a t -> 'a diff -(** [compute_diff default_color oldgraph newgraph] returns the list of edges - which are only in [newgraph] *) +(** [compute_diff default_color oldgraph newgraph] returns the list of edges which are only in + [newgraph] *) val diff_get_colormap : bool -> 'a diff -> Pp.colormap -(** [diff_get_colormap footprint_part diff] returns the colormap of a computed diff, - selecting the footprint colormap if [footprint_part] is true. *) +(** [diff_get_colormap footprint_part diff] returns the colormap of a computed diff, selecting the + footprint colormap if [footprint_part] is true. *) val pp_proplist : Pp.env -> string -> 'a Prop.t * bool -> Format.formatter -> 'b Prop.t list -> unit -(** Print a list of propositions, prepending each one with the given string, - If !Config.pring_using_diff is true, print the diff w.r.t. the given prop, - extracting its local stack vars if the boolean is true. *) +(** Print a list of propositions, prepending each one with the given string, If + !Config.pring_using_diff is true, print the diff w.r.t. the given prop, extracting its local + stack vars if the boolean is true. *) val d_proplist : 'a Prop.t -> 'b Prop.t list -> unit (** dump a prop list coming form the given initial prop *) diff --git a/infer/src/biabduction/Propset.ml b/infer/src/biabduction/Propset.ml index 4763d431a..63533b106 100644 --- a/infer/src/biabduction/Propset.ml +++ b/infer/src/biabduction/Propset.ml @@ -20,8 +20,8 @@ end) let compare = PropSet.compare -(** Sets of propositions. - The invariant is maintaned that Prop.prop_rename_primed_footprint_vars is called on any prop added to the set. *) +(** Sets of propositions. The invariant is maintaned that Prop.prop_rename_primed_footprint_vars is + called on any prop added to the set. *) type t = PropSet.t let add tenv p pset = @@ -71,15 +71,15 @@ let map_option tenv f pset = (** Apply function to all the elements of [propset]. *) let map tenv f pset = from_proplist tenv (List.map ~f (to_proplist pset)) -(** [fold f pset a] computes [f (... (f (f a p1) p2) ...) pn] - where [p1 ... pN] are the elements of pset, in increasing order. *) +(** [fold f pset a] computes [f (... (f (f a p1) p2) ...) pn] where [p1 ... pN] are the elements of + pset, in increasing order. *) let fold f a pset = let l = to_proplist pset in List.fold ~f ~init:a l -(** [iter f pset] computes (f p1;f p2;..;f pN) - where [p1 ... pN] are the elements of pset, in increasing order. *) +(** [iter f pset] computes (f p1;f p2;..;f pN) where [p1 ... pN] are the elements of pset, in + increasing order. *) let iter = PropSet.iter let subseteq = PropSet.subset diff --git a/infer/src/biabduction/Propset.mli b/infer/src/biabduction/Propset.mli index 515877db1..7158bd135 100644 --- a/infer/src/biabduction/Propset.mli +++ b/infer/src/biabduction/Propset.mli @@ -14,8 +14,8 @@ open! IStd [@@@warning "-32"] -(** Sets of propositions. - The invariant is maintaned that Prop.prop_rename_primed_footprint_vars is called on any prop added to the set. *) +(** Sets of propositions. The invariant is maintaned that Prop.prop_rename_primed_footprint_vars is + called on any prop added to the set. *) type t val compare : t -> t -> int @@ -56,13 +56,12 @@ val map_option : Tenv.t -> (Prop.normal Prop.t -> Prop.normal Prop.t option) -> (** Apply function to all the elements of the propset, removing those where it returns [None]. *) val fold : ('a -> Prop.normal Prop.t -> 'a) -> 'a -> t -> 'a -(** [fold f pset a] computes [(f pN ... (f p2 (f p1 a))...)], - where [p1 ... pN] are the elements of pset, in increasing - order. *) +(** [fold f pset a] computes [(f pN ... (f p2 (f p1 a))...)], where [p1 ... pN] are the elements of + pset, in increasing order. *) val iter : (Prop.normal Prop.t -> unit) -> t -> unit -(** [iter f pset] computes (f p1;f p2;..;f pN) - where [p1 ... pN] are the elements of pset, in increasing order. *) +(** [iter f pset] computes (f p1;f p2;..;f pN) where [p1 ... pN] are the elements of pset, in + increasing order. *) val partition : (Prop.normal Prop.t -> bool) -> t -> t * t diff --git a/infer/src/biabduction/Prover.ml b/infer/src/biabduction/Prover.ml index 352fdb32e..3eb44d525 100644 --- a/infer/src/biabduction/Prover.ml +++ b/infer/src/biabduction/Prover.ml @@ -633,14 +633,12 @@ let check_equal tenv prop e1_0 e2_0 = check_equal () || check_equal_const () || check_equal_pi () -(** Check [ |- e=0]. Result [false] means "don't know". *) +(** Check [|- e=0]. Result [false] means "don't know". *) let check_zero tenv e = check_equal tenv Prop.prop_emp e Exp.zero -(** [is_root prop base_exp exp] checks whether [base_exp = - exp.offlist] for some list of offsets [offlist]. If so, it returns - [Some(offlist)]. Otherwise, it returns [None]. Assumes that - [base_exp] points to the beginning of a structure, not the middle. -*) +(** [is_root prop base_exp exp] checks whether [base_exp = exp.offlist] for some list of offsets + [offlist]. If so, it returns [Some(offlist)]. Otherwise, it returns [None]. Assumes that + [base_exp] points to the beginning of a structure, not the middle. *) let is_root tenv prop base_exp exp = let rec f offlist_past e = match e with @@ -840,8 +838,8 @@ let check_lt_normalized tenv prop e1 e2 = upper_lower_check () || Inequalities.check_lt ineq e1 e2 -(** Given an atom and a proposition returns a unique identifier. - We use this to distinguish among different queries. *) +(** Given an atom and a proposition returns a unique identifier. We use this to distinguish among + different queries. *) let get_smt_key a p = let tmp_filename = Filename.temp_file "smt_query" ".cns" in let outc_tmp = Out_channel.create tmp_filename in @@ -1309,9 +1307,8 @@ let extend_sub sub v e = Sil.sub_join new_exp_sub (Sil.sub_range_map (Sil.exp_sub new_exp_sub) sub) -(** Extend [sub1] and [sub2] to witnesses that each instance of - [e1[sub1]] is an instance of [e2[sub2]]. Raise IMPL_FALSE if not - possible. *) +(** Extend [sub1] and [sub2] to witnesses that each instance of [e1\[sub1\]] is an instance of + [e2\[sub2\]]. Raise IMPL_FALSE if not possible. *) let exp_imply tenv calc_missing (subs : subst2) e1_in e2_in : subst2 = let e1 = Prop.exp_normalize_noabs tenv (fst subs) e1_in in let e2 = Prop.exp_normalize_noabs tenv (snd subs) e2_in in @@ -1431,10 +1428,9 @@ let exp_imply tenv calc_missing (subs : subst2) e1_in e2_in : subst2 = do_imply subs e1 e2 -(** Convert a path (from lhs of a |-> to a field name present only in - the rhs) into an id. If the lhs was a footprint var, the id is a - new footprint var. Othewise it is a var with the path in the name - and stamp - 1 *) +(** Convert a path (from lhs of a |-> to a field name present only in the rhs) into an id. If the + lhs was a footprint var, the id is a new footprint var. Othewise it is a var with the path in + the name and stamp - 1 *) let path_to_id path = let rec f = function | Exp.Var id -> @@ -1478,9 +1474,8 @@ let array_len_imply tenv calc_missing subs len1 len2 indices2 = subs -(** Extend [sub1] and [sub2] to witnesses that each instance of - [se1[sub1]] is an instance of [se2[sub2]]. Raise IMPL_FALSE if not - possible. *) +(** Extend [sub1] and [sub2] to witnesses that each instance of [se1\[sub1\]] is an instance of + [se2\[sub2\]]. Raise IMPL_FALSE if not possible. *) let rec sexp_imply tenv source calc_index_frame calc_missing subs se1 se2 typ2 : subst2 * Sil.strexp option * Sil.strexp option = (* L.d_str "sexp_imply "; Sil.d_sexp se1; L.d_str " "; Sil.d_sexp se2; @@ -1731,8 +1726,9 @@ let move_primed_lhs_from_front subs sigma = else sigma -(** [expand_hpred_pointer calc_index_frame hpred] expands [hpred] if it is a |-> whose lhs is a Lfield or Lindex or ptr+off. - Return [(changed, calc_index_frame', hpred')] where [changed] indicates whether the predicate has changed. *) +(** [expand_hpred_pointer calc_index_frame hpred] expands [hpred] if it is a |-> whose lhs is a + Lfield or Lindex or ptr+off. Return [(changed, calc_index_frame', hpred')] where [changed] + indicates whether the predicate has changed. *) let expand_hpred_pointer = let count = ref 0 in fun tenv calc_index_frame hpred -> @@ -2268,9 +2264,8 @@ let rec hpred_imply tenv calc_index_frame calc_missing subs prop1 sigma2 hpred2 (subs', prop1') ) ) -(** Check that [sigma1] implies [sigma2] and return two substitution - instantiations for the primed variables of [sigma1] and [sigma2] - and a frame. Raise IMPL_FALSE if the implication cannot be +(** Check that [sigma1] implies [sigma2] and return two substitution instantiations for the primed + variables of [sigma1] and [sigma2] and a frame. Raise IMPL_FALSE if the implication cannot be proven. *) and sigma_imply tenv calc_index_frame calc_missing subs prop1 sigma2 : subst2 * Prop.normal Prop.t = let is_constant_string_class subs = function @@ -2446,9 +2441,8 @@ let imply_atom tenv calc_missing (sub1, sub2) prop a = imply_pi tenv calc_missing (sub1, sub2) prop [a] -(** Check pure implications before looking at the spatial part. Add - necessary instantiations for equalities and check that instantiations - are possible for disequalities. *) +(** Check pure implications before looking at the spatial part. Add necessary instantiations for + equalities and check that instantiations are possible for disequalities. *) let rec pre_check_pure_implication tenv calc_missing (subs : subst2) pi1 pi2 = match pi2 with | [] -> @@ -2480,9 +2474,9 @@ let rec pre_check_pure_implication tenv calc_missing (subs : subst2) pi1 pi2 = pre_check_pure_implication tenv calc_missing subs pi1 pi2' -(** Perform the array bound checks delayed (to instantiate variables) by the prover. - If there is a provable violation of the array bounds, set the prover status to Bounds_check - and make the proof fail. *) +(** Perform the array bound checks delayed (to instantiate variables) by the prover. If there is a + provable violation of the array bounds, set the prover status to Bounds_check and make the proof + fail. *) let check_array_bounds tenv (sub1, sub2) prop = let check_failed atom = ProverState.checks := Bounds_check :: !ProverState.checks ; @@ -2515,8 +2509,8 @@ let check_array_bounds tenv (sub1, sub2) prop = List.iter ~f:check_bound (ProverState.get_bounds_checks ()) -(** [check_implication_base] returns true if [prop1|-prop2], - ignoring the footprint part of the props *) +(** [check_implication_base] returns true if [prop1|-prop2], ignoring the footprint part of the + props *) let check_implication_base pname tenv check_frame_empty calc_missing prop1 prop2 = try ProverState.reset prop1 prop2 ; @@ -2599,9 +2593,8 @@ type implication_result = * (Exp.t * Exp.t) list ) | ImplFail of check list -(** [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 +(** [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. *) let check_implication_for_footprint pname tenv p1 (p2 : Prop.exposed Prop.t) = let check_frame_empty = false in diff --git a/infer/src/biabduction/Prover.mli b/infer/src/biabduction/Prover.mli index 4f99b3404..2027f62a8 100644 --- a/infer/src/biabduction/Prover.mli +++ b/infer/src/biabduction/Prover.mli @@ -18,13 +18,13 @@ val atom_negate : Tenv.t -> Sil.atom -> Sil.atom (** {2 Ordinary Theorem Proving} *) val check_zero : Tenv.t -> Exp.t -> bool -(** Check [ |- e=0]. Result [false] means "don't know". *) +(** Check [|- e=0]. Result [false] means "don't know". *) val check_equal : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Exp.t -> bool -(** Check [prop |- exp1=exp2]. Result [false] means "don't know". *) +(** Check [prop |- exp1=exp2]. Result [false] means "don't know". *) val check_disequal : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Exp.t -> bool -(** Check whether [prop |- exp1!=exp2]. Result [false] means "don't know". *) +(** Check whether [prop |- exp1!=exp2]. Result [false] means "don't know". *) val type_size_comparable : Typ.t -> Typ.t -> bool (** Return true if the two types have sizes which can be compared *) @@ -33,7 +33,7 @@ val check_type_size_leq : Typ.t -> Typ.t -> bool (** Check <= on the size of comparable types *) val check_atom : Tenv.t -> Prop.normal Prop.t -> atom -> bool -(** Check whether [prop |- a]. Result [false] means "don't know". *) +(** Check whether [prop |- a]. Result [false] means "don't know". *) val check_inconsistency_base : Tenv.t -> Prop.normal Prop.t -> bool (** Inconsistency checking ignoring footprint. *) @@ -45,14 +45,14 @@ val check_allocatedness : Tenv.t -> Prop.normal Prop.t -> Exp.t -> bool (** Check whether [prop |- allocated(exp)]. *) val is_root : Tenv.t -> Prop.normal Prop.t -> Exp.t -> Exp.t -> offset list option -(** [is_root prop base_exp exp] checks whether [base_exp = - exp.offlist] for some list of offsets [offlist]. If so, it returns - [Some(offlist)]. Otherwise, it returns [None]. Assumes that +(** [is_root prop base_exp exp] checks whether [base_exp = exp.offlist] for some list of offsets + [offlist]. If so, it returns [Some(offlist)]. Otherwise, it returns [None]. Assumes that [base_exp] points to the beginning of a structure, not the middle. *) val expand_hpred_pointer : Tenv.t -> bool -> Sil.hpred -> bool * bool * Sil.hpred -(** [expand_hpred_pointer calc_index_frame hpred] expands [hpred] if it is a |-> whose lhs is a Lfield or Lindex or ptr+off. - Return [(changed, calc_index_frame', hpred')] where [changed] indicates whether the predicate has changed. *) +(** [expand_hpred_pointer calc_index_frame hpred] expands [hpred] if it is a |-> whose lhs is a + Lfield or Lindex or ptr+off. Return [(changed, calc_index_frame', hpred')] where [changed] + indicates whether the predicate has changed. *) val get_bounds : Tenv.t -> Prop.normal Prop.t -> Exp.t -> IntLit.t option * IntLit.t option (** Get upper and lower bounds of an expression, if any *) @@ -83,16 +83,15 @@ type implication_result = val check_implication_for_footprint : Typ.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 +(** [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. *) (** {2 Cover: minimum set of pi's whose disjunction is equivalent to true} *) val find_minimum_pure_cover : Tenv.t -> (Sil.atom list * 'a) list -> (Sil.atom list * 'a) list option -(** Find minimum set of pi's in [cases] whose disjunction covers true *) +(** Find minimum set of pi's in [cases] whose disjunction covers true *) (** {2 Subtype checking} *) @@ -101,6 +100,6 @@ module Subtyping_check : sig (** check_subtype t1 t2 checks whether t1 is a subtype of t2, given the type environment tenv. *) val subtype_case_analysis : Tenv.t -> Exp.t -> Exp.t -> Exp.t option * Exp.t option - (** subtype_case_analysis tenv tecp1 texp2 performs case analysis on [texp1 <: texp2], - and returns the updated types in the true and false case, if they are possible *) + (** subtype_case_analysis tenv tecp1 texp2 performs case analysis on [texp1 <: texp2], and returns + the updated types in the true and false case, if they are possible *) end diff --git a/infer/src/biabduction/Rearrange.ml b/infer/src/biabduction/Rearrange.ml index af069e691..b18f99ca3 100644 --- a/infer/src/biabduction/Rearrange.ml +++ b/infer/src/biabduction/Rearrange.ml @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (** Re-arrangement and extension of structures with fresh variables *) diff --git a/infer/src/biabduction/Rearrange.mli b/infer/src/biabduction/Rearrange.mli index b3383485f..b75911746 100644 --- a/infer/src/biabduction/Rearrange.mli +++ b/infer/src/biabduction/Rearrange.mli @@ -33,6 +33,6 @@ val rearrange : -> Prop.normal Prop.t -> Location.t -> Sil.offset list Prop.prop_iter list -(** [rearrange lexp prop] rearranges [prop] into the form [prop' * lexp|->strexp:typ]. - It returns an iterator with [lexp |-> strexp: typ] as current predicate - and the path (an [offsetlist]) which leads to [lexp] as the iterator state. *) +(** [rearrange lexp prop] rearranges [prop] into the form [prop' * lexp|->strexp:typ]. It returns an + iterator with [lexp |-> strexp: typ] as current predicate and the path (an [offsetlist]) which + leads to [lexp] as the iterator state. *) diff --git a/infer/src/biabduction/RetainCyclesType.mli b/infer/src/biabduction/RetainCyclesType.mli index 0b79396ab..50505d4ff 100644 --- a/infer/src/biabduction/RetainCyclesType.mli +++ b/infer/src/biabduction/RetainCyclesType.mli @@ -16,7 +16,7 @@ type retain_cycle_edge_obj = {rc_from: retain_cycle_node; rc_field: retain_cycle type retain_cycle_edge = Object of retain_cycle_edge_obj | Block of Typ.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. *) + to model the cycle structure. The next element from the end of the list is the head. *) type t = {rc_head: retain_cycle_edge; rc_elements: retain_cycle_edge list} module Set : Caml.Set.S with type elt = t diff --git a/infer/src/biabduction/State.ml b/infer/src/biabduction/State.ml index 1ccc939e1..6e055c849 100644 --- a/infer/src/biabduction/State.ml +++ b/infer/src/biabduction/State.ml @@ -116,9 +116,8 @@ let instrs_normalize instrs = Instrs.fold instrs ~init:[] ~f:subst_and_add -(** Create a function to find duplicate nodes. - A node is a duplicate of another one if they have the same kind and location - and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) +(** Create a function to find duplicate nodes. A node is a duplicate of another one if they have the + same kind and location and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) let mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet.t = let module M = (* map from (loc,kind) *) Caml.Map.Make (struct @@ -186,7 +185,8 @@ let get_loc_trace () : Errlog.loc_trace = let get_prop_tenv_pdesc () = !gs.last_prop_tenv_pdesc -(** extract the footprint of the prop, and turn it into a normalized precondition using spec variables *) +(** extract the footprint of the prop, and turn it into a normalized precondition using spec + variables *) let extract_pre p tenv pdesc abstract_fun = let sub = let idlist = Prop.free_vars p |> Ident.hashqueue_of_sequence |> Ident.HashQueue.keys in @@ -204,8 +204,8 @@ let extract_pre p tenv pdesc abstract_fun = Prop.normalize tenv (Prop.prop_sub sub pre') -(** return the normalized precondition extracted form the last prop seen, if any - the abstraction function is a parameter to get around module dependencies *) +(** return the normalized precondition extracted form the last prop seen, if any the abstraction + function is a parameter to get around module dependencies *) let get_normalized_pre (abstract_fun : Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t) : Prop.normal Prop.t option = match get_prop_tenv_pdesc () with diff --git a/infer/src/biabduction/State.mli b/infer/src/biabduction/State.mli index d8845ee93..e5cb56d2b 100644 --- a/infer/src/biabduction/State.mli +++ b/infer/src/biabduction/State.mli @@ -10,7 +10,7 @@ open! IStd (** State of symbolic execution *) -(** Internal state *) +(** Internal state *) type t val add_diverging_states : Paths.PathSet.t -> unit @@ -45,8 +45,8 @@ val get_node : unit -> Procdesc.Node.t option val get_normalized_pre : (Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t) -> Prop.normal Prop.t option -(** return the normalized precondition extracted form the last prop seen, if any - the abstraction function is a parameter to get around module dependencies *) +(** return the normalized precondition extracted form the last prop seen, if any the abstraction + function is a parameter to get around module dependencies *) val get_path : unit -> Paths.Path.t * PredSymb.path_pos option (** Get last path seen in symbolic execution *) @@ -73,9 +73,8 @@ val mark_instr_ok : unit -> unit (** Mark that the execution of the current instruction was OK *) val mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet.t -(** Create a function to find duplicate nodes. - A node is a duplicate of another one if they have the same kind and location - and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) +(** Create a function to find duplicate nodes. A node is a duplicate of another one if they have the + 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 diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index fd49ff9bb..26222c9bd 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -44,20 +44,17 @@ let unroll_type tenv (typ : Typ.t) (off : Sil.offset) = fail (Sil.pp_offset Pp.text) off -(** Apply function [f] to the expression at position [offlist] in [strexp]. - If not found, expand [strexp] and apply [f] to [None]. - The routine should maintain the invariant that strexp and typ correspond to - each other exactly, without involving any re - interpretation of some type t - as the t array. The [fp_root] parameter indicates whether the kind of the - root expression of the corresponding pointsto predicate is a footprint identifier. - The function can expand a list of higher - order [hpara_psto] predicates, if - the list is stored at [offlist] in [strexp] initially. The expanded list - is returned as a part of the result. All these happen under [p], so that it - is sound to call the prover with [p]. Finally, before running this function, - the tool should run strexp_extend_value in rearrange.ml for the same strexp - and offlist, so that all the necessary extensions of strexp are done before - this function. If the tool follows this protocol, it will never hit the assert - false cases for field and array accesses. *) +(** Apply function [f] to the expression at position [offlist] in [strexp]. If not found, expand + [strexp] and apply [f] to [None]. The routine should maintain the invariant that strexp and typ + correspond to each other exactly, without involving any re - interpretation of some type t as + the t array. The [fp_root] parameter indicates whether the kind of the root expression of the + corresponding pointsto predicate is a footprint identifier. The function can expand a list of + higher - order [hpara_psto] predicates, if the list is stored at [offlist] in [strexp] + initially. The expanded list is returned as a part of the result. All these happen under [p], so + that it is sound to call the prover with [p]. Finally, before running this function, the tool + should run strexp_extend_value in rearrange.ml for the same strexp and offlist, so that all the + necessary extensions of strexp are done before this function. If the tool follows this protocol, + it will never hit the assert false cases for field and array accesses. *) let rec apply_offlist pdesc tenv p fp_root nullify_struct (root_lexp, strexp, typ) offlist (f : Exp.t option -> Exp.t) inst lookup_inst = let pp_error () = @@ -164,18 +161,16 @@ let rec apply_offlist pdesc tenv p fp_root nullify_struct (root_lexp, strexp, ty raise (Exceptions.Internal_error (Localise.verbatim_desc "Array out of bounds in Symexec")) -(** Given [lexp |-> se: typ], if the location [offlist] exists in [se], - function [ptsto_lookup p (lexp, se, typ) offlist id] returns a tuple. - The first component of the tuple is an expression at position [offlist] in [se]. - The second component is an expansion of the predicate [lexp |-> se: typ], - where the entity at [offlist] in [se] is expanded if the entity is a list of - higher - order parameters [hpara_psto]. If this expansion happens, - the last component of the tuple is a list of pi - sigma pairs obtained - by instantiating the [hpara_psto] list. Otherwise, the last component is None. - All these steps happen under [p]. So, we can call a prover with [p]. - Finally, before running this function, the tool should run strexp_extend_value - in rearrange.ml for the same se and offlist, so that all the necessary - extensions of se are done before this function. *) +(** Given [lexp |-> se: typ], if the location [offlist] exists in [se], function + [ptsto_lookup p (lexp, se, typ) offlist id] returns a tuple. The first component of the tuple is + an expression at position [offlist] in [se]. The second component is an expansion of the + predicate [lexp |-> se: typ], where the entity at [offlist] in [se] is expanded if the entity is + a list of higher - order parameters [hpara_psto]. If this expansion happens, the last component + of the tuple is a list of pi - sigma pairs obtained by instantiating the [hpara_psto] list. + Otherwise, the last component is None. All these steps happen under [p]. So, we can call a + prover with [p]. Finally, before running this function, the tool should run strexp_extend_value + in rearrange.ml for the same se and offlist, so that all the necessary extensions of se are done + before this function. *) let ptsto_lookup pdesc tenv p (lexp, se, sizeof) offlist id = let f = function Some exp -> exp | None -> Exp.Var id in let fp_root = match lexp with Exp.Var id -> Ident.is_footprint id | _ -> false in @@ -192,17 +187,13 @@ let ptsto_lookup pdesc tenv p (lexp, se, sizeof) offlist id = (e', ptsto', pred_insts_op', lookup_uninitialized) -(** [ptsto_update p (lexp,se,typ) offlist exp] takes - [lexp |-> se: typ], and updates [se] by replacing the - expression at [offlist] with [exp]. Then, it returns - the updated pointsto predicate. If [lexp |-> se: typ] gets - expanded during this update, the generated pi - sigma list from - the expansion gets returned, and otherwise, None is returned. - All these happen under the proposition [p], so it is ok call - prover with [p]. Finally, before running this function, - the tool should run strexp_extend_value in rearrange.ml for the same - se and offlist, so that all the necessary extensions of se are done - before this function. *) +(** [ptsto_update p (lexp,se,typ) offlist exp] takes [lexp |-> se: typ], and updates [se] by + replacing the expression at [offlist] with [exp]. Then, it returns the updated pointsto + predicate. If [lexp |-> se: typ] gets expanded during this update, the generated pi - sigma list + from the expansion gets returned, and otherwise, None is returned. All these happen under the + proposition [p], so it is ok call prover with [p]. Finally, before running this function, the + tool should run strexp_extend_value in rearrange.ml for the same se and offlist, so that all the + necessary extensions of se are done before this function. *) let ptsto_update pdesc tenv p (lexp, se, sizeof) offlist exp = let f _ = exp in let fp_root = match lexp with Exp.Var id -> Ident.is_footprint id | _ -> false in @@ -221,8 +212,7 @@ let update_iter iter pi sigma = List.fold ~f:(Prop.prop_iter_add_atom false) ~init:iter' pi -(** Precondition: se should not include hpara_psto - that could mean nonempty heaps. *) +(** Precondition: se should not include hpara_psto that could mean nonempty heaps. *) let rec execute_nullify_se = function | Sil.Eexp _ -> Sil.Eexp (Exp.zero, Sil.inst_nullify) @@ -234,8 +224,8 @@ let rec execute_nullify_se = function Sil.Earray (len, esel', Sil.inst_nullify) -(** Do pruning for conditional [if (e1 != e2) ] if [positive] is true - and [(if (e1 == e2)] if [positive] is false *) +(** Do pruning for conditional [if (e1 != e2)] if [positive] is true and [(if (e1 == e2)] if + [positive] is false *) let prune_ne tenv ~positive e1 e2 prop = let is_inconsistent = if positive then Prover.check_equal tenv prop e1 e2 else Prover.check_disequal tenv prop e1 e2 @@ -248,10 +238,9 @@ let prune_ne tenv ~positive e1 e2 prop = else Propset.singleton tenv new_prop -(** Do pruning for conditional "if ([e1] CMP [e2])" if [positive] is - true and "if (!([e1] CMP [e2]))" if [positive] is false, where CMP - is "<" if [is_strict] is true and "<=" if [is_strict] is false. -*) +(** Do pruning for conditional "if ([e1] CMP [e2])" if [positive] is true and "if (!([e1] CMP + [e2]))" if [positive] is false, where CMP is "<" if [is_strict] is true and "<=" if [is_strict] + is false. *) let prune_ineq tenv ~is_strict ~positive prop e1 e2 = if Exp.equal e1 e2 then if (positive && not is_strict) || ((not positive) && is_strict) then Propset.singleton tenv prop @@ -486,8 +475,8 @@ let check_already_dereferenced tenv pname cond prop = () -(** Check whether symbolic execution de-allocated a stack variable or a constant string, - raising an exception in that case *) +(** Check whether symbolic execution de-allocated a stack variable or a constant string, raising an + exception in that case *) let check_deallocate_static_memory prop_after = let check_deallocated_attribute = function | Sil.Apred (Aresource ({ra_kind= Rrelease} as ra), [Lvar pv]) @@ -693,8 +682,8 @@ type resolve_and_analyze_result = ; resolved_summary_opt: Summary.t option ; dynamic_dispatch_status: EventLogger.dynamic_dispatch option } -(** Resolve the procedure name and run the analysis of the resolved procedure - if not already analyzed *) +(** Resolve the procedure name and run the analysis of the resolved procedure if not already + analyzed *) let resolve_and_analyze tenv ~caller_summary ?(has_clang_model = false) prop args callee_proc_name call_flags : resolve_and_analyze_result = (* TODO (#15748878): Fix conflict with method overloading by encoding in the procedure name @@ -736,8 +725,8 @@ let resolve_and_analyze tenv ~caller_summary ?(has_clang_model = false) prop arg {resolved_pname; resolved_procdesc_opt; resolved_summary_opt; dynamic_dispatch_status} -(** recognize calls to the constructor java.net.URL and splits the argument string - to be only the protocol. *) +(** recognize calls to the constructor java.net.URL and splits the argument string to be only the + protocol. *) let call_constructor_url_update_args pname actual_params = let url_pname = Typ.Procname.Java @@ -1532,8 +1521,8 @@ and diverge prop path = [] -(** Symbolic execution of a sequence of instructions. - If errors occur and [mask_errors] is true, just treat as skip. *) +(** Symbolic execution of a sequence of instructions. If errors occur and [mask_errors] is true, + just treat as skip. *) and instrs ?(mask_errors = false) exe_env tenv summary instrs ppl = let exe_instr instr (p, path) = L.d_str "Executing Generated Instruction " ; diff --git a/infer/src/biabduction/SymExec.mli b/infer/src/biabduction/SymExec.mli index 94bbbb210..a70b0e611 100644 --- a/infer/src/biabduction/SymExec.mli +++ b/infer/src/biabduction/SymExec.mli @@ -32,8 +32,8 @@ val instrs : -> Instrs.not_reversed_t -> (Prop.normal Prop.t * Paths.Path.t) list -> (Prop.normal Prop.t * Paths.Path.t) list -(** Symbolic execution of a sequence of instructions. - If errors occur and [mask_errors] is true, just treat as skip. *) +(** Symbolic execution of a sequence of instructions. If errors occur and [mask_errors] is true, + just treat as skip. *) val diverge : Prop.normal Prop.t -> Paths.Path.t -> (Prop.normal Prop.t * Paths.Path.t) list (** Symbolic execution of the divergent pure computation. *) diff --git a/infer/src/biabduction/SymExecBlocks.mli b/infer/src/biabduction/SymExecBlocks.mli index b9093ac93..65c078928 100644 --- a/infer/src/biabduction/SymExecBlocks.mli +++ b/infer/src/biabduction/SymExecBlocks.mli @@ -12,12 +12,9 @@ val resolve_method_with_block_args_and_analyze : -> Typ.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 pname if it is defined and it's called with - the correct number of arguments, and some arguments are block closures. - The copy is created by adding extra formals for each captured variable, - and by swapping the calls to the block arguments to the calls to the concrete - blocks. - The new procedure is analyzed and the possibly computed summary is returned - together with the list of arguments where the closures where swapped by their - captured variables. *) +(** [resolve_method_with_block_args_and_analyze caller_pdesc pname args] create a copy of the method + pname if it is defined and it's called with the correct number of arguments, and some arguments + are block closures. The copy is created by adding extra formals for each captured variable, and + by swapping the calls to the block arguments to the calls to the concrete blocks. The new + procedure is analyzed and the possibly computed summary is returned together with the list of + arguments where the closures where swapped by their captured variables. *) diff --git a/infer/src/biabduction/Tabulation.ml b/infer/src/biabduction/Tabulation.ml index 8567a184d..00e3a8e26 100644 --- a/infer/src/biabduction/Tabulation.ml +++ b/infer/src/biabduction/Tabulation.ml @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (** Interprocedural footprint analysis *) diff --git a/infer/src/biabduction/Tabulation.mli b/infer/src/biabduction/Tabulation.mli index e7b547fda..a059ae8cd 100644 --- a/infer/src/biabduction/Tabulation.mli +++ b/infer/src/biabduction/Tabulation.mli @@ -31,12 +31,12 @@ val remove_constant_string_class : Tenv.t -> 'a Prop.t -> Prop.normal Prop.t (** Remove constant string or class from a prop *) val check_attr_dealloc_mismatch : PredSymb.t -> PredSymb.t -> unit -(** Check if the attribute change is a mismatch between a kind of allocation - and a different kind of deallocation *) +(** Check if the attribute change is a mismatch between a kind of allocation and a different kind of + deallocation *) val find_dereference_without_null_check_in_sexp : Sil.strexp -> (int * PredSymb.path_pos) option -(** Check whether a sexp contains a dereference without null check, - and return the line number and path position *) +(** Check whether a sexp contains a dereference without null check, and return the line number and + path position *) val create_cast_exception : Tenv.t -> Logging.ocaml_pos -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn diff --git a/infer/src/biabduction/interproc.ml b/infer/src/biabduction/interproc.ml index a8d9b74fb..058530c88 100644 --- a/infer/src/biabduction/interproc.ml +++ b/infer/src/biabduction/interproc.ml @@ -193,8 +193,8 @@ let do_meet_pre tenv pset = else Propset.to_proplist pset -(** Find the preconditions in the current spec table, - apply meet then join, and return the joined preconditions *) +(** Find the preconditions in the current spec table, apply meet then join, and return the joined + preconditions *) let collect_preconditions tenv summary : Prop.normal BiabductionSummary.Jprop.t list = let proc_name = Summary.get_proc_name summary in let collect_do_abstract_one tenv prop = @@ -513,8 +513,7 @@ let forward_tabulate summary exe_env tenv proc_cfg wl = L.d_ln () -(** Remove locals and formals, - and check if the address of a stack variable is left in the result *) +(** Remove locals and formals, and check if the address of a stack variable is left in the result *) let remove_locals_formals_and_check tenv proc_cfg p = let pdesc = ProcCfg.Exceptional.proc_desc proc_cfg in let pname = Procdesc.get_proc_name pdesc in @@ -688,10 +687,9 @@ let create_seed_vars sigma = List.fold ~f:hpred_add_seed ~init:[] sigma -(** Initialize proposition for execution given formal and global - parameters. The footprint is initialized according to the - execution mode. The prop is not necessarily emp, so it - should be incorporated when the footprint is constructed. *) +(** Initialize proposition for execution given formal and global parameters. The footprint is + initialized according to the execution mode. The prop is not necessarily emp, so it should be + incorporated when the footprint is constructed. *) let prop_init_formals_seed tenv new_formals (prop : 'a Prop.t) : Prop.exposed Prop.t = let sigma_new_formals = let do_formal (pv, typ) = @@ -818,10 +816,9 @@ let execute_filter_prop summary exe_env tenv proc_cfg type exe_phase = (unit -> unit) * (unit -> Prop.normal BiabductionSummary.spec list * BiabductionSummary.phase) -(** Return functions to perform one phase of the analysis for a procedure. - Given [proc_name], return [do, get_results] where [go ()] performs the analysis phase - and [get_results ()] returns the results computed. - This function is architected so that [get_results ()] can be called even after +(** Return functions to perform one phase of the analysis for a procedure. Given [proc_name], return + [do, get_results] where [go ()] performs the analysis phase and [get_results ()] returns the + results computed. This function is architected so that [get_results ()] can be called even after [go ()] was interrupted by and exception. *) let perform_analysis_phase exe_env tenv (summary : Summary.t) (proc_cfg : ProcCfg.Exceptional.t) : exe_phase = @@ -967,9 +964,9 @@ let remove_this_not_null tenv prop = Prop.normalize tenv prop' -(** Is true when the precondition does not contain constrains that can be false at call site. - This means that the post-conditions associated with this precondition cannot be prevented - by the calling context. *) +(** Is true when the precondition does not contain constrains that can be false at call site. This + means that the post-conditions associated with this precondition cannot be prevented by the + calling context. *) let is_unavoidable tenv pre = let prop = remove_this_not_null tenv (BiabductionSummary.Jprop.to_prop pre) in match Prop.CategorizePreconditions.categorize [prop] with @@ -1132,8 +1129,8 @@ let transition_footprint_re_exe summary tenv joined_pres : Summary.t = summary' -(** Perform phase transition from [FOOTPRINT] to [RE_EXECUTION] for - the procedures enabled after the analysis of [proc_name] *) +(** Perform phase transition from [FOOTPRINT] to [RE_EXECUTION] for the procedures enabled after the + analysis of [proc_name] *) let perform_transition proc_cfg tenv proc_name summary = let transition summary = (* disable exceptions for leaks and protect against any other errors *) diff --git a/infer/src/bufferoverrun/absLoc.mli b/infer/src/bufferoverrun/absLoc.mli index ee5e0f866..1aaa151ae 100644 --- a/infer/src/bufferoverrun/absLoc.mli +++ b/infer/src/bufferoverrun/absLoc.mli @@ -98,8 +98,7 @@ module Loc : sig val is_global : t -> bool val is_pretty : t -> bool - (** It checks if it is representable with pretty form, e.g., with a path or with a variable - name. *) + (** It checks if it is representable with pretty form, e.g., with a path or with a variable name. *) val is_return : t -> bool @@ -142,8 +141,8 @@ module PowLoc : sig (** It substitutes paths in the abstract location using [eval_locpath]. *) val lift_cmp : Boolean.EqualOrder.t -> t -> t -> Boolean.t - (** It lifts a comparison of [Loc.t] to [t]. The comparison can be [Boolean.EqualOrder.eq], - [Boolean.EqualOrder.ne], etc. *) + (** It lifts a comparison of [Loc.t] to [t]. The comparison can be [Boolean.EqualOrder.eq], + [Boolean.EqualOrder.ne], etc. *) end val can_strong_update : PowLoc.t -> bool diff --git a/infer/src/bufferoverrun/arrayBlk.mli b/infer/src/bufferoverrun/arrayBlk.mli index 7e4277a34..863577baf 100644 --- a/infer/src/bufferoverrun/arrayBlk.mli +++ b/infer/src/bufferoverrun/arrayBlk.mli @@ -43,15 +43,15 @@ val is_symbolic : t -> bool (** Check if there is a symbolic integer value in its offset or size *) val lift_cmp_itv : (Itv.t -> Itv.t -> Boolean.t) -> Boolean.EqualOrder.t -> t -> t -> Boolean.t -(** Lift a comparison of [Itv.t] and [Loc.t] to that of [t]. The comparison for [Itv.t] is used for - integer values such as offset and size, and the comparison for [Loc.t] is used for allocsites. *) +(** Lift a comparison of [Itv.t] and [Loc.t] to that of [t]. The comparison for [Itv.t] is used for + integer values such as offset and size, and the comparison for [Loc.t] is used for allocsites. *) val transform_length : f:(Itv.t -> Itv.t) -> t -> t (** Apply [f] to all sizes *) val prune_comp : Binop.t -> t -> t -> t (** [prune_comp comp x y] returns a pruned value of [x] by [comp] and [y]. [comp] should be - [Binop.Le], [Ge], [Lt], or [Gt]. *) + [Binop.Le], [Ge], [Lt], or [Gt]. *) val prune_eq : t -> t -> t (** [prune_eq x y] returns a pruned value of [x] by [== y]. *) @@ -67,15 +67,15 @@ val diff : t -> t -> Itv.t (** Return difference of offsets between given array blocks *) val normalize : t -> t -(** Normalize all interval values such as offset and size in it. Thus, if an interval value is - invalid, the interval value is replaced with bottom. *) +(** Normalize all interval values such as offset and size in it. Thus, if an interval value is + invalid, the interval value is replaced with bottom. *) val subst : t -> Bounds.Bound.eval_sym -> AbsLoc.PowLoc.eval_locpath -> AbsLoc.PowLoc.t * t (** Substitute symbolic abstract locations and symbolic interval value in the array block. - [eval_sym] is to get substituted interval values and [eval_locpath] is to get substituted - abstract locaion values. It also returns a set of abstract locations containing non-allocsite - locations from the substitution results. Since the key of [ArrayBlk.t] is [AbsLoc.Allocsite.t], - they cannot be written in this domain. *) + [eval_sym] is to get substituted interval values and [eval_locpath] is to get substituted + abstract locaion values. It also returns a set of abstract locations containing non-allocsite + locations from the substitution results. Since the key of [ArrayBlk.t] is [AbsLoc.Allocsite.t], + they cannot be written in this domain. *) val set_length : Itv.t -> t -> t @@ -87,9 +87,9 @@ val get_symbols : t -> Symb.SymbolSet.t (** Return all symbols for integer values in it *) val get_offset : ?cost_mode:bool -> t -> Itv.t -(** Return offset of the array block. If [cost_mode] is [true], it returns a conservative - (bigger than correct one), but not correct offset results. *) +(** Return offset of the array block. If [cost_mode] is [true], it returns a conservative (bigger + than correct one), but not correct offset results. *) val get_size : ?cost_mode:bool -> t -> Itv.t -(** Return size of the array block. If [cost_mode] is [true], it returns a conservative (bigger - than correct one), but not correct size results. *) +(** Return size of the array block. If [cost_mode] is [true], it returns a conservative (bigger than + correct one), but not correct size results. *) diff --git a/infer/src/bufferoverrun/boolean.mli b/infer/src/bufferoverrun/boolean.mli index 90ce58e15..e7ffd7699 100644 --- a/infer/src/bufferoverrun/boolean.mli +++ b/infer/src/bufferoverrun/boolean.mli @@ -24,9 +24,8 @@ val and_ : t -> t -> t val or_ : t -> t -> t module EqualOrder : sig - (** - This module provides abstract transfer functions for comparisons on unordered values, only based on equality, like abstract locations. -*) + (** This module provides abstract transfer functions for comparisons on unordered values, only + based on equality, like abstract locations. *) type b = t diff --git a/infer/src/bufferoverrun/bounds.ml b/infer/src/bufferoverrun/bounds.ml index 07f1d2d88..658c57b3e 100644 --- a/infer/src/bufferoverrun/bounds.ml +++ b/infer/src/bufferoverrun/bounds.ml @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd open! AbstractDomain.Types module F = Format diff --git a/infer/src/bufferoverrun/bounds.mli b/infer/src/bufferoverrun/bounds.mli index a8b826b74..5a8c68e7c 100644 --- a/infer/src/bufferoverrun/bounds.mli +++ b/infer/src/bufferoverrun/bounds.mli @@ -12,8 +12,8 @@ module Bound : sig type t val mk_MultB : Z.t * t * t -> t - (** It makes a bound of [Bound.MultB], which represents a multiplication of two bounds. For - example, [MultB (1, x, y)] represents [1 + x × y]. *) + (** It makes a bound of [Bound.MultB], which represents a multiplication of two bounds. For + example, [MultB (1, x, y)] represents [1 + x × y]. *) type eval_sym = t Symb.Symbol.eval diff --git a/infer/src/bufferoverrun/bufferOverrunField.ml b/infer/src/bufferoverrun/bufferOverrunField.ml index 0bbf6b452..4b0938aaa 100644 --- a/infer/src/bufferoverrun/bufferOverrunField.ml +++ b/infer/src/bufferoverrun/bufferOverrunField.ml @@ -8,13 +8,10 @@ open! IStd module F = Format module L = Logging -(** - If fn is empty, prints [pp_lhs_alone lhs] - Otherwise prints [pp_lhs lhs ^ sep ^ fn] +(** If fn is empty, prints [pp_lhs_alone lhs] Otherwise prints [pp_lhs lhs ^ sep ^ fn] - Create invisible phantom fields by giving them a name ending in '.' - The name preceeding the '.' will be used in debug mode. -*) + Create invisible phantom fields by giving them a name ending in '.' The name preceeding the '.' + will be used in debug mode. *) let pp ~pp_lhs ~pp_lhs_alone ~sep f lhs fn = let fieldname = Typ.Fieldname.to_flat_string fn in if String.is_empty fieldname then diff --git a/infer/src/bufferoverrun/bufferOverrunModels.ml b/infer/src/bufferoverrun/bufferOverrunModels.ml index 2d8999451..165956880 100644 --- a/infer/src/bufferoverrun/bufferOverrunModels.ml +++ b/infer/src/bufferoverrun/bufferOverrunModels.ml @@ -449,8 +449,7 @@ let create_copy_array src_exp = module CFArray = struct - (** Creates a new array from the given array by copying the first X - elements. *) + (** Creates a new array from the given array by copying the first X elements. *) let create_array src_exp size_exp = let {exec= malloc_exec; check= _} = malloc ~can_be_zero:true size_exp in let exec model_env ~ret:((id, _) as ret) mem = @@ -766,8 +765,8 @@ module StdBasicString = struct let length = StdVector.size end -(** Java's integers are modeled with an indirection to a memory - location that holds the actual integer value *) +(** Java's integers are modeled with an indirection to a memory location that holds the actual + integer value *) module JavaInteger = struct let intValue exp = let exec _ ~ret:(id, _) mem = @@ -884,8 +883,8 @@ module Collection = struct {exec; check= no_check} - (** increase the size by [0, 1] because put replaces the value - rather than add a new one when the key is found in the map *) + (** increase the size by [0, 1] because put replaces the value rather than add a new one when the + key is found in the map *) let put coll_id = {exec= change_size_by_incr_or_not coll_id; check= no_check} (* The return value is set by [set_itv_updated_by_addition] in order to be sure that it can be @@ -954,9 +953,8 @@ module Collection = struct {exec; check= no_check} - (** Returns a view of the portion of this list between the specified - fromIndex, inclusive, and toIndex, exclusive. Simply model it as - creating a new list with length toIndex - fromIndex. *) + (** Returns a view of the portion of this list between the specified fromIndex, inclusive, and + toIndex, exclusive. Simply model it as creating a new list with length toIndex - fromIndex. *) let subList from_exp to_exp = let exec ({integer_type_widths} as model) ~ret mem = let from_idx = Sem.eval integer_type_widths from_exp mem in @@ -967,8 +965,8 @@ module Collection = struct {exec; check= no_check} - (** increase the size by [0, |collection_to_add|] because put replaces the value - rather than add a new one when the key is found in the map *) + (** increase the size by [0, |collection_to_add|] because put replaces the value rather than add a + new one when the key is found in the map *) let putAll coll_id coll_to_add = let exec model_env ~ret mem = let to_add_length = diff --git a/infer/src/bufferoverrun/bufferOverrunSemantics.ml b/infer/src/bufferoverrun/bufferOverrunSemantics.ml index 070ebb266..16a1c97da 100644 --- a/infer/src/bufferoverrun/bufferOverrunSemantics.ml +++ b/infer/src/bufferoverrun/bufferOverrunSemantics.ml @@ -269,10 +269,8 @@ and eval_binop : Typ.IntegerWidths.t -> Binop.t -> Exp.t -> Exp.t -> Mem.t -> Va Val.lor_sem v1 v2 -(** - [eval_locs exp mem] is like [eval exp mem |> Val.get_all_locs] - but takes some shortcuts to avoid computing useless and/or problematic intermediate values -*) +(** [eval_locs exp mem] is like [eval exp mem |> Val.get_all_locs] but takes some shortcuts to avoid + computing useless and/or problematic intermediate values *) let rec eval_locs : Exp.t -> Mem.t -> PowLoc.t = fun exp mem -> match exp with diff --git a/infer/src/bufferoverrun/polynomials.ml b/infer/src/bufferoverrun/polynomials.ml index 188baaacc..aa1919247 100644 --- a/infer/src/bufferoverrun/polynomials.ml +++ b/infer/src/bufferoverrun/polynomials.ml @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd open! AbstractDomain.Types module Bound = Bounds.Bound diff --git a/infer/src/bufferoverrun/symb.mli b/infer/src/bufferoverrun/symb.mli index 8282bc9d0..958bec99f 100644 --- a/infer/src/bufferoverrun/symb.mli +++ b/infer/src/bufferoverrun/symb.mli @@ -24,14 +24,12 @@ module SymbolPath : sig | Field of {fn: Typ.Fieldname.t; prefix: partial; typ: Typ.t option} | Callsite of {ret_typ: Typ.t; cs: CallSite.t} | StarField of {last_field: Typ.Fieldname.t; prefix: partial} - (** - Represents a path starting with [prefix] and ending with the field [last_field], - the middle can be anything. - Invariants: - - There is at most one StarField - - StarField excluded, there are no duplicate fieldnames - - StarField can only be followed by Deref elements - *) + (** Represents a path starting with [prefix] and ending with the field [last_field], the + middle can be anything. Invariants: + + - There is at most one StarField + - StarField excluded, there are no duplicate fieldnames + - StarField can only be followed by Deref elements *) [@@deriving compare] type t = private diff --git a/infer/src/checkers/LithoDomain.mli b/infer/src/checkers/LithoDomain.mli index 2d3a1ea89..c6d9acaf4 100644 --- a/infer/src/checkers/LithoDomain.mli +++ b/infer/src/checkers/LithoDomain.mli @@ -34,8 +34,8 @@ module CallSet : module type of AbstractDomain.FiniteSet (MethodCall) include module type of AbstractDomain.Map (LocalAccessPath) (CallSet) val substitute : f_sub:(LocalAccessPath.t -> LocalAccessPath.t option) -> t -> t -(** Substitute each access path in the domain using [f_sub]. If [f_sub] returns None, the - original access path is retained; otherwise, the new one is used *) +(** Substitute each access path in the domain using [f_sub]. If [f_sub] returns None, the original + access path is retained; otherwise, the new one is used *) val iter_call_chains : f:(AccessPath.t -> MethodCall.t list -> unit) -> t -> unit (** Apply [f] to each maximal call chain encoded in [t] *) diff --git a/infer/src/checkers/SimpleChecker.ml b/infer/src/checkers/SimpleChecker.ml index 0f40fe5ad..8debec4d1 100644 --- a/infer/src/checkers/SimpleChecker.ml +++ b/infer/src/checkers/SimpleChecker.ml @@ -9,8 +9,8 @@ open! IStd module F = Format module L = Logging -(** functor that makes it easy to write a basic abstract interpretation checker by lifting - a type, comparison function, reporting function, and exec function into an analyzer *) +(** functor that makes it easy to write a basic abstract interpretation checker by lifting a type, + comparison function, reporting function, and exec function into an analyzer *) module type Spec = sig (** what state do you want to propagate? *) @@ -20,15 +20,12 @@ module type Spec = sig (** implement the state the analysis should start from here *) val exec_instr : t -> Sil.instr -> Procdesc.Node.nodekind -> Typ.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. - *) + (** 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 - (** log errors here. - input is a state, location where the state occurs in the source, and the current procedure. - *) + (** log errors here. input is a state, location where the state occurs in the source, and the + current procedure. *) val compare : t -> t -> int end diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 38b170f4c..46af067fd 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -20,9 +20,8 @@ let is_whitelisted (pname : Typ.Procname.t) = type siof_model = { qual_name: string (** (fuzzy) name of the method, eg "std::ios_base::Init::Init" *) ; initialized_globals: string list - (** names of variables that are guaranteed to be initialized once the method is executed, - eg ["std::cerr"] *) - } + (** names of variables that are guaranteed to be initialized once the method is executed, eg + ["std::cerr"] *) } let parse_siof_model (qual_name, initialized_globals) = {qual_name; initialized_globals} diff --git a/infer/src/checkers/Source.mli b/infer/src/checkers/Source.mli index cfd1223d5..9d198ed9e 100644 --- a/infer/src/checkers/Source.mli +++ b/infer/src/checkers/Source.mli @@ -34,7 +34,8 @@ module type S = sig ; 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 - (** return Some (taint spec) if the call site with the given actuals is a taint source, None otherwise *) + (** return Some (taint spec) if the call site 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 (** return each formal of the function paired with either Some(source) if the formal is a taint diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index bb6712c72..835fa1c16 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -66,7 +66,7 @@ module type S = sig val get_reports : ?cur_site:CallSite.t -> t -> report list (** get the reportable source-sink flows in this trace. specifying [cur_site] restricts the - reported paths to ones introduced by the call at [cur_site] *) + 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 diff --git a/infer/src/checkers/Trace.mli b/infer/src/checkers/Trace.mli index d7e7f5f46..225adae95 100644 --- a/infer/src/checkers/Trace.mli +++ b/infer/src/checkers/Trace.mli @@ -75,7 +75,7 @@ module type S = sig val get_reports : ?cur_site:CallSite.t -> t -> report list (** get the reportable source-sink flows in this trace. specifying [cur_site] restricts the - reported paths to ones introduced by the call at [cur_site] *) + 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 diff --git a/infer/src/checkers/TraceElem.ml b/infer/src/checkers/TraceElem.ml index 90898511c..004c83616 100644 --- a/infer/src/checkers/TraceElem.ml +++ b/infer/src/checkers/TraceElem.ml @@ -13,9 +13,9 @@ module type Kind = sig val matches : caller:t -> callee:t -> bool (** Return true if the [caller] element kind matches the [callee] element kind. Used during trace - expansion; we will only consider expanding the trace from caller into callee if this - evaluates to true. This can normally just be [equal], but something fuzzier may be required - if [t] is a type that contains identifiers from the caller/callee *) + expansion; we will only consider expanding the trace from caller into callee if this evaluates + to true. This can normally just be [equal], but something fuzzier may be required if [t] is a + type that contains identifiers from the caller/callee *) val pp : F.formatter -> t -> unit end diff --git a/infer/src/checkers/accessPathDomains.mli b/infer/src/checkers/accessPathDomains.mli index 366e48dae..c2d4c5d54 100644 --- a/infer/src/checkers/accessPathDomains.mli +++ b/infer/src/checkers/accessPathDomains.mli @@ -20,8 +20,8 @@ module Set : sig val of_list : AccessPath.Abs.t list -> t val mem : AccessPath.Abs.t -> t -> bool - (** return true if {% \gamma(\{ap\}) \subseteq \gamma(aps) %}. - note: this is worst-case linear in the size of the set *) + (** return true if {% \gamma(\{ap\}) \subseteq \gamma(aps) %}. note: this is worst-case linear in + the size of the set *) val mem_fuzzy : AccessPath.Abs.t -> t -> bool (** more permissive version of [mem]; return true if {% \gamma(\{a\}) \cap \gamma(aps) != \{\} %}. @@ -31,6 +31,6 @@ module Set : sig val normalize : t -> t (** simplify an access path set to its canonical representation by eliminating redundancies - between (1) pairs of abstracted access_paths, and (2) exact access paths and abstracted - access paths. warning: this is quadratic in the size of the set! use sparingly *) + between (1) pairs of abstracted access_paths, and (2) exact access paths and abstracted access + paths. warning: this is quadratic in the size of the set! use sparingly *) end diff --git a/infer/src/checkers/accessTree.mli b/infer/src/checkers/accessTree.mli index 81025cbf8..85ed33778 100644 --- a/infer/src/checkers/accessTree.mli +++ b/infer/src/checkers/accessTree.mli @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (** tree of (trace, access path) associations organized by structure of access paths *) diff --git a/infer/src/checkers/annotations.ml b/infer/src/checkers/annotations.ml index c0460758a..05557eb8e 100644 --- a/infer/src/checkers/annotations.ml +++ b/infer/src/checkers/annotations.ml @@ -225,12 +225,12 @@ let field_injector_readwrite_list = let field_injector_readonly_list = inject :: field_injector_readwrite_list -(** Annotations for readonly injectors. - The injector framework initializes the field but does not write null into it. *) +(** Annotations for readonly injectors. The injector framework initializes the field but does not + write null into it. *) let ia_is_field_injector_readonly ia = List.exists ~f:(ia_ends_with ia) field_injector_readonly_list -(** Annotations for read-write injectors. - The injector framework initializes the field and can write null into it. *) +(** Annotations for read-write injectors. The injector framework initializes the field and can write + null into it. *) let ia_is_field_injector_readwrite ia = List.exists ~f:(ia_ends_with ia) field_injector_readwrite_list diff --git a/infer/src/checkers/annotations.mli b/infer/src/checkers/annotations.mli index e6bd8c684..1e43e77d7 100644 --- a/infer/src/checkers/annotations.mli +++ b/infer/src/checkers/annotations.mli @@ -65,12 +65,12 @@ val ia_is_initializer : Annot.Item.t -> bool val ia_is_cleanup : Annot.Item.t -> bool val ia_is_field_injector_readonly : Annot.Item.t -> bool -(** Annotations for readonly injectors. - The injector framework initializes the field but does not write null into it. *) +(** Annotations for readonly injectors. The injector framework initializes the field but does not + write null into it. *) val ia_is_field_injector_readwrite : Annot.Item.t -> bool -(** Annotations for read-write injectors. - The injector framework initializes the field and can write null into it. *) +(** Annotations for read-write injectors. The injector framework initializes the field and can write + null into it. *) val ia_is_nonnull : Annot.Item.t -> bool @@ -116,8 +116,7 @@ val pdesc_get_return_annot : Procdesc.t -> Annot.Item.t (** get the list of annotations on the return value of [pdesc] *) 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 *) +(** 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 diff --git a/infer/src/checkers/control.ml b/infer/src/checkers/control.ml index 75cc8cbf2..b99b4713b 100644 --- a/infer/src/checkers/control.ml +++ b/infer/src/checkers/control.ml @@ -36,16 +36,16 @@ end module ControlDepSet = AbstractDomain.FiniteSet (CVar) module ControlMap = PrettyPrintable.MakePPMap (Var) -(** Map control var -> loop head location *) +(** Map control var -> loop head location *) module GuardNodes = AbstractDomain.FiniteSet (Procdesc.Node) module LoopHeads = Procdesc.NodeSet module ExitNodeToLoopHeads = Procdesc.NodeMap -(** Map exit node -> loop head set *) +(** Map exit node -> loop head set *) module LoopHeadToGuardNodes = Procdesc.NodeMap -(** Map loop head -> prune nodes in the loop guard *) +(** Map loop head -> prune nodes in the loop guard *) type loop_control_maps = { exit_map: LoopHeads.t ExitNodeToLoopHeads.t diff --git a/infer/src/checkers/control.mli b/infer/src/checkers/control.mli index fc68b36d9..7e136d7e7 100644 --- a/infer/src/checkers/control.mli +++ b/infer/src/checkers/control.mli @@ -10,15 +10,15 @@ module LoopHead = Procdesc.Node module LoopHeads = Procdesc.NodeSet module ControlMap : module type of PrettyPrintable.MakePPMap (Var) -(** Map control var -> loop head location *) +(** Map control var -> loop head location *) module GuardNodes : module type of AbstractDomain.FiniteSet (Procdesc.Node) module ExitNodeToLoopHeads = Procdesc.NodeMap -(** Map exit node -> loop head set *) +(** Map exit node -> loop head set *) module LoopHeadToGuardNodes = Procdesc.NodeMap -(** Map loop head -> prune nodes in the loop guard *) +(** Map loop head -> prune nodes in the loop guard *) type invariant_map diff --git a/infer/src/checkers/cost.ml b/infer/src/checkers/cost.ml index a3d264200..aec56f8a0 100644 --- a/infer/src/checkers/cost.ml +++ b/infer/src/checkers/cost.ml @@ -390,18 +390,21 @@ module ConstraintSolver = struct loop max - (** - Infer equalities from sums, like this: - (1) A + sum1 = A + sum2 => sum1 = sum2 + (** Infer equalities from sums, like this: - It does not try to saturate - (2) A = B + C /\ B = D + E => A = C + D + E - Nor combine more than 2 equations - (3) A = B + C /\ B = D + E /\ F = C + D + E => A = F - ((3) is implied by (1) /\ (2)) + (1) A + sum1 = A + sum2 => sum1 = sum2 - Its complexity is unknown but I think it is bounded by nbNodes x nbEdges x max. - *) + It does not try to saturate + + (2) A = B + C /\ B = D + E => A = C + D + E + + Nor combine more than 2 equations + + (3) A = B + C /\ B = D + E /\ F = C + D + E => A = F + + ((3) is implied by (1) /\ (2)) + + Its complexity is unknown but I think it is bounded by nbNodes x nbEdges x max. *) let infer_equalities_from_sums ~debug equalities ~max = let normalizer = normalizer equalities in let f ~did_improve (_repr, set) = @@ -429,10 +432,9 @@ module ConstraintSolver = struct ControlFlowCost.Set.init_cost ~of_node set ) - (** - From sums: if A = B + C, do cost(A) = min(cost(A), cost(B) + cost(C)) - From inequalities: if A = B + C, then B <= A, do cost(B) = min(cost(B), cost(A)) - *) + (** From sums: if A = B + C, do cost(A) = min(cost(A), cost(B) + cost(C)) + + From inequalities: if A = B + C, then B <= A, do cost(B) = min(cost(B), cost(A)) *) let improve_costs ~debug equalities ~max = let of_item (item : ControlFlowCost.Item.t) = (item :> ControlFlowCost.t) @@ -649,15 +651,13 @@ module ThresholdReports = struct CostIssues.enabled_cost_map none end -(** Calculate the final Worst Case Cost predicted for each cost field - and each WTO component. It is the dot product of the symbolic cost - of the node and how many times it is executed. *) +(** Calculate the final Worst Case Cost predicted for each cost field and each WTO component. It is + the dot product of the symbolic cost of the node and how many times it is executed. *) module WorstCaseCost = struct type astate = {costs: CostDomain.t; reports: ThresholdReports.t} - (** We don't report when the cost is Top as it corresponds to - subsequent 'don't know's. Instead, we report Top cost only at - the top level per function. *) + (** We don't report when the cost is Top as it corresponds to subsequent 'don't know's. Instead, + we report Top cost only at the top level per function. *) let should_report_cost cost ~threshold = (not (BasicCost.is_top cost)) && not (BasicCost.leq ~lhs:cost ~rhs:threshold) diff --git a/infer/src/checkers/costDomain.ml b/infer/src/checkers/costDomain.ml index de686962b..35d66181a 100644 --- a/infer/src/checkers/costDomain.ml +++ b/infer/src/checkers/costDomain.ml @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd module F = Format diff --git a/infer/src/checkers/costUtils.ml b/infer/src/checkers/costUtils.ml index fd5f98f8b..5f58e3c58 100644 --- a/infer/src/checkers/costUtils.ml +++ b/infer/src/checkers/costUtils.ml @@ -19,8 +19,8 @@ let of_itv ~(itv : Itv.t) ~degree_kind ~of_function loc = |> BasicCost.of_non_negative_bound ~degree_kind -(** Given a string of length n and an optional starting index i (0 by - default), return itv [0, n_u-i_l] *) +(** Given a string of length n and an optional starting index i (0 by default), return itv + [0, n_u-i_l] *) let string_len_range_itv model_env exp ~from mem = let itv = BufferOverrunModels.JavaString.get_length model_env exp mem |> BufferOverrunDomain.Val.get_itv diff --git a/infer/src/checkers/dataflow.mli b/infer/src/checkers/dataflow.mli index 33854f484..ef715417b 100644 --- a/infer/src/checkers/dataflow.mli +++ b/infer/src/checkers/dataflow.mli @@ -41,8 +41,8 @@ module type DF = sig val join : state list -> state -> state val run : Tenv.t -> Procdesc.t -> state -> Procdesc.Node.t -> transition - (** Run the dataflow analysis on a procedure starting from the given state. - Returns a function to lookup the results of the analysis on every node *) + (** Run the dataflow analysis on a procedure starting from the given state. Returns a function to + lookup the results of the analysis on every node *) end (** Functor to create an instance of a dataflow analysis. *) diff --git a/infer/src/checkers/idenv.ml b/infer/src/checkers/idenv.ml index 701a95fbf..0a8d1e56a 100644 --- a/infer/src/checkers/idenv.ml +++ b/infer/src/checkers/idenv.ml @@ -7,8 +7,8 @@ open! IStd -(** Environment for temporary identifiers used in instructions. - Lazy implementation: only created when actually used. *) +(** Environment for temporary identifiers used in instructions. Lazy implementation: only created + when actually used. *) type t = Exp.t Ident.Hash.t Lazy.t diff --git a/infer/src/checkers/idenv.mli b/infer/src/checkers/idenv.mli index 36dc2bba1..a97607df9 100644 --- a/infer/src/checkers/idenv.mli +++ b/infer/src/checkers/idenv.mli @@ -7,8 +7,8 @@ open! IStd -(** Environment for temporary identifiers used in instructions. - Lazy implementation: only created when actually used. *) +(** Environment for temporary identifiers used in instructions. Lazy implementation: only created + when actually used. *) type t diff --git a/infer/src/checkers/impurity.ml b/infer/src/checkers/impurity.ml index 3842f6173..63c7e7c1f 100644 --- a/infer/src/checkers/impurity.ml +++ b/infer/src/checkers/impurity.ml @@ -47,10 +47,10 @@ let add_invalid_and_modified ~check_empty attrs acc = else res @ acc -(** Given Pulse summary, extract impurity info, i.e. parameters and - global variables that are modified by the function. +(** Given Pulse summary, extract impurity info, i.e. parameters and global variables that are + modified by the function. - TODO: keep track of impure library calls *) + TODO: keep track of impure library calls *) let extract_impurity pdesc pre_post : ImpurityDomain.t = let pre_heap = (AbductiveDomain.extract_pre pre_post).BaseDomain.heap in let post_heap = (AbductiveDomain.extract_post pre_post).BaseDomain.heap in diff --git a/infer/src/checkers/inefficientKeysetIterator.ml b/infer/src/checkers/inefficientKeysetIterator.ml index 2c1d17589..960fb27fc 100644 --- a/infer/src/checkers/inefficientKeysetIterator.ml +++ b/infer/src/checkers/inefficientKeysetIterator.ml @@ -30,13 +30,15 @@ let implements_map tenv s = PatternMatch.implements_map tenv s || PatternMatch.implements_androidx_map tenv s -(** If given a node that has 4 instructions and calls fun_name, - pickup bcvarY, i.e. variable for the first argument +(** If given a node that has 4 instructions and calls fun_name, pickup bcvarY, i.e. variable for the + first argument + + {v n$X = *&$bcvarY _ = *n$X n$X+1 = fun_name(n$X,....) *&$irvarZ = n$X+1 - *) + v} *) let find_first_arg_pvar node ~fun_name ~class_name_f = let instrs = Procdesc.Node.get_instrs node in if Instrs.count instrs >= 4 then diff --git a/infer/src/checkers/liveness.ml b/infer/src/checkers/liveness.ml index bc5a0437d..6c89aa634 100644 --- a/infer/src/checkers/liveness.ml +++ b/infer/src/checkers/liveness.ml @@ -41,14 +41,14 @@ module type LivenessConfig = sig end (** Use this config to get a reliable liveness pre-analysis that tells you which variables are live - at which program point *) + at which program point *) module PreAnalysisMode : LivenessConfig = struct (** do not do any funky stuff *) let is_blacklisted_destructor _proc_name = false end (** Use this config to get a dead store checker that can take some liberties wrt a strict liveness - analysis *) + analysis *) module CheckerMode : LivenessConfig = struct let blacklisted_destructor_matcher = QualifiedCppName.Match.of_fuzzy_qual_names diff --git a/infer/src/checkers/loopInvariant.ml b/infer/src/checkers/loopInvariant.ml index 29ce9a9d0..07110ceab 100644 --- a/infer/src/checkers/loopInvariant.ml +++ b/infer/src/checkers/loopInvariant.ml @@ -261,12 +261,11 @@ let get_inv_vars_in_loop tenv reaching_defs_invariant_map ~is_pure_by_default ~g module LoopHeadToInvVars = Procdesc.NodeMap -(** Map loop head -> invariant vars in loop *) +(** Map loop head -> invariant vars in loop *) type invariant_map = VarSet.t LoopHeadToInvVars.t -(** This is invoked by cost analysis, hence assume that unmodeled - calls are pure by default *) +(** This is invoked by cost analysis, hence assume that unmodeled calls are pure by default *) let get_loop_inv_var_map tenv get_callee_purity reaching_defs_invariant_map loop_head_to_loop_nodes : invariant_map = LoopHeadToLoopNodes.fold diff --git a/infer/src/checkers/loopInvariant.mli b/infer/src/checkers/loopInvariant.mli index eb110d0f6..1e46646cc 100644 --- a/infer/src/checkers/loopInvariant.mli +++ b/infer/src/checkers/loopInvariant.mli @@ -19,7 +19,7 @@ module LoopHeadToLoopNodes = Procdesc.NodeMap (** Map loop header node -> all nodes in the loop *) module LoopHeadToInvVars = Procdesc.NodeMap -(** Map loop head -> invariant vars in loop *) +(** Map loop head -> invariant vars in loop *) type invariant_map = VarsInLoop.t Procdesc.NodeMap.t diff --git a/infer/src/checkers/loop_control.ml b/infer/src/checkers/loop_control.ml index 34190cc0f..f0870d5a8 100644 --- a/infer/src/checkers/loop_control.ml +++ b/infer/src/checkers/loop_control.ml @@ -72,11 +72,8 @@ let get_exit_nodes_in_loop loop_nodes = Control.GuardNodes.diff succs_of_loop_nodes loop_nodes |> Control.GuardNodes.elements -(** - Starting from the start_nodes, find all the nodes upwards until the - target is reached, i.e picking up predecessors which have not been - already added to the found_nodes -*) +(** Starting from the start_nodes, find all the nodes upwards until the target is reached, i.e + picking up predecessors which have not been already added to the found_nodes *) let get_all_nodes_upwards_until target start_nodes = let rec aux found_nodes = function | [] -> @@ -94,11 +91,8 @@ let is_prune node = match Procdesc.Node.get_kind node with Procdesc.Node.Prune_node _ -> true | _ -> false -(** - Remove pairs of prune nodes that are for the same condition, - i.e. sibling of the same parent. This is necessary to prevent - picking unnecessary control variables in do-while like loops -*) +(** Remove pairs of prune nodes that are for the same condition, i.e. sibling of the same parent. + This is necessary to prevent picking unnecessary control variables in do-while like loops *) let remove_prune_node_pairs exit_nodes guard_nodes = let exit_nodes = Control.GuardNodes.of_list exit_nodes in let except_exit_nodes = Control.GuardNodes.diff guard_nodes exit_nodes in @@ -112,10 +106,8 @@ let remove_prune_node_pairs exit_nodes guard_nodes = |> Control.GuardNodes.union exit_nodes -(** - Since there could be multiple back-edges per loop, collect all source nodes per loop head. - loop_head (target of back-edges) --> source nodes -*) +(** Since there could be multiple back-edges per loop, collect all source nodes per loop head. + loop_head (target of back-edges) --> source nodes *) let get_loop_head_to_source_nodes cfg = get_back_edges cfg |> List.fold ~init:Procdesc.NodeMap.empty ~f:(fun loop_head_to_source_list {source; target} -> @@ -124,13 +116,10 @@ let get_loop_head_to_source_nodes cfg = loop_head_to_source_list ) -(** - Get a pair of maps (exit_map, loop_head_to_guard_map) where - exit_map : exit_node -> loop_head set (i.e. target of the back edges) - loop_head_to_guard_map : loop_head -> guard_nodes and - guard_nodes contains the nodes that may affect the looping behavior, i.e. - occur in the guard of the loop conditional. -*) +(** Get a pair of maps (exit_map, loop_head_to_guard_map) where exit_map : exit_node -> loop_head + set (i.e. target of the back edges) loop_head_to_guard_map : loop_head -> guard_nodes and + guard_nodes contains the nodes that may affect the looping behavior, i.e. occur in the guard of + the loop conditional. *) let get_control_maps loop_head_to_source_nodes_map = Procdesc.NodeMap.fold (fun loop_head source_list diff --git a/infer/src/checkers/loop_control.mli b/infer/src/checkers/loop_control.mli index 5fbf600b9..230c84bcc 100644 --- a/infer/src/checkers/loop_control.mli +++ b/infer/src/checkers/loop_control.mli @@ -8,24 +8,16 @@ open! IStd val get_all_nodes_upwards_until : Procdesc.Node.t -> Procdesc.Node.t list -> Control.GuardNodes.t -(** - Starting from the start_nodes, find all the nodes upwards until the - target is reached, i.e picking up predecessors which have not been - already added to the found_nodes -*) +(** Starting from the start_nodes, find all the nodes upwards until the target is reached, i.e + picking up predecessors which have not been already added to the found_nodes *) val get_loop_head_to_source_nodes : Procdesc.t -> Procdesc.Node.t list Procdesc.NodeMap.t -(** - Since there could be multiple back-edges per loop, collect all source nodes per loop head. - loop_head (target of back-edges) --> source nodes -*) +(** Since there could be multiple back-edges per loop, collect all source nodes per loop head. + loop_head (target of back-edges) --> source nodes *) val get_loop_control_maps : Procdesc.t -> Control.loop_control_maps * Control.GuardNodes.t Procdesc.NodeMap.t -(** - Get a pair of maps (exit_map, loop_head_to_guard_map) where - exit_map : exit_node -> loop_head set (i.e. target of the back edges) - loop_head_to_guard_map : loop_head -> guard_nodes and - guard_nodes contains the nodes that may affect the looping behavior, i.e. - occur in the guard of the loop conditional. -*) +(** Get a pair of maps (exit_map, loop_head_to_guard_map) where exit_map : exit_node -> loop_head + set (i.e. target of the back edges) loop_head_to_guard_map : loop_head -> guard_nodes and + guard_nodes contains the nodes that may affect the looping behavior, i.e. occur in the guard of + the loop conditional. *) diff --git a/infer/src/checkers/reachingDefs.ml b/infer/src/checkers/reachingDefs.ml index 1f1b020b5..59e209e1d 100644 --- a/infer/src/checkers/reachingDefs.ml +++ b/infer/src/checkers/reachingDefs.ml @@ -11,9 +11,8 @@ module NodeCFG = ProcCfg.Normal module Defs = AbstractDomain.FiniteSet (Procdesc.Node) (** The node in which the reaching definition x := e is defined. - A definition x :=e, declared at node N, reaches the current node - if there is a path from node N to the current node such that x is - not modified along the path **) + A definition x :=e, declared at node N, reaches the current node if there is a path from node N + to the current node such that x is not modified along the path **) (* even though we only add singletons (defs), the set is needed for joins *) diff --git a/infer/src/checkers/reachingDefs.mli b/infer/src/checkers/reachingDefs.mli index 7f665f47b..42bee00d5 100644 --- a/infer/src/checkers/reachingDefs.mli +++ b/infer/src/checkers/reachingDefs.mli @@ -10,9 +10,8 @@ open! IStd module Defs : module type of AbstractDomain.FiniteSet (Procdesc.Node) (** The node in which the reaching definition x := e is defined. - A definition x :=e, declared at node N, reaches the current node - if there is a path from node N to the current node such that x is - not modified along the path **) + A definition x :=e, declared at node N, reaches the current node if there is a path from node N + to the current node such that x is not modified along the path **) module ReachingDefsMap : module type of AbstractDomain.Map (Var) (Defs) (** Map var -> its reaching definition *) diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index b4929e31a..55fb6e849 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -75,8 +75,9 @@ module BuildMethodSignature = struct (** Returns parameters of a function/method. They will have following order: - 1. normal parameters - 2. return parameter (optional) *) + + + normal parameters + + return parameter (optional) *) let get_parameters qual_type_to_sil_type tenv ~block_return_type method_decl = let open Clang_ast_t in let par_to_ms_par par = diff --git a/infer/src/clang/CType_decl.mli b/infer/src/clang/CType_decl.mli index 601d0ac3f..850a3f3ef 100644 --- a/infer/src/clang/CType_decl.mli +++ b/infer/src/clang/CType_decl.mli @@ -14,14 +14,14 @@ module CProcname : sig -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t - (** Given decl, return its procname. This function should be used for all procedures - present in original AST *) + (** 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 - (** 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 method name only based on the - first part of the name without the parameters *) + (** 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 + method name only based on the first part of the name without the parameters *) (** WARNING: functions from this module should not be used if full decl is available in AST *) module NoAstDecl : sig diff --git a/infer/src/clang/Capture.ml b/infer/src/clang/Capture.ml index dc7c608f4..da5bb5595 100644 --- a/infer/src/clang/Capture.ml +++ b/infer/src/clang/Capture.ml @@ -11,7 +11,7 @@ module L = Logging let debug_mode = Config.debug_mode || Config.frontend_stats (** This function reads the json file in fname, validates it, and encodes in the AST data structure - defined in Clang_ast_t. *) + defined in Clang_ast_t. *) let validate_decl_from_file fname = Atdgen_runtime.Util.Biniou.from_file ~len:CFrontend_config.biniou_buffer_size Clang_ast_b.read_decl fname @@ -22,7 +22,8 @@ let validate_decl_from_channel chan = Clang_ast_b.read_decl chan -(**FIXME(T54413835): Make the perf stats in the frontend work when one runs more than one frontend action *) +(**FIXME(T54413835): Make the perf stats in the frontend work when one runs more than one frontend + action *) let register_perf_stats_report source_file = let stats_type = if Config.capture then PerfStats.ClangFrontend source_file diff --git a/infer/src/clang/ClangCommand.ml b/infer/src/clang/ClangCommand.ml index 42a225fcd..bb30ae07d 100644 --- a/infer/src/clang/ClangCommand.ml +++ b/infer/src/clang/ClangCommand.ml @@ -80,7 +80,8 @@ let libcxx_include_to_override_regex = (** Filter arguments from [args], looking into argfiles too. [replace_options_arg prev arg] returns - [arg'], where [arg'] is the new version of [arg] given the preceding arguments (in reverse order) [prev]. *) + [arg'], where [arg'] is the new version of [arg] given the preceding arguments (in reverse + order) [prev]. *) let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?(post_args = []) ?(pre_args = []) args = (* [prev] is the previously seen argument, [res_rev] is the reversed result, [changed] is true if @@ -141,9 +142,9 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?( List.append pre_args (List.rev_append res_rev post_args) -(** Work around various path or library issues occurring when one tries to substitute Apple's version - of clang with a different version. Also mitigate version discrepancies in clang's - fatal warnings. *) +(** Work around various path or library issues occurring when one tries to substitute Apple's + version of clang with a different version. Also mitigate version discrepancies in clang's fatal + warnings. *) let clang_cc1_cmd_sanitizer cmd = let replace_args arg = function | Some override_regex when Str.string_match override_regex arg 0 -> diff --git a/infer/src/clang/ClangCommand.mli b/infer/src/clang/ClangCommand.mli index e2c6fbae2..86ac01064 100644 --- a/infer/src/clang/ClangCommand.mli +++ b/infer/src/clang/ClangCommand.mli @@ -11,23 +11,25 @@ type t val mk : is_driver:bool -> ClangQuotes.style -> prog:string -> args:string list -> t (** [mk ~is_driver qs prog args] finds the type of command depending on its arguments [args]. The - quoting style of the arguments have to be provided, so that the command may be run later - on. Beware that this doesn't look inside argument files. This can be used to create a "clang -### - ..." command on which to call [command_to_run], but other functions from the module will not work - as expected unless the command has been normalized by "clang -### ...". *) + quoting style of the arguments have to be provided, so that the command may be run later on. + Beware that this doesn't look inside argument files. This can be used to create a "clang -### + ..." command on which to call [command_to_run], but other functions from the module will not + work as expected unless the command has been normalized by "clang -### ...". *) val command_to_run : t -> string (** Make a command into a string ready to be passed to a shell to be executed. Fine to call with clang driver commands. *) val can_attach_ast_exporter : t -> bool -(** Whether the command is suitable for attaching the AST exporter. Must be called on normalized commands. *) +(** Whether the command is suitable for attaching the AST exporter. Must be called on normalized + commands. *) val may_capture : t -> bool (** Whether the command has a chance of triggering compilation steps we can capture. *) val with_plugin_args : t -> t -(** Add the arguments needed to attach the facebook-clang-plugins plugin. Must be called on normalized commands. *) +(** Add the arguments needed to attach the facebook-clang-plugins plugin. Must be called on + normalized commands. *) val prepend_arg : string -> t -> t diff --git a/infer/src/clang/ClangWrapper.ml b/infer/src/clang/ClangWrapper.ml index 4f9acfb35..364c545e7 100644 --- a/infer/src/clang/ClangWrapper.ml +++ b/infer/src/clang/ClangWrapper.ml @@ -52,7 +52,7 @@ let check_for_existing_file args = (** Given a clang command, return a list of new commands to run according to the results of `clang - -### [args]`. *) + \-### [args]`. *) let clang_driver_action_items : ClangCommand.t -> action_item list = fun cmd -> let clang_hashhashhash = diff --git a/infer/src/clang/ast_expressions.mli b/infer/src/clang/ast_expressions.mli index b5cb38b58..4776ff945 100644 --- a/infer/src/clang/ast_expressions.mli +++ b/infer/src/clang/ast_expressions.mli @@ -29,9 +29,7 @@ val make_obj_c_message_expr_info_class : val make_function_call : stmt_info -> string -> stmt list -> stmt val trans_with_conditional : stmt_info -> expr_info -> stmt list -> stmt -(** We translate an expression with a conditional - x <=> x?1:0 *) +(** We translate an expression with a conditional x <=> x?1:0 *) val trans_negation_with_conditional : stmt_info -> expr_info -> stmt list -> stmt -(** We translate the logical negation of an expression with a conditional - !x <=> x?0:1 *) +(** We translate the logical negation of an expression with a conditional !x <=> x?0:1 *) diff --git a/infer/src/clang/cArithmetic_trans.ml b/infer/src/clang/cArithmetic_trans.ml index e84273d75..4a98df832 100644 --- a/infer/src/clang/cArithmetic_trans.ml +++ b/infer/src/clang/cArithmetic_trans.ml @@ -47,8 +47,8 @@ let compound_assignment_binary_operation_instruction boi_kind (e1, t1) typ e2 lo (** Returns a pair ([binary_expression], instructions). "binary_expression" is returned when we are - calculating an expression "instructions" is not empty when the binary operator is actually a - statement like an assignment. *) + calculating an expression "instructions" is not empty when the binary operator is actually a + statement like an assignment. *) let binary_operation_instruction source_range boi ((e1, t1) as e1_with_typ) typ (e2, t2) loc = let binop_exp ?(change_order = false) op = if change_order then Exp.BinOp (op, e2, e1) else Exp.BinOp (op, e1, e2) diff --git a/infer/src/clang/cArithmetic_trans.mli b/infer/src/clang/cArithmetic_trans.mli index 6ff919940..68784487c 100644 --- a/infer/src/clang/cArithmetic_trans.mli +++ b/infer/src/clang/cArithmetic_trans.mli @@ -20,8 +20,8 @@ val binary_operation_instruction : -> Location.t -> Exp.t * Sil.instr list (** Returns a pair ([binary_expression], instructions). "binary_expression" is returned when we are - calculating an expression "instructions" is not empty when the binary operator is actually a - statement like an assignment. *) + calculating an expression "instructions" is not empty when the binary operator is actually a + statement like an assignment. *) val unary_operation_instruction : CFrontend_config.translation_unit_context diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index 9c21662f5..d84ee6e2b 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -50,12 +50,12 @@ val get_type : Clang_ast_t.type_ptr -> Clang_ast_t.c_type option (** looks up clang pointer to type and returns c_type. It requires type_ptr to be `TPtr. *) val get_desugared_type : Clang_ast_t.type_ptr -> Clang_ast_t.c_type option -(** looks up clang pointer to type and resolves any sugar around it. - See get_type for more info and restrictions *) +(** looks up clang pointer to type and resolves any sugar around it. See get_type for more info and + restrictions *) val get_decl_from_typ_ptr : Clang_ast_t.type_ptr -> Clang_ast_t.decl option -(** returns declaration of the type for certain types - (RecordType, ObjCInterfaceType and None for others *) +(** returns declaration of the type for certain types (RecordType, ObjCInterfaceType and None for + others *) val name_of_typedef_type_info : Clang_ast_t.typedef_type_info -> QualifiedCppName.t @@ -101,8 +101,7 @@ val generate_key_decl : Clang_ast_t.decl -> string (** Generates a key for a declaration based on its name and the declaration tag. *) val get_super_if : Clang_ast_t.decl option -> Clang_ast_t.decl option -(** Given an objc impl or interface decl, returns the objc interface decl of - the superclass, if any. *) +(** Given an objc impl or interface decl, returns the objc interface decl of the superclass, if any. *) val get_impl_decl_info : Clang_ast_t.decl -> Clang_ast_t.obj_c_implementation_decl_info option @@ -111,14 +110,11 @@ val get_super_ObjCImplementationDecl : (** Given an objc impl decl info, return its super class implementation decl *) val is_objc_if_descendant : ?blacklist:string list -> Clang_ast_t.decl option -> string list -> bool -(** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl. - Returns true if the passed in decl is an objc interface decl that's an - eventual descendant of one of the classes passed in. - Ancestors param is a list of strings that represent the class names. - Will short-circuit on NSObject and NSProxy since those are known to be - common base classes. - The list of classes to short-circuit on can be overridden via specifying - the named `blacklist` argument. *) +(** Recursively go up the inheritance hierarchy of a given ObjCInterfaceDecl. Returns true if the + passed in decl is an objc interface decl that's an eventual descendant of one of the classes + passed in. Ancestors param is a list of strings that represent the class names. Will + short-circuit on NSObject and NSProxy since those are known to be common base classes. The list + of classes to short-circuit on can be overridden via specifying the named `blacklist` argument. *) val qual_type_to_objc_interface : Clang_ast_t.qual_type -> Clang_ast_t.decl option diff --git a/infer/src/clang/cContext.mli b/infer/src/clang/cContext.mli index 86727370f..bf6843eb2 100644 --- a/infer/src/clang/cContext.mli +++ b/infer/src/clang/cContext.mli @@ -7,8 +7,8 @@ open! IStd -(** Contains current class and current method to be translated as well as local variables, - and the cfg, and tenv corresponding to the current file. *) +(** Contains current class and current method to be translated as well as local variables, and the + cfg, and tenv corresponding to the current file. *) module StmtMap = ClangPointers.Map diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index fb2098b9a..73592ca23 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -255,8 +255,8 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron List.iter ~f:(process_one_method_decl trans_unit_ctx tenv cfg curr_class) decl_list - (** Given REVERSED list of method qualifiers (method_name::class_name::rest_quals), return - whether method should be translated based on method and class whitelists *) + (** Given REVERSED list of method qualifiers (method_name::class_name::rest_quals), return whether + method should be translated based on method and class whitelists *) let is_whitelisted_cpp_method = let method_matcher = QualifiedCppName.Match.of_fuzzy_qual_names Config.whitelisted_cpp_methods diff --git a/infer/src/clang/cFrontend_errors.mli b/infer/src/clang/cFrontend_errors.mli index febfbb13c..f1421b69e 100644 --- a/infer/src/clang/cFrontend_errors.mli +++ b/infer/src/clang/cFrontend_errors.mli @@ -34,8 +34,8 @@ val incorrect_assumption : -> ?ast_node:string -> ('a, Format.formatter, unit, _) format4 -> 'a -(** Used to mark places in the frontend that incorrectly assume something to be - impossible. TODO(t21762295) get rid of all instances of this. *) +(** Used to mark places in the frontend that incorrectly assume something to be impossible. + TODO(t21762295) get rid of all instances of this. *) val protect : f:(unit -> unit) diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index fab476f20..2024f3124 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -40,7 +40,7 @@ let should_do_frontend_check translation_unit (loc_start, _) = false -(** We translate by default the instructions in the current file. In C++ development, we also +(** We translate by default the instructions in the current file. In C++ development, we also translate the headers that are part of the project. However, in testing mode, we don't want to translate the headers because the dot files in the frontend tests should contain nothing else than the source file to avoid conflicts between different versions of the libraries. *) diff --git a/infer/src/clang/cMethodSignature.ml b/infer/src/clang/cMethodSignature.ml index 54ee6e0d2..697b84605 100644 --- a/infer/src/clang/cMethodSignature.ml +++ b/infer/src/clang/cMethodSignature.ml @@ -8,7 +8,7 @@ open! IStd (** Define the signature of a method consisting of its name, its arguments, return type, location - and whether its an instance method. *) + and whether its an instance method. *) module F = Format diff --git a/infer/src/clang/cMethodSignature.mli b/infer/src/clang/cMethodSignature.mli index 3e6fb8833..b63f62cd8 100644 --- a/infer/src/clang/cMethodSignature.mli +++ b/infer/src/clang/cMethodSignature.mli @@ -8,7 +8,7 @@ open! IStd (** Define the signature of a method consisting of its name, its arguments, return type, location - and whether its an instance method. *) + and whether its an instance method. *) type param_type = {name: Mangled.t; typ: Typ.t; is_pointer_to_const: bool; annot: Annot.Item.t} diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index ecb3dc4f0..72c020be6 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -7,12 +7,12 @@ open! IStd -(** Methods for creating a procdesc from a method or function declaration - and for resolving a method call and finding the right callee *) +(** Methods for creating a procdesc from a method or function declaration and for resolving a method + call and finding the right callee *) module L = Logging -(** When the methoc call is MCStatic, means that it is a class method. When it is MCVirtual, it +(** When the methoc call is MCStatic, means that it is a class method. When it is MCVirtual, it means that it is an instance method and that the method to be called will be determined at runtime. If it is MCNoVirtual it means that it is an instance method but that the method to be called will be determined at compile time *) diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index 2c83d3c51..ae385e366 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -7,10 +7,10 @@ open! IStd -(** Methods for creating a procdesc from a method or function declaration - and for resolving a method call and finding the right callee *) +(** Methods for creating a procdesc from a method or function declaration and for resolving a method + call and finding the right callee *) -(** When the methoc call is MCStatic, means that it is a class method. When it is MCVirtual, it +(** When the methoc call is MCStatic, means that it is a class method. When it is MCVirtual, it means that it is an instance method and that the method to be called will be determined at runtime. If it is MCNoVirtual it means that it is an instance method but that the method to be called will be determined at compile time *) diff --git a/infer/src/clang/cScope.ml b/infer/src/clang/cScope.ml index d41254db9..64cff2890 100644 --- a/infer/src/clang/cScope.ml +++ b/infer/src/clang/cScope.ml @@ -79,8 +79,7 @@ module Variables = struct ; swallow_destructors: bool (** That scope does not generate destructor calls (eg because it ends in an instruction that will already do so like [ReturnStmt]). We still want to generate a scope to catch - variables declared in that scope and avoid them being destroyed elsewhere. *) - } + variables declared in that scope and avoid them being destroyed elsewhere. *) } (** get which statements define a variable scope and possible a breakable scope *) let get_scopes stmt = diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index d8a5c16d0..2f572bf96 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd open PolyVariantEqual diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index c0cee8ffa..5f3f332f6 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -8,7 +8,7 @@ open! IStd module Hashtbl = Caml.Hashtbl -(** Utility methods to support the translation of clang ast constructs into sil instructions. *) +(** Utility methods to support the translation of clang ast constructs into sil instructions. *) module L = Logging @@ -118,7 +118,7 @@ let mk_cond_continuation cont = type priority_node = Free | Busy of Clang_ast_t.pointer (** A translation state. It provides the translation function with the info it needs to carry on the - translation. *) + translation. *) type trans_state = { context: CContext.t (** current context of the translation *) ; succ_nodes: Procdesc.Node.t list (** successor nodes in the cfg *) diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index 5cd71349b..4c68d0b9a 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -7,7 +7,7 @@ open! IStd -(** Utility methods to support the translation of clang ast constructs into sil instructions. *) +(** Utility methods to support the translation of clang ast constructs into sil instructions. *) type continuation = { break: Procdesc.Node.t list @@ -18,7 +18,7 @@ type continuation = type priority_node = Free | Busy of Clang_ast_t.pointer (** A translation state. It provides the translation function with the info it needs to carry on the - translation. *) + translation. *) type trans_state = { context: CContext.t (** current context of the translation *) ; succ_nodes: Procdesc.Node.t list (** successor nodes in the cfg *) @@ -30,11 +30,11 @@ type trans_state = val default_trans_state : CContext.t -> trans_state -(** Part of the translation result that is (loosely) related to control flow graph - construction. More importantly, this is the part of a [trans_result] that some internal - translation functions work on when constructing a [trans_result] before the other components of - the translation result are available (such as the return expression). This is made into a - separate type to make intermediate computations easier to write and easier to typecheck. *) +(** Part of the translation result that is (loosely) related to control flow graph construction. + More importantly, this is the part of a [trans_result] that some internal translation functions + work on when constructing a [trans_result] before the other components of the translation result + are available (such as the return expression). This is made into a separate type to make + intermediate computations easier to write and easier to typecheck. *) type control = { root_nodes: Procdesc.Node.t list (** Top cfg nodes (root) created by the translation *) ; leaf_nodes: Procdesc.Node.t list (** Bottom cfg nodes (leaf) created by the translate *) @@ -86,7 +86,7 @@ val is_null_stmt : Clang_ast_t.stmt -> bool val dereference_value_from_result : ?strip_pointer:bool -> Clang_ast_t.source_range -> Location.t -> trans_result -> trans_result (** Given a [trans_result], create a temporary variable with dereferenced value of an expression - assigned to it *) + assigned to it *) val cast_operation : Clang_ast_t.cast_kind -> Exp.t * Typ.t -> Typ.t -> Location.t -> Sil.instr list * (Exp.t * Typ.t) @@ -148,7 +148,7 @@ end (** priority_node is used to enforce some kind of policy for creating nodes in the cfg. Certain elements of the AST _must_ create nodes therefore there is no need for them to use priority_node. Certain elements instead need or need not to create a node depending of certain - factors. When an element of the latter kind wants to create a node it must claim priority first + factors. When an element of the latter kind wants to create a node it must claim priority first (like taking a lock). priority can be claimes only when it is free. If an element of AST succedes in claiming priority its id (pointer) is recorded in priority. After an element has finished it frees the priority. In general an AST element E checks if an ancestor has claimed @@ -193,8 +193,8 @@ module PriorityNode : sig -> Clang_ast_t.stmt_info -> trans_result -> trans_result - (** convenience function like [compute_results_to_parent] when there is a single [trans_result] - to consider *) + (** convenience function like [compute_results_to_parent] when there is a single [trans_result] to + consider *) end (** Module for translating goto instructions by keeping a map of labels. *) diff --git a/infer/src/clang/cVar_decl.ml b/infer/src/clang/cVar_decl.ml index 33124098b..de71c293d 100644 --- a/infer/src/clang/cVar_decl.ml +++ b/infer/src/clang/cVar_decl.ml @@ -7,7 +7,7 @@ open! IStd -(** Process variable declarations by saving them as local or global variables. *) +(** Process variable declarations by saving them as local or global variables. *) (** Computes the local variables of a function or method to be added to the procdesc *) diff --git a/infer/src/clang/cVar_decl.mli b/infer/src/clang/cVar_decl.mli index 739ffae2e..dac301b00 100644 --- a/infer/src/clang/cVar_decl.mli +++ b/infer/src/clang/cVar_decl.mli @@ -7,7 +7,7 @@ open! IStd -(** Process variable declarations by saving them as local or global variables. *) +(** Process variable declarations by saving them as local or global variables. *) (** Computes the local variables of a function or method to be added to the procdesc *) diff --git a/infer/src/clang/objcCategory_decl.ml b/infer/src/clang/objcCategory_decl.ml index 67718d296..48bfd46ea 100644 --- a/infer/src/clang/objcCategory_decl.ml +++ b/infer/src/clang/objcCategory_decl.ml @@ -9,8 +9,8 @@ open! IStd module L = Logging (** In this module an ObjC category declaration or implementation is processed. The category is - saved in the tenv as a struct with the corresponding fields and methods , and the class it - belongs to *) + saved in the tenv as a struct with the corresponding fields and methods , and the class it + belongs to *) let cat_class_decl dr = match dr.Clang_ast_t.dr_name with Some n -> CAst_utils.get_qualified_name n | _ -> assert false diff --git a/infer/src/clang/objcCategory_decl.mli b/infer/src/clang/objcCategory_decl.mli index 679363fe4..0c65686c6 100644 --- a/infer/src/clang/objcCategory_decl.mli +++ b/infer/src/clang/objcCategory_decl.mli @@ -7,9 +7,10 @@ open! IStd -(** In this module an ObjC category declaration or implementation is processed. The category *) +(** In this module an ObjC category declaration or implementation is processed. The category *) -(** is saved in the tenv as a struct with the corresponding fields and methods , and the class it belongs to *) +(** is saved in the tenv as a struct with the corresponding fields and methods , and the class it + belongs to *) val category_decl : CAst_utils.qual_type_to_sil_type diff --git a/infer/src/clang/objcInterface_decl.ml b/infer/src/clang/objcInterface_decl.ml index 0844019b3..6dd5b36be 100644 --- a/infer/src/clang/objcInterface_decl.ml +++ b/infer/src/clang/objcInterface_decl.ml @@ -7,7 +7,7 @@ open! IStd -(** In this module an ObjC interface declaration or implementation is processed. The class *) +(** In this module an ObjC interface declaration or implementation is processed. The class *) (** is saved in the tenv as a struct with the corresponding fields, potential superclass and *) diff --git a/infer/src/clang/objcProperty_decl.ml b/infer/src/clang/objcProperty_decl.ml index a051343b5..0e839dc18 100644 --- a/infer/src/clang/objcProperty_decl.ml +++ b/infer/src/clang/objcProperty_decl.ml @@ -7,7 +7,8 @@ open! IStd -(** Process properties by creating their getters and setters in the case that they need to be syntethized *) +(** Process properties by creating their getters and setters in the case that they need to be + syntethized *) (** or in the case of dynamic. *) diff --git a/infer/src/clang/objcProperty_decl.mli b/infer/src/clang/objcProperty_decl.mli index ad97af059..83d8c5abc 100644 --- a/infer/src/clang/objcProperty_decl.mli +++ b/infer/src/clang/objcProperty_decl.mli @@ -7,7 +7,8 @@ open! IStd -(** Process properties by creating their getters and setters in the case that they need to be synthesized *) +(** Process properties by creating their getters and setters in the case that they need to be + synthesized *) (** or in the case of dynamic. *) diff --git a/infer/src/clang/objcProtocol_decl.mli b/infer/src/clang/objcProtocol_decl.mli index 7dfa7eadc..5cdfcc59a 100644 --- a/infer/src/clang/objcProtocol_decl.mli +++ b/infer/src/clang/objcProtocol_decl.mli @@ -8,6 +8,6 @@ open! IStd (** In this module an ObjC protocol declaration or implementation is processed. The protocol is - saved in the tenv as a struct with the corresponding methods *) + saved in the tenv as a struct with the corresponding methods *) val protocol_decl : CAst_utils.qual_type_to_sil_type -> Tenv.t -> Clang_ast_t.decl -> Typ.desc diff --git a/infer/src/concurrency/ConcurrencyModels.ml b/infer/src/concurrency/ConcurrencyModels.ml index 90a353389..d6722d795 100644 --- a/infer/src/concurrency/ConcurrencyModels.ml +++ b/infer/src/concurrency/ConcurrencyModels.ml @@ -138,10 +138,9 @@ end = struct QualifiedCppName.Match.of_fuzzy_qual_names class_names - (** C++ guard classes used for scope-based lock management. - NB we pretend all classes below implement the mutex interface even though only - [shared_lock] and [unique_lock] do, for simplicity. The comments summarise which - methods are implemented. *) + (** C++ guard classes used for scope-based lock management. NB we pretend all classes below + implement the mutex interface even though only [shared_lock] and [unique_lock] do, for + simplicity. The comments summarise which methods are implemented. *) let guards = (* TODO std::scoped_lock *) [ (* no lock/unlock *) diff --git a/infer/src/concurrency/ConcurrencyModels.mli b/infer/src/concurrency/ConcurrencyModels.mli index baa965e2a..5e35e44f9 100644 --- a/infer/src/concurrency/ConcurrencyModels.mli +++ b/infer/src/concurrency/ConcurrencyModels.mli @@ -23,15 +23,15 @@ type lock_effect = type thread = BackgroundThread | MainThread | MainThreadIfTrue | UnknownThread val is_thread_utils_method : string -> Typ.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 *) +(** 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 (** describe how this procedure behaves with respect to locking *) val get_thread_assert_effect : Typ.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. *) +(** 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 @@ -60,7 +60,8 @@ val annotated_as_worker_thread : val runs_on_ui_thread : attrs_of_pname:(Typ.Procname.t -> ProcAttributes.t option) -> Tenv.t -> Typ.Procname.t -> bool -(** is method not transitively annotated @WorkerThread and is modeled or annotated @UIThread or equivalent? *) +(** 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 (** is method a known Android UI thread callback (eg [Activity.onCreate]) *) diff --git a/infer/src/concurrency/ExplicitTrace.mli b/infer/src/concurrency/ExplicitTrace.mli index d7988854e..3c190d664 100644 --- a/infer/src/concurrency/ExplicitTrace.mli +++ b/infer/src/concurrency/ExplicitTrace.mli @@ -41,7 +41,7 @@ module type TraceElem = sig val map : f:(elem_t -> elem_t) -> t -> t val get_loc : t -> Location.t - (** Starting location of the trace: this is either [loc] if [trace==[]], or the head of [trace]. *) + (** Starting location of the trace: this is either [loc] if [trace==\[\]], or the head of [trace]. *) val make_loc_trace : ?nesting:int -> t -> Errlog.loc_trace diff --git a/infer/src/concurrency/MethodMatcher.ml b/infer/src/concurrency/MethodMatcher.ml index 16c82543a..5c30da7d2 100644 --- a/infer/src/concurrency/MethodMatcher.ml +++ b/infer/src/concurrency/MethodMatcher.ml @@ -21,8 +21,9 @@ let rec strip_template_args str = if String.equal result str then str else strip_template_args result -(** [call_matches C methods] builds a method matcher for calls [C.foo] where - [foo] is in [methods]. Named arguments change behaviour: +(** [call_matches C methods] builds a method matcher for calls [C.foo] where [foo] is + in [methods]. Named arguments change behaviour: + - [search_superclasses=true] will match calls [S.foo] where [S] is a superclass of [C]. - [method_prefix=true] will match calls [C.foo] where [foo] is a prefix of a string in [methods] - [actuals_pred] is a predicate that runs on the expressions fed as arguments to the call, and diff --git a/infer/src/concurrency/MethodMatcher.mli b/infer/src/concurrency/MethodMatcher.mli index afe469cc6..3d4fdab13 100644 --- a/infer/src/concurrency/MethodMatcher.mli +++ b/infer/src/concurrency/MethodMatcher.mli @@ -7,8 +7,8 @@ open! IStd -(** pattern matcher for Java/C++ methods - NB matching is modulo template arguments in C++ classes and functions *) +(** 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 record = @@ -19,18 +19,18 @@ type record = ; methods: string list } val default : record -(** record encapsulating the default arguments of [call_matches]. [classname=""] and [methods=[]]. +(** record encapsulating the default arguments of [call_matches]. [classname=""] and [methods=\[\]]. Useful for [with] expressions *) val of_record : record -> t (** make a matcher out of a record; optional values use defaults *) val of_json : Yojson.Basic.t -> t -(** Parse a JSon object into a matcher. The Json object must be a list of records, each - corresponding to a single matcher. Each record must have a ["classname"] field with a [string] - value, and a ["methods"] field with a list of strings. The record may also have boolean - fields ["search_superclasses"] and ["method_prefix"]. If absent, the defaults are used. - The resulting matcher matches if one of the matchers in the list does. *) +(** Parse a JSon object into a matcher. The Json object must be a list of records, each + corresponding to a single matcher. Each record must have a ["classname"] field with a [string] + value, and a ["methods"] field with a list of strings. The record may also have boolean fields + ["search_superclasses"] and ["method_prefix"]. If absent, the defaults are used. The resulting + matcher matches if one of the matchers in the list does. *) val of_list : t list -> t (** Or combinator *) diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 50e078a3e..7700e5e65 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -796,13 +796,11 @@ let should_filter_access exp_opt = AccessExpression.to_accesses exp |> snd |> List.exists ~f:check_access ) -(** - Map containing reported accesses, which groups them in lists, by abstract location. - The equivalence relation used for grouping them is equality of access paths. - This is slightly complicated because local variables contain the pname of the function declaring - them. Here we want a purely name-based comparison, and in particular that [this == this] - regardless the method declaring it. Hence the redefined comparison functions. -*) +(** Map containing reported accesses, which groups them in lists, by abstract location. The + equivalence relation used for grouping them is equality of access paths. This is slightly + complicated because local variables contain the pname of the function declaring them. Here we + want a purely name-based comparison, and in particular that [this == this] regardless the method + declaring it. Hence the redefined comparison functions. *) module ReportMap : sig type t @@ -935,23 +933,22 @@ let should_report_guardedby_violation classname_str ({snapshot; tenv; procname} To cut down on duplication noise we don't always report at both sites (line numbers) involved in a race. - -- If a protected access races with an unprotected one, we don't report the protected but we do - report the unprotected one (and we point to the protected from the unprotected one). This - way the report is at the line number in a race-pair where the programmer should take action. + \-- If a protected access races with an unprotected one, we don't report the protected but we do + report the unprotected one (and we point to the protected from the unprotected one). This way + the report is at the line number in a race-pair where the programmer should take action. - -- Similarly, if a threaded and unthreaded (not known to be threaded) access race, we report at - the unthreaded site. + \-- Similarly, if a threaded and unthreaded (not known to be threaded) access race, we report at + the unthreaded site. Also, we avoid reporting multiple races at the same line (which can happen a lot in an interprocedural scenario) or multiple accesses to the same field in a single method, expecting that the programmer already gets signal from one report. To report all the races with separate - warnings leads to a lot of noise. But note, we never suppress all the potential issues in a + warnings leads to a lot of noise. But note, we never suppress all the potential issues in a class: if we don't report any races, it means we didn't find any. The above is tempered at the moment by abstractions of "same lock" and "same thread": we are currently not distinguishing different locks, and are treating "known to be confined to a - thread" as if "known to be confined to UI thread". -*) + thread" as if "known to be confined to UI thread". *) let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportMap.t) = let open RacerDDomain in let open RacerDModels in diff --git a/infer/src/concurrency/RacerDDomain.ml b/infer/src/concurrency/RacerDDomain.ml index b8b27773f..982eb8472 100644 --- a/infer/src/concurrency/RacerDDomain.ml +++ b/infer/src/concurrency/RacerDDomain.ml @@ -10,10 +10,10 @@ module AccessExpression = HilExp.AccessExpression module F = Format module MF = MarkupFormatter -(** Master function for deciding whether RacerD should completely ignore a variable as the root - of an access expression. Currently fires on *static locals* and any variable which does not - appear in source code (eg, temporary variables and frontend introduced variables). - This is because currently reports on these variables would not be easily actionable. +(** Master function for deciding whether RacerD should completely ignore a variable as the root of + an access expression. Currently fires on *static locals* and any variable which does not appear + in source code (eg, temporary variables and frontend introduced variables). This is because + currently reports on these variables would not be easily actionable. This is here and not in RacerDModels to avoid dependency cycles. *) let should_skip_var v = @@ -119,9 +119,9 @@ end module TraceElem = struct include ExplicitTrace.MakeTraceElemModuloLocation (Access) (CallPrinter) - (** This choice means the comparator is insensitive to the location access. - This preserves correctness only if the overlying comparator (AccessSnapshot) - takes into account the characteristics of the access (eg lock status). *) + (** This choice means the comparator is insensitive to the location access. This preserves + correctness only if the overlying comparator (AccessSnapshot) takes into account the + characteristics of the access (eg lock status). *) let is_write {elem} = Access.is_write elem diff --git a/infer/src/concurrency/RacerDDomain.mli b/infer/src/concurrency/RacerDDomain.mli index ee7cbcc0a..bcd03e775 100644 --- a/infer/src/concurrency/RacerDDomain.mli +++ b/infer/src/concurrency/RacerDDomain.mli @@ -21,7 +21,7 @@ module Access : sig | ContainerWrite of {exp: AccessExpression.t; pname: Typ.Procname.t} (** Write to container object *) | InterfaceCall of Typ.Procname.t - (** Call to method of interface not annotated with @ThreadSafe *) + (** Call to method of interface not annotated with [@ThreadSafe] *) [@@deriving compare] include ExplicitTrace.Element with type t := t @@ -59,17 +59,17 @@ module LocksDomain : sig (** integrate current state with a callee summary *) end -(** Abstraction of threads that may run in parallel with the current thread. - NoThread < AnyThreadExceptSelf < AnyThread *) +(** Abstraction of threads that may run in parallel with the current thread. NoThread < + AnyThreadExceptSelf < AnyThread *) module ThreadsDomain : sig type t = | NoThread (** No threads can run in parallel with the current thread (concretization: empty set). We - assume this by default unless we see evidence to the contrary (annotations, use of locks, - etc.) *) + assume this by default unless we see evidence to the contrary (annotations, use of + locks, etc.) *) | AnyThreadButSelf (** Current thread can run in parallel with other threads, but not with a copy of itself. - (concretization : {% \{ t | t \in TIDs ^ t != t_cur \} %} ) *) + (concretization : {% \{ t | t \in TIDs ^ t != t_cur \} %} ) *) | AnyThread (** Current thread can run in parallel with any thread, including itself (concretization: set of all TIDs ) *) @@ -132,8 +132,8 @@ end module OwnershipAbstractValue : sig type t = private | OwnedIf of IntSet.t - (** Owned if the formals at the given indexes are owned in the caller; unconditionally owned - if the set of formals is empty = bottom of the lattice *) + (** Owned if the formals at the given indexes are owned in the caller; unconditionally owned + if the set of formals is empty = bottom of the lattice *) | Unowned (** Unowned value; top of the lattice *) [@@deriving compare] @@ -171,7 +171,7 @@ end module Attribute : sig type t = - | Functional (** holds a value returned from a callee marked @Functional *) + | Functional (** holds a value returned from a callee marked [@Functional] *) | Choice of Choice.t (** holds a boolean choice variable *) include PrettyPrintable.PrintableOrderedType with type t := t diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index c0abb7841..7051de7ee 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -130,7 +130,7 @@ let get_container_access pn tenv = (** holds of procedure names which should not be analyzed in order to avoid known sources of - inaccuracy *) + inaccuracy *) let should_skip = let matcher = lazy @@ -467,7 +467,7 @@ let is_synchronized_container callee_pname (access_exp : HilExp.AccessExpression false -(** check that callee is abstract and accepts one argument. In addition, its argument type must be +(** check that callee is abstract and accepts one argument. In addition, its argument type must be equal to its return type. *) let is_abstract_getthis_like callee = attrs_of_pname callee diff --git a/infer/src/concurrency/RacerDModels.mli b/infer/src/concurrency/RacerDModels.mli index 4a0e2d1b5..1a9b85259 100644 --- a/infer/src/concurrency/RacerDModels.mli +++ b/infer/src/concurrency/RacerDModels.mli @@ -22,25 +22,25 @@ val is_box : Typ.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 -(** 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. *) +(** 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 (** 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 *) + 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 val is_thread_safe_method : Typ.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. *) +(** 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 diff --git a/infer/src/concurrency/StarvationModels.ml b/infer/src/concurrency/StarvationModels.ml index 95d8759e0..df571a328 100644 --- a/infer/src/concurrency/StarvationModels.ml +++ b/infer/src/concurrency/StarvationModels.ml @@ -54,8 +54,8 @@ let timeunit_of_exp = fun timeunit_exp -> str_of_exp timeunit_exp |> Option.bind ~f:(String.Map.find time_units) -(** check whether actuals of a method call either empty, denoting indefinite timeout, - or evaluate to a finite timeout greater than the android anr limit *) +(** check whether actuals of a method call either empty, denoting indefinite timeout, or evaluate to + a finite timeout greater than the android anr limit *) let empty_or_excessive_timeout actuals = let duration_of_exp = function | HilExp.Constant (Const.Cint duration_lit) -> diff --git a/infer/src/concurrency/StarvationModels.mli b/infer/src/concurrency/StarvationModels.mli index 3aa47286d..9409b08c8 100644 --- a/infer/src/concurrency/StarvationModels.mli +++ b/infer/src/concurrency/StarvationModels.mli @@ -18,8 +18,8 @@ val may_block : Tenv.t -> Typ.Procname.t -> HilExp.t list -> severity option val is_strict_mode_violation : Tenv.t -> Typ.Procname.t -> HilExp.t list -> bool val is_synchronized_library_call : Tenv.t -> Typ.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 *) +(** 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 (** should we treat a method call as skip (eg library methods in guava) to avoid FPs? *) @@ -35,14 +35,15 @@ val is_annotated_lockless : val schedules_work : Tenv.t -> Typ.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 thread *) +(** an instance field holding a reference to an executor may be annotated as running on UI/non-UI + thread *) type scheduler_thread_constraint = ForUIThread | ForNonUIThread | ForUnknownThread [@@deriving equal] val get_executor_thread_annotation_constraint : Tenv.t -> HilExp.AccessExpression.t -> scheduler_thread_constraint option -(** 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. *) +(** 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 (** given a receiver, find the [run()] method in the appropriate class *) diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 3d6705072..3c591bea7 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -275,8 +275,8 @@ end module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.Normal)) -(** Before analyzing Java instance methods (non-constructor, non-static), compute the attributes - of instance variables that all constructors agree on after termination. *) +(** Before analyzing Java instance methods (non-constructor, non-static), compute the attributes of + instance variables that all constructors agree on after termination. *) let add_constructor_attributes tenv procname (astate : Domain.t) = let open Domain in let skip_constructor_analysis = @@ -585,7 +585,7 @@ let fold_reportable_summaries (tenv, current_summary) clazz ~init ~f = The net effect of the above issues is that we will only see these locks in conflicting pairs once, as opposed to twice with all other deadlock pairs. *) -(** report warnings possible on the parallel composition of two threads/critical pairs +(** report warnings possible on the parallel composition of two threads/critical pairs [should_report_starvation] means [pair] is on the UI thread and not on a constructor *) let report_on_parallel_composition ~should_report_starvation tenv pdesc pair lock other_pname other_pair report_map = diff --git a/infer/src/concurrency/starvationDomain.ml b/infer/src/concurrency/starvationDomain.ml index 60df91a62..f826b00b8 100644 --- a/infer/src/concurrency/starvationDomain.ml +++ b/infer/src/concurrency/starvationDomain.ml @@ -46,9 +46,9 @@ module ThreadDomain = struct |> F.pp_print_string fmt - (** Can two thread statuses occur in parallel? Only [UIThread, UIThread] is forbidden. - In addition, this is monotonic wrt the lattice (increasing either argument cannot - transition from true to false). *) + (** Can two thread statuses occur in parallel? Only [UIThread, UIThread] is forbidden. In + addition, this is monotonic wrt the lattice (increasing either argument cannot transition from + true to false). *) let can_run_in_parallel st1 st2 = match (st1, st2) with UIThread, UIThread -> false | _, _ -> true @@ -59,9 +59,9 @@ module ThreadDomain = struct Otherwise, we have no info on caller, so use callee's info. *) let integrate_summary ~caller ~callee = if is_bottom caller then callee else caller - (** given the current thread state [caller_thread] and the thread state under which a critical pair - occurred, [pair_thread], decide whether to throw away the pair (returning [None]) because it - cannot occur within a call from the current state, or adapt its thread state appropriately. *) + (** given the current thread state [caller_thread] and the thread state under which a critical + pair occurred, [pair_thread], decide whether to throw away the pair (returning [None]) because + it cannot occur within a call from the current state, or adapt its thread state appropriately. *) let apply_to_pair caller_thread pair_thread = match (caller_thread, pair_thread) with | UnknownThread, _ -> @@ -154,8 +154,8 @@ module Event = struct StrictModeCall descr 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. *) +(** 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]} @@ -409,11 +409,12 @@ let is_recursive_lock event tenv = false -(** skip adding an order pair [(_, event)] if - - we have no tenv, or, - - [event] is not a lock event, or, - - we do not hold the lock, or, - - the lock is not recursive. *) +(** skip adding an order pair [(_, event)] if + + - we have no tenv, or, + - [event] is not a lock event, or, + - we do not hold the lock, or, + - the lock is not recursive. *) let should_skip ?tenv event lock_state = Option.exists tenv ~f:(fun tenv -> LockState.is_lock_taken event lock_state && is_recursive_lock event tenv ) diff --git a/infer/src/concurrency/starvationDomain.mli b/infer/src/concurrency/starvationDomain.mli index 34dd10a7e..0be1d4a32 100644 --- a/infer/src/concurrency/starvationDomain.mli +++ b/infer/src/concurrency/starvationDomain.mli @@ -8,23 +8,23 @@ open! IStd module F = Format -(** Domain for thread-type. The main goals are - - Track code paths that are explicitly on UI/BG thread (via annotations, or assertions). - - Maintain UI/BG-thread-ness through the call stack (if a caller is of unknown status and - callee is on UI/BG thread then caller must be on the UI/BG thread too). - - Traces with "UI-thread" status cannot interleave but all other combinations can. - - Top is AnyThread, which means that there are executions on both UI and BG threads on - this method. - - Bottom is UnknownThread, and used as initial state. -*) +(** Domain for thread-type. The main goals are + + - Track code paths that are explicitly on UI/BG thread (via annotations, or assertions). + - Maintain UI/BG-thread-ness through the call stack (if a caller is of unknown status and callee + is on UI/BG thread then caller must be on the UI/BG thread too). + - Traces with "UI-thread" status cannot interleave but all other combinations can. + - Top is AnyThread, which means that there are executions on both UI and BG threads on this + method. + - Bottom is UnknownThread, and used as initial state. *) module ThreadDomain : sig type t = UnknownThread | UIThread | BGThread | AnyThread include AbstractDomain.WithBottom with type t := t end -(** Abstraction of a path that represents a lock, special-casing comparison - to work over type, base variable modulo this and access list *) +(** Abstraction of a path that represents a lock, special-casing comparison to work over type, base + variable modulo this and access list *) module Lock : sig include PrettyPrintable.PrintableOrderedType with type t = AccessPath.t @@ -68,12 +68,11 @@ module CriticalPairElement : sig type t = private {acquisitions: Acquisitions.t; event: Event.t; thread: ThreadDomain.t} end -(** A [CriticalPairElement] equipped with a call stack. - The intuition is that if we have a critical pair `(locks, event)` in the summary - of a method then there is a trace of that method where `event` occurs, and right - before it occurs the locks held are exactly `locks` (no over/under approximation). - We call it "critical" because the information here alone determines deadlock conditions. -*) +(** A [CriticalPairElement] equipped with a call stack. The intuition is that if we have a critical + pair `(locks, event)` in the summary of a method then there is a trace of that method where + `event` occurs, and right before it occurs the locks held are exactly `locks` (no over/under + approximation). We call it "critical" because the information here alone determines deadlock + conditions. *) module CriticalPair : sig type t = private {elem: CriticalPairElement.t; loc: Location.t; trace: CallSite.t list} @@ -196,8 +195,8 @@ val pp_summary : F.formatter -> summary -> unit val integrate_summary : ?tenv:Tenv.t -> ?lhs:HilExp.AccessExpression.t -> CallSite.t -> t -> summary -> t -(** apply a callee summary to the current abstract state; - [lhs] is the expression assigned the returned value, if any *) +(** apply a callee summary to the current abstract state; [lhs] is the expression assigned the + returned value, if any *) val summary_of_astate : Procdesc.t -> t -> summary diff --git a/infer/src/infer.ml b/infer/src/infer.ml index 4bf33f278..4dc532320 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -7,8 +7,7 @@ open! IStd -(** Top-level driver that orchestrates build system integration, frontends, backend, and - reporting *) +(** Top-level driver that orchestrates build system integration, frontends, backend, and reporting *) module CLOpt = CommandLineOption module L = Logging diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index 55f3fd4ae..301f6596d 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -213,8 +213,8 @@ let split_buck_command buck_cmd = accepted_buck_commands -(** Given a list of arguments return the extended list of arguments where -the args in a file have been extracted *) +(** Given a list of arguments return the extended list of arguments where the args in a file have + been extracted *) let inline_argument_files buck_args = let expand_buck_arg buck_arg = if String.is_prefix ~prefix:"@" buck_arg then diff --git a/infer/src/integration/Buck.mli b/infer/src/integration/Buck.mli index 90b2ffa2d..4043348eb 100644 --- a/infer/src/integration/Buck.mli +++ b/infer/src/integration/Buck.mli @@ -23,12 +23,9 @@ val add_flavors_to_buck_arguments : -> extra_flavors:string list -> string list -> flavored_arguments -(** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer. For - instance, in capture mode, the buck command: - build //foo/bar:baz#some,flavor - becomes: - build //foo/bar:baz#infer-capture-all,some,flavor -*) +(** Add infer flavors to the targets in the given buck arguments, depending on the infer analyzer. + For instance, in capture mode, the buck command: build //foo/bar:baz#some,flavor becomes: build + //foo/bar:baz#infer-capture-all,some,flavor *) val store_args_in_file : string list -> string list (** Given a list of arguments, stores them in a file if needed and returns the new command line *) diff --git a/infer/src/integration/CaptureCompilationDatabase.mli b/infer/src/integration/CaptureCompilationDatabase.mli index 57f27b54b..09eeaf53b 100644 --- a/infer/src/integration/CaptureCompilationDatabase.mli +++ b/infer/src/integration/CaptureCompilationDatabase.mli @@ -15,11 +15,11 @@ val capture_files_in_database : val capture_file_in_database : CompilationDatabase.t -> SourceFile.t -> unit val get_compilation_database_files_buck : prog:string -> args:string list -> [> `Raw of string] list -(** Get the compilation database files that contain the compilation given by the - buck command. It will be the compilation of the passed targets only or also - the dependencies according to the flag --buck-compilation-database deps | no-deps *) +(** Get the compilation database files that contain the compilation given by the buck command. It + will be the compilation of the passed targets only or also the dependencies according to the + flag --buck-compilation-database deps | no-deps *) val get_compilation_database_files_xcodebuild : prog:string -> args:string list -> [> `Escaped of string] list -(** Get the compilation database files that contain the compilation given by the - xcodebuild command, using xcpretty. *) +(** Get the compilation database files that contain the compilation given by the xcodebuild command, + using xcpretty. *) diff --git a/infer/src/integration/CompilationDatabase.ml b/infer/src/integration/CompilationDatabase.ml index 9e05f1d93..d563d2127 100644 --- a/infer/src/integration/CompilationDatabase.ml +++ b/infer/src/integration/CompilationDatabase.ml @@ -28,11 +28,11 @@ let parse_command_and_arguments command_and_arguments = (command, [arguments]) -(** Parse the compilation database json file into the compilationDatabase - map. The json file consists of an array of json objects that contain the file - to be compiled, the directory to be compiled in, and the compilation command as a list - and as a string. We pack this information into the compilationDatabase map, and remove the - clang invocation part, because we will use a clang wrapper. *) +(** Parse the compilation database json file into the compilationDatabase map. The json file + consists of an array of json objects that contain the file to be compiled, the directory to be + compiled in, and the compilation command as a list and as a string. We pack this information + into the compilationDatabase map, and remove the clang invocation part, because we will use a + clang wrapper. *) let decode_json_file (database : t) json_format = let json_path = match json_format with `Raw x | `Escaped x -> x in let unescape_path s = diff --git a/infer/src/integration/CompilationDatabase.mli b/infer/src/integration/CompilationDatabase.mli index 9bcac3c30..f0425fe24 100644 --- a/infer/src/integration/CompilationDatabase.mli +++ b/infer/src/integration/CompilationDatabase.mli @@ -16,8 +16,7 @@ type compilation_data = (** argument list, where each argument is already escaped for the shell. This is because in some cases the argument list contains arguments that are actually themselves a list of arguments, for instance because the compilation database only contains a "command" - entry. *) - } + entry. *) } val filter_compilation_data : t -> f:(SourceFile.t -> bool) -> (SourceFile.t * compilation_data) list diff --git a/infer/src/integration/Driver.mli b/infer/src/integration/Driver.mli index 18d72cc1f..c588a5ade 100644 --- a/infer/src/integration/Driver.mli +++ b/infer/src/integration/Driver.mli @@ -43,4 +43,5 @@ val run_epilogue : unit -> unit (** cleanup infer-out/ for Buck, generate stats, and generally post-process the results of a run *) val read_config_changed_files : unit -> SourceFile.Set.t option -(** return the list of changed files as read from Config.changed_files_index and passed to SourceFile.changed_sources_from_changed_files *) +(** return the list of changed files as read from Config.changed_files_index and passed to + SourceFile.changed_sources_from_changed_files *) diff --git a/infer/src/istd/Escape.ml b/infer/src/istd/Escape.ml index b0a38e580..0e2b8a7e3 100644 --- a/infer/src/istd/Escape.ml +++ b/infer/src/istd/Escape.ml @@ -7,8 +7,7 @@ open! IStd -(** Escape a string for use in a CSV or XML file: replace reserved - characters with escape sequences *) +(** Escape a string for use in a CSV or XML file: replace reserved characters with escape sequences *) module F = Format diff --git a/infer/src/istd/Escape.mli b/infer/src/istd/Escape.mli index a909f38d2..1630a809e 100644 --- a/infer/src/istd/Escape.mli +++ b/infer/src/istd/Escape.mli @@ -7,8 +7,7 @@ open! IStd -(** Escape a string for use in a CSV or XML file: replace reserved - characters with escape sequences *) +(** Escape a string for use in a CSV or XML file: replace reserved characters with escape sequences *) val escape_dotty : string -> string (** escape a string to be used in a dotty file *) diff --git a/infer/src/istd/IList.mli b/infer/src/istd/IList.mli index e59df7496..10b306b37 100644 --- a/infer/src/istd/IList.mli +++ b/infer/src/istd/IList.mli @@ -33,7 +33,7 @@ val split_last_rev : 'a list -> ('a * 'a list) option val append_no_duplicates : cmp:('a -> 'a -> int) -> ('a list -> 'a list -> 'a list) Staged.t (** [append_no_duplicates list1 list2], assuming that list1 and list2 have no duplicates on their - own, it computes list1 @ (filtered list2), so it keeps the order of both lists and has no + own, it computes [list1 @ (filtered list2)], so it keeps the order of both lists and has no duplicates. *) val merge_dedup : 'a list -> 'a list -> compare:('a -> 'a -> int) -> 'a list @@ -48,7 +48,7 @@ val remove_first : 'a list -> f:('a -> bool) -> 'a list option val force_until_first_some : 'a option lazy_t list -> 'a option (** [force_until_first_some xs] forces the computation of each element of [xs] and returns the first -that matches (Some _); or, if no such element exists, it returns None. *) + that matches (Some _); or, if no such element exists, it returns None. *) val eval_until_first_some : (unit -> 'a option) list -> 'a option (** given a list of functions taking unit, evaluate and return the first one to return [Some x] *) diff --git a/infer/src/istd/IOption.mli b/infer/src/istd/IOption.mli index 6b06d7037..7bf2c317f 100644 --- a/infer/src/istd/IOption.mli +++ b/infer/src/istd/IOption.mli @@ -14,11 +14,10 @@ val value_default_f : f:(unit -> 'a) -> 'a option -> 'a (** Like [Option.value ~default:(f ())] but [f] is called only if [None]. *) val if_none_evalopt : f:(unit -> 'a option) -> 'a option -> 'a option -(** [if_none_evalopt ~f x] evaluates to [f ()] if [x = None], otherwise returns [x]. - Useful for chaining matchers where the first returning non-[None] determines - the result. *) +(** [if_none_evalopt ~f x] evaluates to [f ()] if [x = None], otherwise returns [x]. Useful for + chaining matchers where the first returning non-[None] determines the result. *) val if_none_eval : f:(unit -> 'a) -> 'a option -> 'a -(** [if_none_eval ~f x] evaluates to [y] if [x=Some y] else to [f ()]. - Useful for terminating chains built with [if_none_evalopt]. - This is exactly the same as [value_default_f] but with a better name. *) +(** [if_none_eval ~f x] evaluates to [y] if [x=Some y] else to [f ()]. Useful for terminating chains + built with [if_none_evalopt]. This is exactly the same as [value_default_f] but with a better + name. *) diff --git a/infer/src/istd/ImperativeUnionFind.ml b/infer/src/istd/ImperativeUnionFind.ml index 3a8f3e015..42a4e6a7b 100644 --- a/infer/src/istd/ImperativeUnionFind.ml +++ b/infer/src/istd/ImperativeUnionFind.ml @@ -91,15 +91,13 @@ module Make (Set : Set) = struct let remove_now t r = H.remove t r end - (** - Data-structure for disjoint sets. - [reprs] is the mapping element -> representative - [sets] is the mapping representative -> set + (** Data-structure for disjoint sets. [reprs] is the mapping element -> representative [sets] is + the mapping representative -> set - It implements path-compression and union by size, hence find and union are amortized O(1)-ish. + It implements path-compression and union by size, hence find and union are amortized O(1)-ish. - [nb_iterators] and [to_remove] are used to defer removing elements to avoid iterator invalidation during fold. - *) + [nb_iterators] and [to_remove] are used to defer removing elements to avoid iterator + invalidation during fold. *) type t = {reprs: Reprs.t; sets: Sets.t; mutable nb_iterators: int; mutable to_remove: Repr.t list} let create () = {reprs= Reprs.create (); sets= Sets.create (); nb_iterators= 0; to_remove= []} diff --git a/infer/src/istd/ImperativeUnionFind.mli b/infer/src/istd/ImperativeUnionFind.mli index b75a90bb3..006d0b3cf 100644 --- a/infer/src/istd/ImperativeUnionFind.mli +++ b/infer/src/istd/ImperativeUnionFind.mli @@ -31,7 +31,8 @@ module Make (Set : Set) : sig val find : t -> Set.elt -> Repr.t val union : t -> Set.elt -> Set.elt -> (Set.elt * Set.elt) option - (** [union t e1 e2] returns [None] if [e1] and [e2] were already in the same set, [Some (a, b)] if [a] is merged into [b] (were [(a, b)] is either [(e1, e2)] or [(e2, e1)]). *) + (** [union t e1 e2] returns [None] if [e1] and [e2] were already in the same set, [Some (a, b)] if + [a] is merged into [b] (were [(a, b)] is either [(e1, e2)] or [(e2, e1)]). *) val find_create_set : t -> Repr.t -> Set.t diff --git a/infer/src/istd/MaximumSharing.ml b/infer/src/istd/MaximumSharing.ml index a6a57c0cc..b926a1dc3 100644 --- a/infer/src/istd/MaximumSharing.ml +++ b/infer/src/istd/MaximumSharing.ml @@ -17,7 +17,8 @@ module Hashing : sig val of_int : int -> hash_value val shallow : 'a -> hash_value - (** A deterministic hash function that visits O(1) objects, to ensure termination on cyclic values. *) + (** A deterministic hash function that visits O(1) objects, to ensure termination on cyclic + values. *) val alloc_of_block : tag:int -> size:int -> state @@ -261,12 +262,10 @@ end = struct (Hashing.of_int 0, (* Make sure it fails hard if [Obj.set_field] is called on it *) Obj.repr 0) - (** - Returns a value structurally equal but with potentially more sharing. - Potentially unsafe if used on mutable values that are modified later. - Preserves polymorphic compare, hashing, no-sharing marshalling. - May have an impact on code using [phys_equal] or marshalling with sharing. - *) + (** Returns a value structurally equal but with potentially more sharing. Potentially unsafe if + used on mutable values that are modified later. Preserves polymorphic compare, hashing, + no-sharing marshalling. May have an impact on code using [phys_equal] or marshalling with + sharing. *) let normalize_value sharer v = hash_and_normalize_obj sharer (Obj.repr v) dummy_should_not_be_patched (-1) |> snd |> Obj.obj end diff --git a/infer/src/istd/MaximumSharing.mli b/infer/src/istd/MaximumSharing.mli index a43187136..cb545f62a 100644 --- a/infer/src/istd/MaximumSharing.mli +++ b/infer/src/istd/MaximumSharing.mli @@ -7,9 +7,7 @@ open! IStd -(** - Current implementation will stack overflow on deep values (TODO: a tailrec version). -*) +(** Current implementation will stack overflow on deep values (TODO: a tailrec version). *) module Sharer : sig type t diff --git a/infer/src/istd/PhysEqual.mli b/infer/src/istd/PhysEqual.mli index 6f143ff6d..79821ecca 100644 --- a/infer/src/istd/PhysEqual.mli +++ b/infer/src/istd/PhysEqual.mli @@ -9,22 +9,21 @@ open! IStd val shallow_equal : 'a -> 'a -> bool -(** - Helpers function to enforce physical equality. - - Let suppose [construct/deconstruct] is a 1-level-allocation OCaml construction/deconstruction, - such as variant type, tuple or record construction. - Instead of writing - let a = deconstruct a0 in - let b = deconstruct b0 in - let res = f a b in - if phys_equal res a then a0 - else if phys_equal res b then b0 - else construct res - - Simply write - PhysEqual.optim2 ~res:(construct (f a b)) a0 b0 -*) +(** Helpers function to enforce physical equality. + + Let suppose [construct/deconstruct] is a 1-level-allocation OCaml construction/deconstruction, + such as variant type, tuple or record construction. Instead of writing + + {[ + let a = deconstruct a0 in + let b = deconstruct b0 in + let res = f a b in + if phys_equal res a then a0 else if phys_equal res b then b0 else construct res + ]} + + Simply write + + {[ PhysEqual.optim2 ~res:(construct (f a b)) a0 b0 ]} *) val optim1 : res:'a -> 'a -> 'a diff --git a/infer/src/istd/Pp.ml b/infer/src/istd/Pp.ml index f2e2cfb53..33001645e 100644 --- a/infer/src/istd/Pp.ml +++ b/infer/src/istd/Pp.ml @@ -8,7 +8,7 @@ open! IStd module F = Format -(** Pretty Printing} *) +(** Pretty Printing *) (** Kind of simple printing: default or with full types *) type simple_kind = SIM_DEFAULT | SIM_WITH_TYP @@ -73,8 +73,8 @@ let extend_colormap pe (x : Obj.t) (c : color) = {pe with cmap_norm= colormap} -(** Set the object substitution, which is supposed to preserve the type. - Currently only used for a map from (identifier) expressions to the program var containing them *) +(** Set the object substitution, which is supposed to preserve the type. Currently only used for a + map from (identifier) expressions to the program var containing them *) let set_obj_sub pe (sub : 'a -> 'a) = let new_obj_sub x = let x' = Obj.repr (sub (Obj.obj x)) in diff --git a/infer/src/istd/Pp.mli b/infer/src/istd/Pp.mli index bdb47594e..cdda1f0cb 100644 --- a/infer/src/istd/Pp.mli +++ b/infer/src/istd/Pp.mli @@ -42,8 +42,8 @@ val reset_obj_sub : env -> env (** Reset the object substitution, so that no substitution takes place *) val set_obj_sub : env -> ('a -> 'a) -> env -(** Set the object substitution, which is supposed to preserve the type. - Currently only used for a map from (identifier) expressions to the program var containing them *) +(** Set the object substitution, which is supposed to preserve the type. Currently only used for a + map from (identifier) expressions to the program var containing them *) val colormap_red : colormap (** red colormap *) diff --git a/infer/src/istd/PrettyPrintable.mli b/infer/src/istd/PrettyPrintable.mli index f2e302d08..5763b1db7 100644 --- a/infer/src/istd/PrettyPrintable.mli +++ b/infer/src/istd/PrettyPrintable.mli @@ -186,7 +186,7 @@ module type PPUniqRankSet = sig val union_prefer_left : t -> t -> t (** in case an element with the same rank is present both in [lhs] and [rhs], keep the one from - [lhs] in [union_prefer_left lhs rhs] *) + [lhs] in [union_prefer_left lhs rhs] *) val pp : ?print_rank:bool -> F.formatter -> t -> unit end diff --git a/infer/src/java/JProcname.ml b/infer/src/java/JProcname.ml index 6002d9bdf..546e273f1 100644 --- a/infer/src/java/JProcname.ml +++ b/infer/src/java/JProcname.ml @@ -151,8 +151,8 @@ module JNI = struct tokenize_aux input_chars [] - (** Very simple minded: keep reducing until no more non-terminals are left. - Fail if no reductions happened during a scan *) + (** Very simple minded: keep reducing until no more non-terminals are left. Fail if no reductions + happened during a scan *) let reduce symbols = let rec reduce_aux ~symbols ~unchanged_symbols ~in_method ~jnis_in_method ~jnis = let tl_or_empty l = match l with [] -> [] | [_] -> [] | _ :: tl -> tl in diff --git a/infer/src/java/jClasspath.mli b/infer/src/java/jClasspath.mli index 319c81e44..fa9011139 100644 --- a/infer/src/java/jClasspath.mli +++ b/infer/src/java/jClasspath.mli @@ -10,8 +10,8 @@ open! IStd open Javalib_pack 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 *) +(** 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 (** Check if there is a model for the given procname *) @@ -45,7 +45,7 @@ val lookup_node : JBasics.class_name -> program -> JCode.jcode Javalib.interface val add_missing_callee : program -> Typ.Procname.t -> JBasics.class_name -> JBasics.method_signature -> unit -(** add the class name of method signature to the list of callees *) +(** add the class name of method signature to the list of callees *) val set_callee_translated : program -> Typ.Procname.t -> unit (** set that the CFG for the procedure has been created *) diff --git a/infer/src/java/jConfig.ml b/infer/src/java/jConfig.ml index a8882e817..6d341b1ff 100644 --- a/infer/src/java/jConfig.ml +++ b/infer/src/java/jConfig.ml @@ -46,7 +46,7 @@ let long_st = "long" let short_st = "short" -(** {2 Encoding of primitive types when they are the element type of arrays } *) +(** {2 Encoding of primitive types when they are the element type of arrays} *) let boolean_code = "Z" diff --git a/infer/src/java/jContext.mli b/infer/src/java/jContext.mli index 033e168c4..40a3ae3c7 100644 --- a/infer/src/java/jContext.mli +++ b/infer/src/java/jContext.mli @@ -10,19 +10,19 @@ open! IStd open Javalib_pack open Sawja_pack -(** data structure for representing whether an instruction is a goto, a return or a standard instruction. *) +(** data structure for representing whether an instruction is a goto, a return or a standard + instruction. *) type jump_kind = Next | Jump of int | Exit module NodeTbl : Caml.Hashtbl.S with type key = Procdesc.Node.t -(** Hastable for storing nodes that correspond to if-instructions. These are - used when adding the edges in the contrl flow graph. *) +(** Hastable for storing nodes that correspond to if-instructions. These are used when adding the + edges in the contrl flow graph. *) -(** data structure for saving the three structures tht contain the intermediate - representation of a file: the type environment, the control graph and the control - flow graph *) +(** data structure for saving the three structures tht contain the intermediate representation of a + file: the type environment, the control graph and the control flow graph *) type icfg = {tenv: Tenv.t; cfg: Cfg.t} -(** data structure for storing the context elements. *) +(** data structure for storing the context elements. *) type t = private { icfg: icfg ; procdesc: Procdesc.t @@ -36,7 +36,7 @@ type t = private val create_context : icfg -> Procdesc.t -> JBir.t -> JBasics.class_name -> SourceFile.t -> JClasspath.program -> t -(** cretes a context for a given method. *) +(** cretes a context for a given method. *) val get_tenv : t -> Tenv.t (** returns the type environment that corresponds to the current file. *) @@ -51,14 +51,14 @@ val add_goto_jump : t -> int -> jump_kind -> unit (** adds to the context the line that the node in the given line will jump to. *) val get_goto_jump : t -> int -> jump_kind -(** if the given line corresponds to a goto instruction, then returns the - line where it jumps to, otherwise returns the next line. *) +(** if the given line corresponds to a goto instruction, then returns the line where it jumps to, + otherwise returns the next line. *) val is_goto_jump : t -> int -> bool -(** returns whether the given line corresponds to a goto instruction. *) +(** returns whether the given line corresponds to a goto instruction. *) val set_pvar : t -> JBir.var -> Typ.t -> Pvar.t -(** [set_pvar context var type] adds a variable with a type to the context *) +(** [set_pvar context var type] adds a variable with a type to the context *) val get_var_type : t -> JBir.var -> Typ.t option (** [get_var_type context var] returns the type of the variable, if the variable is in the context *) @@ -67,7 +67,7 @@ val reset_pvar_type : t -> unit (** resets the dynamic type of the variables in the context. *) val reset_exn_node_table : unit -> unit -(** resets the hashtable mapping methods to their exception nodes *) +(** resets the hashtable mapping methods to their exception nodes *) val add_exn_node : Typ.Procname.t -> Procdesc.Node.t -> unit (** adds the exception node for a given method *) diff --git a/infer/src/java/jFrontend.mli b/infer/src/java/jFrontend.mli index c9c763701..ff374c452 100644 --- a/infer/src/java/jFrontend.mli +++ b/infer/src/java/jFrontend.mli @@ -16,7 +16,7 @@ val cache_classname : JBasics.class_name -> unit (** [cache_classname cn] stores the classname to the disk *) val is_classname_cached : JBasics.class_name -> bool -(** [is_classname_cached cn] *) +(** [is_classname_cached cn] *) val compute_source_icfg : Printer.LineReader.t @@ -27,7 +27,9 @@ val compute_source_icfg : -> string option -> SourceFile.t -> Cfg.t -(** [compute_cfg linereader classes program tenv source_basename source_file] create the control flow graph for the file [source_file] by translating all the classes in [program] originating from [source_file] *) +(** [compute_cfg linereader classes program tenv source_basename source_file] create the control + flow graph for the file [source_file] by translating all the classes in [program] originating + from [source_file] *) val compute_class_icfg : SourceFile.t diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 074add5ca..091abc52a 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -15,9 +15,8 @@ type invoke_kind = I_Virtual | I_Interface | I_Special | I_Static 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. *) +(** 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 method_name = @@ -123,8 +122,8 @@ let translate_formals program tenv cn impl = List.rev (List.fold ~f:collect ~init:[] (JBir.params impl)) -(** Creates the list of local variables from the bytecode and add the variables from - the JBir representation *) +(** Creates the list of local variables from the bytecode and add the variables from the JBir + representation *) let translate_locals program tenv formals bytecode jbir_code = let formal_set = List.fold ~f:(fun set (var, _) -> Mangled.Set.add var set) ~init:Mangled.Set.empty formals diff --git a/infer/src/java/jTrans.mli b/infer/src/java/jTrans.mli index f08ec7cad..4b8d024db 100644 --- a/infer/src/java/jTrans.mli +++ b/infer/src/java/jTrans.mli @@ -10,7 +10,7 @@ open! IStd open Javalib_pack open Sawja_pack -(** Data structure for storing the results of the translation of an instruction. *) +(** Data structure for storing the results of the translation of an instruction. *) type translation = | Skip | Instr of Procdesc.Node.t @@ -62,8 +62,8 @@ val create_cm_procdesc : -> JCode.jcode Javalib.concrete_method -> Typ.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 *) +(** [create_procdesc source_file program linereader icfg cm proc_name] creates a procedure + description for the concrete method cm and adds it to cfg *) val instruction : JContext.t -> int -> JBir.instr -> translation (** translates an instruction into a statement node or prune nodes in the cfg *) diff --git a/infer/src/java/jTransType.ml b/infer/src/java/jTransType.ml index 131c6a868..7086a2e26 100644 --- a/infer/src/java/jTransType.ml +++ b/infer/src/java/jTransType.ml @@ -417,7 +417,7 @@ and value_type program tenv vt = object_type program tenv ot -(** Translate object types into Exp.Sizeof expressions *) +(** Translate object types into Exp.Sizeof expressions *) let sizeof_of_object_type program tenv ot subtype = match (object_type program tenv ot).Typ.desc with | Typ.Tptr (typ, _) -> @@ -452,8 +452,8 @@ let extract_array_type typ = match typ.Typ.desc with Typ.Tptr ({desc= Tarray {elt}}, Typ.Pk_pointer) -> elt | _ -> typ -(** translate the type of an expression, looking in the method signature for formal parameters - this is because variables in expressions do not have accurate types *) +(** translate the type of an expression, looking in the method signature for formal parameters this + is because variables in expressions do not have accurate types *) let rec expr_type (context : JContext.t) expr = let program = context.program in let tenv = JContext.get_tenv context in @@ -469,7 +469,6 @@ let rec expr_type (context : JContext.t) expr = value_type program tenv (JBir.type_of_expr expr) -(** Returns the return type of the method based on the return type - specified in ms. *) +(** Returns the return type of the method based on the return type specified in ms. *) let return_type program tenv ms = match JBasics.ms_rtype ms with None -> Typ.mk Tvoid | Some vt -> value_type program tenv vt diff --git a/infer/src/java/jTransType.mli b/infer/src/java/jTransType.mli index 66128409a..35273a266 100644 --- a/infer/src/java/jTransType.mli +++ b/infer/src/java/jTransType.mli @@ -36,7 +36,7 @@ val get_class_type_no_pointer : JClasspath.program -> Tenv.t -> JBasics.class_na without the pointer part *) val get_class_type : JClasspath.program -> Tenv.t -> JBasics.class_name -> Typ.t -(** [get_class_type program tenv cn] returns the sil type representation of the class *) +(** [get_class_type program tenv cn] returns the sil type representation of the class *) val is_autogenerated_assert_field : Typ.Fieldname.t -> bool (** return true if [field_name] is the autogenerated C.$assertionsDisabled field for class C *) @@ -67,7 +67,8 @@ val create_array_type : Typ.t -> int -> Typ.t (** [create_array_type typ dim] creates an array type with dimension dim and content typ *) val extract_cn_no_obj : Typ.t -> JBasics.class_name option -(** [extract_cn_type_np] returns the Java class name of typ when typ is a pointer type, otherwise returns None *) +(** [extract_cn_type_np] returns the Java class name of typ when typ is a pointer type, otherwise + returns None *) val object_type_to_string : JBasics.object_type -> string (** returns a string representation of an object Java type *) diff --git a/infer/src/labs/00_dummy_checker/ResourceLeaks.ml b/infer/src/labs/00_dummy_checker/ResourceLeaks.ml index 07eb60e05..5c56a82d0 100644 --- a/infer/src/labs/00_dummy_checker/ResourceLeaks.ml +++ b/infer/src/labs/00_dummy_checker/ResourceLeaks.ml @@ -77,7 +77,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/01_integer_domain/ResourceLeaks.ml b/infer/src/labs/01_integer_domain/ResourceLeaks.ml index 6225a0d71..544c06770 100644 --- a/infer/src/labs/01_integer_domain/ResourceLeaks.ml +++ b/infer/src/labs/01_integer_domain/ResourceLeaks.ml @@ -79,7 +79,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/02_domain_join/ResourceLeaks.ml b/infer/src/labs/02_domain_join/ResourceLeaks.ml index 6225a0d71..544c06770 100644 --- a/infer/src/labs/02_domain_join/ResourceLeaks.ml +++ b/infer/src/labs/02_domain_join/ResourceLeaks.ml @@ -79,7 +79,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/03_domain_top/ResourceLeaks.ml b/infer/src/labs/03_domain_top/ResourceLeaks.ml index 6225a0d71..544c06770 100644 --- a/infer/src/labs/03_domain_top/ResourceLeaks.ml +++ b/infer/src/labs/03_domain_top/ResourceLeaks.ml @@ -79,7 +79,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/04_interprocedural/ResourceLeaks.ml b/infer/src/labs/04_interprocedural/ResourceLeaks.ml index 8a0c2ccb1..b0e8d9dad 100644 --- a/infer/src/labs/04_interprocedural/ResourceLeaks.ml +++ b/infer/src/labs/04_interprocedural/ResourceLeaks.ml @@ -93,7 +93,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml b/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml index f28d20a8e..d4f54aea1 100644 --- a/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml +++ b/infer/src/labs/05_access_paths_interprocedural/ResourceLeaks.ml @@ -100,7 +100,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/labs/ResourceLeaks.ml b/infer/src/labs/ResourceLeaks.ml index 206cef2a6..31fbab304 100644 --- a/infer/src/labs/ResourceLeaks.ml +++ b/infer/src/labs/ResourceLeaks.ml @@ -77,7 +77,7 @@ end module CFG = ProcCfg.Normal (** 5(a) Type of CFG to analyze--Exceptional to follow exceptional control-flow edges, Normal to - ignore them *) + ignore them *) (* Create an intraprocedural abstract interpreter from the transfer functions we defined *) module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG)) diff --git a/infer/src/nullsafe/AnnotatedField.mli b/infer/src/nullsafe/AnnotatedField.mli index 327876413..5c3d0113d 100644 --- a/infer/src/nullsafe/AnnotatedField.mli +++ b/infer/src/nullsafe/AnnotatedField.mli @@ -12,4 +12,4 @@ open! IStd type t = {annotation_deprecated: Annot.Item.t; annotated_type: AnnotatedType.t} val get : Tenv.t -> Typ.Fieldname.t -> Typ.t -> t option -(** Looks up for a field declaration and, in case of success, converts it to {t} *) +(** Looks up for a field declaration and, in case of success, converts it to [t] *) diff --git a/infer/src/nullsafe/AnnotatedNullability.ml b/infer/src/nullsafe/AnnotatedNullability.ml index df11cec63..bdd0795d6 100644 --- a/infer/src/nullsafe/AnnotatedNullability.ml +++ b/infer/src/nullsafe/AnnotatedNullability.ml @@ -8,34 +8,36 @@ open! IStd module F = Format -(** Representation of a (non local) type in Java program, with added information about its nullability, - according to the source code. - Nullability information might come either from explicit annotations, or from other sources, - including conventions about defaults. - Note that nullsafe omits Nullability information in types used for local variable declarations: - this information is inferred according to flow-sensitive inferrence rule. -*) +(** Representation of a (non local) type in Java program, with added information about its + nullability, according to the source code. Nullability information might come either from + explicit annotations, or from other sources, including conventions about defaults. Note that + nullsafe omits Nullability information in types used for local variable declarations: this + information is inferred according to flow-sensitive inferrence rule. *) type t = | Nullable of nullable_origin - | DeclaredNonnull of declared_nonnull_origin (** See {Nullability.t} for explanation *) + | DeclaredNonnull of declared_nonnull_origin (** See {!Nullability.t} for explanation *) | Nonnull of nonnull_origin [@@deriving compare] and nullable_origin = - | AnnotatedNullable (** The type is expicitly annotated with @Nullable in the code *) + | AnnotatedNullable (** The type is expicitly annotated with [@Nullable] in the code *) | AnnotatedPropagatesNullable - (** If a function param is annotated as @PropagatesNullable, this param is automatically nullable *) + (** If a function param is annotated as [@PropagatesNullable], this param is automatically + nullable *) | HasPropagatesNullableInParam - (** If a method has at least one param marked as @PropagatesNullable, return value is automatically nullable *) + (** If a method has at least one param marked as [@PropagatesNullable], return value is + automatically nullable *) | ModelledNullable (** nullsafe knows it is nullable via its internal models *) [@@deriving compare] and declared_nonnull_origin = | AnnotatedNonnull - (** The type is explicitly annotated as non nullable via one of nonnull annotations Nullsafe recognizes *) + (** The type is explicitly annotated as non nullable via one of nonnull annotations Nullsafe + recognizes *) | ImplicitlyNonnull - (** Infer was run in mode where all not annotated (non local) types are treated as non nullable *) + (** Infer was run in mode where all not annotated (non local) types are treated as non + nullable *) and nonnull_origin = | ModelledNonnull (** nullsafe knows it is non-nullable via its internal models *) diff --git a/infer/src/nullsafe/AnnotatedNullability.mli b/infer/src/nullsafe/AnnotatedNullability.mli index 04a0b0d3b..30efa7b6a 100644 --- a/infer/src/nullsafe/AnnotatedNullability.mli +++ b/infer/src/nullsafe/AnnotatedNullability.mli @@ -7,38 +7,39 @@ open! IStd -(** Nullability of a type in Java program (e.g. in a function or field declaration). - It might come from explicit annotations (or lack of annotation), or from other sources, - including conventions about defaults, models, or the mode nullsafe runs in. - NOTE: This is complementary to {!InferredNullability.t}. - {!InferredNullability} contains info about _actual_ nullability - (what did nullsafe infer according to its flow-sensitive rules.). - In contrast, AnnotatedNullability represents _formal_ type as it appears - in the program code. - NOTE: Nullsafe disregards user-provided annotations for local types, so - annotated nullability applies only for types declared at methods and field level. -*) +(** Nullability of a type in Java program (e.g. in a function or field declaration). It might come + from explicit annotations (or lack of annotation), or from other sources, including conventions + about defaults, models, or the mode nullsafe runs in. NOTE: This is complementary to + {!InferredNullability.t}. {!InferredNullability} contains info about _actual_ nullability (what + did nullsafe infer according to its flow-sensitive rules.). In contrast, AnnotatedNullability + represents _formal_ type as it appears in the program code. NOTE: Nullsafe disregards + user-provided annotations for local types, so annotated nullability applies only for types + declared at methods and field level. *) type t = | Nullable of nullable_origin - | DeclaredNonnull of declared_nonnull_origin (** See {Nullability.t} for explanation *) + | DeclaredNonnull of declared_nonnull_origin (** See {!Nullability.t} for explanation *) | Nonnull of nonnull_origin [@@deriving compare] and nullable_origin = - | AnnotatedNullable (** The type is expicitly annotated with @Nullable in the code *) + | AnnotatedNullable (** The type is expicitly annotated with [@Nullable] in the code *) | AnnotatedPropagatesNullable - (** If a function param is annotated as @PropagatesNullable, this param is automatically nullable *) + (** If a function param is annotated as [@PropagatesNullable], this param is automatically + nullable *) | HasPropagatesNullableInParam - (** If a method has at least one param marked as @PropagatesNullable, return value is automatically nullable *) + (** If a method has at least one param marked as [@PropagatesNullable], return value is + automatically nullable *) | ModelledNullable (** nullsafe knows it is nullable via its internal models *) [@@deriving compare] and declared_nonnull_origin = | AnnotatedNonnull - (** The type is explicitly annotated as non nullable via one of nonnull annotations Nullsafe recognizes *) + (** The type is explicitly annotated as non nullable via one of nonnull annotations Nullsafe + recognizes *) | ImplicitlyNonnull - (** Infer was run in mode where all not annotated (non local) types are treated as non nullable *) + (** Infer was run in mode where all not annotated (non local) types are treated as non + nullable *) and nonnull_origin = | ModelledNonnull (** nullsafe knows it is non-nullable via its internal models *) @@ -49,9 +50,8 @@ and nonnull_origin = val get_nullability : t -> Nullability.t val of_type_and_annotation : is_strict_mode:bool -> Typ.t -> Annot.Item.t -> t -(** Given the type and its annotations, returns its nullability. - NOTE: it does not take into account models etc., so this is intended to be used - as a helper function for more high-level annotation processing. - *) +(** Given the type and its annotations, returns its nullability. NOTE: it does not take into account + models etc., so this is intended to be used as a helper function for more high-level annotation + processing. *) val pp : Format.formatter -> t -> unit diff --git a/infer/src/nullsafe/AnnotatedSignature.mli b/infer/src/nullsafe/AnnotatedSignature.mli index 7432d344e..12acc06e4 100644 --- a/infer/src/nullsafe/AnnotatedSignature.mli +++ b/infer/src/nullsafe/AnnotatedSignature.mli @@ -32,7 +32,8 @@ 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 -(** Override nullability for a function signature given its modelled nullability (for ret value and params) *) +(** 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. *) diff --git a/infer/src/nullsafe/AssignmentRule.mli b/infer/src/nullsafe/AssignmentRule.mli index 68b55d1cf..02b2eabd6 100644 --- a/infer/src/nullsafe/AssignmentRule.mli +++ b/infer/src/nullsafe/AssignmentRule.mli @@ -6,10 +6,9 @@ *) open! IStd -(** Assignment rule should be checked when a value is assigned to a location. - Assignment can be explicit (lhs = rhs) or implicit (e.g. returning from a function). - This rule checks if null can be passed to a place that does not expect null. - *) +(** Assignment rule should be checked when a value is assigned to a location. Assignment can be + explicit (lhs = rhs) or implicit (e.g. returning from a function). This rule checks if null can + be passed to a place that does not expect null. *) type violation [@@deriving compare] @@ -35,4 +34,5 @@ val violation_description : -> assignment_type -> rhs_origin:TypeOrigin.t -> string * IssueType.t * Location.t -(** Given context around violation, return error message together with the info where to put this message *) +(** Given context around violation, return error message together with the info where to put this + message *) diff --git a/infer/src/nullsafe/DereferenceRule.mli b/infer/src/nullsafe/DereferenceRule.mli index 9afaffe97..6b9410592 100644 --- a/infer/src/nullsafe/DereferenceRule.mli +++ b/infer/src/nullsafe/DereferenceRule.mli @@ -6,9 +6,8 @@ *) open! IStd -(** Dereference rule should be checked every type an object is dereferenced. - The rule checks if the reference is nullable. - *) +(** Dereference rule should be checked every type an object is dereferenced. The rule checks if the + reference is nullable. *) type violation [@@deriving compare] @@ -28,4 +27,5 @@ val violation_description : -> nullable_object_descr:string option -> nullable_object_origin:TypeOrigin.t -> string * IssueType.t * Location.t -(** Given context around violation, return error message together with the info where to put this message *) +(** Given context around violation, return error message together with the info where to put this + message *) diff --git a/infer/src/nullsafe/ErrorRenderingUtils.mli b/infer/src/nullsafe/ErrorRenderingUtils.mli index d9ae1b8ec..ba69791f5 100644 --- a/infer/src/nullsafe/ErrorRenderingUtils.mli +++ b/infer/src/nullsafe/ErrorRenderingUtils.mli @@ -10,16 +10,12 @@ open! IStd val is_object_nullability_self_explanatory : object_expression:string -> TypeOrigin.t -> bool -(** In order to understand why such and such object is nullable (or not nullable), - we render its origin. - In some cases this is redundant and adds extra noise for the user. - *) +(** In order to understand why such and such object is nullable (or not nullable), we render its + origin. In some cases this is redundant and adds extra noise for the user. *) val get_strict_mode_violation_issue : bad_usage_location:Location.t -> TypeOrigin.t -> string * IssueType.t * Location.t -(** Situation when we tried to use DeclaredNonnull as Nonnull. - This is disallowed only in strict mode. - Returns a tuple (error message, issue type, error location). - NOTE: Location of the error will be NOT in the place when the value is used (that is [bad_usage_location]), - but where the value is first obtained from. - *) +(** Situation when we tried to use DeclaredNonnull as Nonnull. This is disallowed only in strict + mode. Returns a tuple (error message, issue type, error location). NOTE: Location of the error + will be NOT in the place when the value is used (that is [bad_usage_location]), but where the + value is first obtained from. *) diff --git a/infer/src/nullsafe/InferredNullability.mli b/infer/src/nullsafe/InferredNullability.mli index a053c7b75..5fb834f89 100644 --- a/infer/src/nullsafe/InferredNullability.mli +++ b/infer/src/nullsafe/InferredNullability.mli @@ -7,15 +7,12 @@ open! IStd -(** Module to represent nullability of expressions inferred during - flow-sensitive symbolic execution. - NOTE: This is complementaty to {!InferredNullability.t}. - {!InferredNullability} contains info about _formal_ nullability - (what does the code say about nullability of a given type, according to - explicit annotations and implicit agreements (e.g. models)). - In contrast, InferredNullability represents what Nullsafe thinks about such and such - expression according to its type inference rules. - *) +(** Module to represent nullability of expressions inferred during flow-sensitive symbolic + execution. NOTE: This is complementaty to {!InferredNullability.t}. {!InferredNullability} + contains info about _formal_ nullability (what does the code say about nullability of a given + type, according to explicit annotations and implicit agreements (e.g. models)). In contrast, + InferredNullability represents what Nullsafe thinks about such and such expression according to + its type inference rules. *) type t [@@deriving compare] @@ -26,11 +23,11 @@ val create : TypeOrigin.t -> t val is_nonnull_or_declared_nonnull : t -> bool val get_origin : t -> TypeOrigin.t -(** The simple explanation of how was nullability inferred. *) +(** The simple explanation of how was nullability inferred. *) val join : t -> t -> t -(** This is what happens with nullability when we join two flows in CFG, - e.g. +(** This is what happens with nullability when we join two flows in CFG, e.g. + {[ if(something) { a = e1; @@ -38,8 +35,7 @@ val join : t -> t -> t a = e2; } // what is nullability of `a` at this point? - ]} - *) + ]} *) val origin_is_fun_library : t -> bool diff --git a/infer/src/nullsafe/InheritanceRule.mli b/infer/src/nullsafe/InheritanceRule.mli index 3b66b1f50..29785b4ea 100644 --- a/infer/src/nullsafe/InheritanceRule.mli +++ b/infer/src/nullsafe/InheritanceRule.mli @@ -7,14 +7,15 @@ open! IStd (** Inheritance rule: - a) Return type for an overridden method is covariant: - overridden method is allowed to narrow down the return value to a subtype of the one from the - base method; this means it is OK to make the return value non-null when it was nullable in the base) - b) Parameter type for an overridden method is contravariant. - It is OK for a derived method to accept nullable in the params even if the base does not accept nullable. - NOTE: Rule a) is based on Java covariance rule for the return type. - In contrast, rule b) is nullsafe specific as Java does not support type contravariance for method params. - *) + + + Return type for an overridden method is covariant: overridden method is allowed to narrow down + the return value to a subtype of the one from the base method; this means it is OK to make the + return value non-null when it was nullable in the base) + + Parameter type for an overridden method is contravariant. It is OK for a derived method to + accept nullable in the params even if the base does not accept nullable. + + NOTE: Rule 1) is based on Java covariance rule for the return type. In contrast, rule 2) is + nullsafe specific as Java does not support type contravariance for method params. *) type violation [@@deriving compare] diff --git a/infer/src/nullsafe/Initializers.mli b/infer/src/nullsafe/Initializers.mli index f4453cc4d..31e37d42f 100644 --- a/infer/src/nullsafe/Initializers.mli +++ b/infer/src/nullsafe/Initializers.mli @@ -7,16 +7,16 @@ open! IStd -(** Functionality for evaluating typestates after class initialization. - Nullsafe's notion of initialization augments Java's one in the following way: - 1. A method is considered "initializer" if it is either marked as @Initializer or is in - the list of known initializer methods (e.g. onCreate()). - 2. For each constructor, Nullsafe assumes all initializer methods will be called after - the constructor is called. (Nullsafe does not check if this assumption is indeed true). - 3. Nullsafe uses assumption 2, in order to check if class fields were initialized or not. - (a non-nullable field is considered not initialized if it is not initialized in at least - one constructor). - *) +(** Functionality for evaluating typestates after class initialization. Nullsafe's notion of + initialization augments Java's one in the following way: + + + A method is considered "initializer" if it is either marked as [@Initializer] or is in the + list of known initializer methods (e.g. onCreate()). + + For each constructor, Nullsafe assumes all initializer methods will be called after the + constructor is called. (Nullsafe does not check if this assumption is indeed true). + + Nullsafe uses assumption 2, in order to check if class fields were initialized or not. (a + non-nullable field is considered not initialized if it is not initialized in at least one + constructor). *) val final_initializer_typestates_lazy : Tenv.t diff --git a/infer/src/nullsafe/Nullability.ml b/infer/src/nullsafe/Nullability.ml index 9e71297da..a6dd4c616 100644 --- a/infer/src/nullsafe/Nullability.ml +++ b/infer/src/nullsafe/Nullability.ml @@ -11,14 +11,13 @@ type t = | Null (** The only possible value for that type is null *) | Nullable (** No guarantees on the nullability *) | DeclaredNonnull - (** The type comes from a signature that is annotated (explicitly or implicitly according to conventions) - as non-nullable. Hovewer, it might still contain null since the truthfullness of the declaration was - not checked. - *) + (** The type comes from a signature that is annotated (explicitly or implicitly according to + conventions) as non-nullable. Hovewer, it might still contain null since the truthfullness + of the declaration was not checked. *) | Nonnull - (** We believe that this value can not be null. If it is not the case, this is - an unsoundness issue for Nullsafe, and we aim to minimize number of such issues - occuring in real-world programs. *) + (** We believe that this value can not be null. If it is not the case, this is an unsoundness + issue for Nullsafe, and we aim to minimize number of such issues occuring in real-world + programs. *) [@@deriving compare, equal] let top = Nullable diff --git a/infer/src/nullsafe/Nullability.mli b/infer/src/nullsafe/Nullability.mli index 3f6274457..84816c1e6 100644 --- a/infer/src/nullsafe/Nullability.mli +++ b/infer/src/nullsafe/Nullability.mli @@ -7,35 +7,33 @@ open! IStd -(** Nullability is a central concept for Nullsafe type-checker. - Informally, nullability is a "type" - set of values together with some additional context. - All nullsafe is interested about if whether a value can be null, and if it can, - what are potential causes of leaking the null inside it. - Formally, nullability values form a lattice with partial order and upper bound operations. - Practically, most of nullsafe core should remain agnostic over exact values of nullability - (e.g. pattern-mathching over them should be a rare case. Core of typechecker should deal with subtyping and joins instead.) - *) +(** Nullability is a central concept for Nullsafe type-checker. Informally, nullability is a "type" + \- set of values together with some additional context. All nullsafe is interested about if + whether a value can be null, and if it can, what are potential causes of leaking the null inside + it. Formally, nullability values form a lattice with partial order and upper bound operations. + Practically, most of nullsafe core should remain agnostic over exact values of nullability (e.g. + pattern-mathching over them should be a rare case. Core of typechecker should deal with + subtyping and joins instead.) *) type t = | Null (** The only possible value for that type is null *) | Nullable (** No guarantees on the nullability *) | DeclaredNonnull - (** The type comes from a signature that is annotated (explicitly or implicitly according to conventions) - as non-nullable. Hovewer, it might still contain null since the truthfullness of the declaration was - not checked. - *) + (** The type comes from a signature that is annotated (explicitly or implicitly according to + conventions) as non-nullable. Hovewer, it might still contain null since the truthfullness + of the declaration was not checked. *) | Nonnull - (** We believe that this value can not be null. If it is not the case, this is - an unsoundness issue for Nullsafe, and we aim to minimize number of such issues - occuring in real-world programs. *) + (** We believe that this value can not be null. If it is not the case, this is an unsoundness + issue for Nullsafe, and we aim to minimize number of such issues occuring in real-world + programs. *) [@@deriving compare, equal] val top : t (** The most generic type. *) val is_subtype : subtype:t -> supertype:t -> bool -(** A is a subtype of B, if all values of A can be represented in B. - Subtype relation is reflexive: everything is a subtype of itself. *) +(** A is a subtype of B, if all values of A can be represented in B. Subtype relation is reflexive: + everything is a subtype of itself. *) val join : t -> t -> t (** Unique upper bound over two types: the most precise type that is a supertype of both. diff --git a/infer/src/nullsafe/OverAnnotatedRule.mli b/infer/src/nullsafe/OverAnnotatedRule.mli index d462b0de8..375536e42 100644 --- a/infer/src/nullsafe/OverAnnotatedRule.mli +++ b/infer/src/nullsafe/OverAnnotatedRule.mli @@ -6,28 +6,23 @@ *) open! IStd -(** Checks if a type in signature (e.g. return value) can be made more specific. - NOTE: This rule is complementatary to assignment rule. - While assignment rule checks a single assignment `lhs = rhs`, this rule - checks checks ALL assignments to `lhs` in the program. - NOTE: Violation of this rule is not a type violation, hence it should never be surfaced as error: - `lhs`'s type can be intentionally made broad by code author - (e.g. to anticipate future changes in the implementation). - Heuristits are required to correctly surface overannotated rule to the user. - This rule is useful for some scenarios, especially for nullability code conversions - when it is expected that some signatures were annotated with @Nullable defensively, so - surfacing such cases can improve API and make migration smooth. - *) +(** Checks if a type in signature (e.g. return value) can be made more specific. NOTE: This rule is + complementatary to assignment rule. While assignment rule checks a single assignment `lhs = + rhs`, this rule checks checks ALL assignments to `lhs` in the program. NOTE: Violation of this + rule is not a type violation, hence it should never be surfaced as error: `lhs`'s type can be + intentionally made broad by code author (e.g. to anticipate future changes in the + implementation). Heuristits are required to correctly surface overannotated rule to the user. + This rule is useful for some scenarios, especially for nullability code conversions when it is + expected that some signatures were annotated with [@Nullable] defensively, so surfacing such + cases can improve API and make migration smooth. *) type violation [@@deriving compare] val check : what:Nullability.t -> by_rhs_upper_bound:Nullability.t -> (unit, violation) result -(** - Checks if the declared type for `what` can be narrowed, based on the information about - all assignments `what = rhs_i`. - If an upper bound of `rhs_i` over ALL assignents `what = rhs_i` that exist in the program - is a _strict_ subtype of lhs, `lhs`'s type can be narrowed to be that upper bound. -*) +(** Checks if the declared type for `what` can be narrowed, based on the information about all + assignments `what = rhs_i`. If an upper bound of `rhs_i` over ALL assignents `what = rhs_i` that + exist in the program is a _strict_ subtype of lhs, `lhs`'s type can be narrowed to be that upper + bound. *) type violation_type = | FieldOverAnnoted of Typ.Fieldname.t diff --git a/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.mli b/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.mli index 378b9258f..243fdeb6f 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.mli +++ b/infer/src/nullsafe/ThirdPartyAnnotationGlobalRepo.mli @@ -10,7 +10,8 @@ open! IStd (** A singleton. Should be initialized once prior to start of nullsafe. *) val initialize : absolute_path_to_repo:string option -> ThirdPartyAnnotationInfo.storage -> unit -(** Should be initialized exactly once before access. Path to repo is None if there is no repo on the disk. *) +(** Should be initialized exactly once before access. Path to repo is None if there is no repo on + the disk. *) val get_repo : unit -> ThirdPartyAnnotationInfo.storage (** Can be accessed only when initialization was done *) diff --git a/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli b/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli index 8588b83aa..ec54cdd59 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli +++ b/infer/src/nullsafe/ThirdPartyAnnotationInfo.mli @@ -27,16 +27,12 @@ val add_from_signature_file : (** Parse the information from the signature file, and add it to the storage *) val find_nullability_info : storage -> ThirdPartyMethod.unique_repr -> signature_info option -(** The main method. Do we have an information about the third-party method? - If we do not, or it is not a third-party method, returns None. - Otherwise returns the nullability information. - *) +(** The main method. Do we have an information about the third-party method? If we do not, or it is + not a third-party method, returns None. Otherwise returns the nullability information. *) 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. - *) +(** 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 -(** 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 - *) +(** 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/ThirdPartyAnnotationInfoLoader.mli b/infer/src/nullsafe/ThirdPartyAnnotationInfoLoader.mli index 018cc08cb..051bc96b3 100644 --- a/infer/src/nullsafe/ThirdPartyAnnotationInfoLoader.mli +++ b/infer/src/nullsafe/ThirdPartyAnnotationInfoLoader.mli @@ -11,7 +11,5 @@ type load_error val pp_load_error : Format.formatter -> load_error -> unit val load : path_to_repo_dir:string -> (ThirdPartyAnnotationInfo.storage, load_error) result -(** Given a path to a repo with 3rd annotation info, loads it from a disk to - in-memory representation. - After this is done, information can be requested via [ThirdPartyAnnotationInfo]. - *) +(** Given a path to a repo with 3rd annotation info, loads it from a disk to in-memory + representation. After this is done, information can be requested via [ThirdPartyAnnotationInfo]. *) diff --git a/infer/src/nullsafe/ThirdPartyMethod.mli b/infer/src/nullsafe/ThirdPartyMethod.mli index d04d42382..580895749 100644 --- a/infer/src/nullsafe/ThirdPartyMethod.mli +++ b/infer/src/nullsafe/ThirdPartyMethod.mli @@ -5,21 +5,19 @@ * LICENSE file in the root directory of this source tree. *) -(** A helper module responsible for representing nullability information for a single 3rd party method, - as well with functionality to read this information from the 3rd party nullability repository. - *) +(** A helper module responsible for representing nullability information for a single 3rd party + method, as well with functionality to read this information from the 3rd party nullability + repository. *) open! IStd -(** E.g. "full.package.name.TypeName$NestedTypeName1$NestedTypeName2" - *) +(** E.g. "full.package.name.TypeName$NestedTypeName1$NestedTypeName2" *) type fully_qualified_type = string -(** The minimum information that is needed to _uniquely_ identify the method. - That why we don't include e.g. return type, access quilifiers, or whether the method is static - (because Java overload resolution rules ignore these things). - In contrast, parameter types are essential, because Java allows several methods with different types. - *) +(** The minimum information that is needed to _uniquely_ identify the method. That why we don't + include e.g. return type, access quilifiers, or whether the method is static (because Java + overload resolution rules ignore these things). In contrast, parameter types are essential, + because Java allows several methods with different types. *) type unique_repr = { class_name: fully_qualified_type ; method_name: method_name @@ -42,10 +40,10 @@ type parsing_error val string_of_parsing_error : parsing_error -> string val parse : string -> (unique_repr * nullability, parsing_error) result -(** Given a string representing nullability information for a given third-party method, - return the method signature and nullability of its params and return values. - The string should come from a repository storing 3rd party annotations. - E.g. - "package.name.Class$NestedClass#foo(package.name.SomeClass, @Nullable package.name.OtherClass) @Nullable" *) +(** Given a string representing nullability information for a given third-party method, return the + method signature and nullability of its params and return values. The string should come from a + repository storing 3rd party annotations. E.g. + ["package.name.Class$NestedClass#foo(package.name.SomeClass, @Nullable package.name.OtherClass) + @Nullable"] *) val pp_parse_result : Format.formatter -> unique_repr * nullability -> unit diff --git a/infer/src/nullsafe/eradicate.ml b/infer/src/nullsafe/eradicate.ml index 60ca55a70..27dcdd747 100644 --- a/infer/src/nullsafe/eradicate.ml +++ b/infer/src/nullsafe/eradicate.ml @@ -231,7 +231,7 @@ module Main = struct let callback = Callback.callback end -(** Eradicate checker for Java @Nullable annotations. *) +(** Eradicate checker for Java [@Nullable] annotations. *) let callback_eradicate = let checks = {TypeCheck.eradicate= true; check_ret_type= []} in Main.callback checks diff --git a/infer/src/nullsafe/eradicateChecks.ml b/infer/src/nullsafe/eradicateChecks.ml index 4fa5cefb7..c48f092ad 100644 --- a/infer/src/nullsafe/eradicateChecks.ml +++ b/infer/src/nullsafe/eradicateChecks.ml @@ -566,8 +566,8 @@ let check_inheritance_rule_for_signature find_canonical_duplicate tenv loc ~base () -(** Checks if the annotations are consistent with the derived classes and with the - implemented interfaces *) +(** Checks if the annotations are consistent with the derived classes and with the implemented + interfaces *) let check_overridden_annotations find_canonical_duplicate tenv proc_name proc_desc annotated_signature = let start_node = Procdesc.get_start_node proc_desc in diff --git a/infer/src/nullsafe/immutableChecker.ml b/infer/src/nullsafe/immutableChecker.ml index bda31d5a6..66055d3ad 100644 --- a/infer/src/nullsafe/immutableChecker.ml +++ b/infer/src/nullsafe/immutableChecker.ml @@ -7,7 +7,8 @@ open! IStd -(** Check an implicit cast when returning an immutable collection from a method whose type is mutable. *) +(** Check an implicit cast when returning an immutable collection from a method whose type is + mutable. *) let check_immutable_cast tenv curr_pname curr_pdesc typ_expected typ_found_opt loc : unit = match typ_found_opt with | Some typ_found -> ( diff --git a/infer/src/nullsafe/models.ml b/infer/src/nullsafe/models.ml index e69b31016..e16b07d27 100644 --- a/infer/src/nullsafe/models.ml +++ b/infer/src/nullsafe/models.ml @@ -62,9 +62,8 @@ let to_modelled_nullability ThirdPartyMethod.{ret_nullability; param_nullability (is_nullable ret_nullability, List.map param_nullability ~f:is_nullable) -(** Return the annotated signature of the procedure, taking into account models. - External models take precedence over internal ones. - *) +(** Return the annotated signature of the procedure, taking into account models. External models + take precedence over internal ones. *) let get_modelled_annotated_signature tenv proc_attributes = let proc_name = proc_attributes.ProcAttributes.proc_name in let is_strict_mode = diff --git a/infer/src/nullsafe/typeErr.ml b/infer/src/nullsafe/typeErr.ml index 575aed340..af783d4fd 100644 --- a/infer/src/nullsafe/typeErr.ml +++ b/infer/src/nullsafe/typeErr.ml @@ -99,9 +99,8 @@ let err_tbl : err_state H.t = H.create 1 (** Reset the error table. *) let reset () = H.reset err_tbl -(** Get the forall status of an err_instance. - The forall status indicates that the error should be printed only if it - occurs on every path. *) +(** Get the forall status of an err_instance. The forall status indicates that the error should be + printed only if it occurs on every path. *) let get_forall = function | Condition_redundant _ -> true @@ -117,8 +116,8 @@ let get_forall = function false -(** Reset the always field of the forall erros in the node, so if they are not set again - we know that they don't fire on every path. *) +(** Reset the always field of the forall erros in the node, so if they are not set again we know + that they don't fire on every path. *) let node_reset_forall node = let iter (err_instance, instr_ref_opt) err_state = match (instr_ref_opt, get_forall err_instance) with @@ -277,8 +276,8 @@ let report_error_now tenv (st_report_error : st_report_error) err_instance loc p ?severity err_description -(** Report an error unless is has been reported already, or unless it's a forall error - since it requires waiting until the end of the analysis and be printed by flush. *) +(** Report an error unless is has been reported already, or unless it's a forall error since it + requires waiting until the end of the analysis and be printed by flush. *) let report_error tenv (st_report_error : st_report_error) find_canonical_duplicate err_instance instr_ref_opt loc pdesc = let should_report_now = add_err find_canonical_duplicate err_instance instr_ref_opt loc in diff --git a/infer/src/nullsafe/typeOrigin.ml b/infer/src/nullsafe/typeOrigin.ml index a7b97472f..e3a19ef7d 100644 --- a/infer/src/nullsafe/typeOrigin.ml +++ b/infer/src/nullsafe/typeOrigin.ml @@ -20,21 +20,19 @@ type t = | ArrayLengthResult (** integer value - result of accessing array.length *) | ArrayAccess (** Result of accessing an array by index *) | InferredNonnull of {previous_origin: t} - (** The value is inferred as non-null during flow-sensitive type inference - (most commonly from relevant condition branch or assertion explicitly comparing the value with `null`) *) + (** The value is inferred as non-null during flow-sensitive type inference (most commonly from + relevant condition branch or assertion explicitly comparing the value with `null`) *) (* Below are two special values. *) | OptimisticFallback - (** Something went wrong during typechecking. - We fall back to optimistic (not-nullable) type to reduce potential non-actionable false positives. - Ideally we should not see these instances. They should be either processed gracefully - (and a dedicated type constructor should be added), or fixed. - T54687014 tracks unsoundness issues caused by this type. - *) + (** Something went wrong during typechecking. We fall back to optimistic (not-nullable) type + to reduce potential non-actionable false positives. Ideally we should not see these + instances. They should be either processed gracefully (and a dedicated type constructor + should be added), or fixed. T54687014 tracks unsoundness issues caused by this type. *) | Undef (** Undefined value before initialization *) [@@deriving compare] and field_origin = - { object_origin: t (** field's object origin (object is before field access operator `.`) *) + { object_origin: t (** field's object origin (object is before field access operator `.`) *) ; field_name: Typ.Fieldname.t ; field_type: AnnotatedType.t ; access_loc: Location.t } diff --git a/infer/src/nullsafe/typeOrigin.mli b/infer/src/nullsafe/typeOrigin.mli index 177e88241..baed18f14 100644 --- a/infer/src/nullsafe/typeOrigin.mli +++ b/infer/src/nullsafe/typeOrigin.mli @@ -18,20 +18,19 @@ type t = | ArrayLengthResult (** integer value - result of accessing array.length *) | ArrayAccess (** Result of accessing an array by index *) | InferredNonnull of {previous_origin: t} - (** The value is inferred as non-null during flow-sensitive type inference - (most commonly from relevant condition branch or assertion explicitly comparing the value with `null`) *) + (** The value is inferred as non-null during flow-sensitive type inference (most commonly from + relevant condition branch or assertion explicitly comparing the value with `null`) *) (* Below are two special values. *) | OptimisticFallback - (** Something went wrong during typechecking. - We fall back to optimistic (not-nullable) type to reduce potential non-actionable false positives. - Ideally we should not see these instances. They should be either processed gracefully - (and a dedicated type constructor should be added), or fixed. - T54687014 tracks unsoundness issues caused by this type. *) + (** Something went wrong during typechecking. We fall back to optimistic (not-nullable) type + to reduce potential non-actionable false positives. Ideally we should not see these + instances. They should be either processed gracefully (and a dedicated type constructor + should be added), or fixed. T54687014 tracks unsoundness issues caused by this type. *) | Undef (** Undefined value before initialization *) [@@deriving compare] and field_origin = - { object_origin: t (** field's object origin (object is before field access operator `.`) *) + { object_origin: t (** field's object origin (object is before field access operator `.`) *) ; field_name: Typ.Fieldname.t ; field_type: AnnotatedType.t ; access_loc: Location.t } diff --git a/infer/src/pulse/PulseAbductiveDomain.ml b/infer/src/pulse/PulseAbductiveDomain.ml index 3dc736d54..af373713d 100644 --- a/infer/src/pulse/PulseAbductiveDomain.ml +++ b/infer/src/pulse/PulseAbductiveDomain.ml @@ -350,8 +350,8 @@ module PrePost = struct | Aliasing of {addr_caller: AbstractValue.t; addr_callee: AbstractValue.t; addr_callee': AbstractValue.t} (** raised when the precondition and the current state disagree on the aliasing, i.e. some - addresses [callee_addr] and [callee_addr'] that are distinct in the pre are aliased to - a single address [caller_addr] in the caller's current state. Typically raised when + addresses [callee_addr] and [callee_addr'] that are distinct in the pre are aliased to a + single address [caller_addr] in the caller's current state. Typically raised when calling [foo(z,z)] where the spec for [foo(x,y)] says that [x] and [y] are disjoint. *) | Arithmetic of { addr_caller: AbstractValue.t @@ -384,10 +384,9 @@ module PrePost = struct ; visited: AddressSet.t (** set of callee addresses that have been visited already - NOTE: this is not always equal to the domain of [rev_subst]: when applying the post - we visit each subgraph from each formal independently so we reset [visited] between - the visit of each formal *) - } + NOTE: this is not always equal to the domain of [rev_subst]: when applying the post we + visit each subgraph from each formal independently so we reset [visited] between the + visit of each formal *) } let pp_call_state fmt {astate; subst; rev_subst; visited} = F.fprintf fmt @@ -447,8 +446,8 @@ module PrePost = struct (** Materialize the (abstract memory) subgraph of [pre] reachable from [addr_pre] in - [call_state.astate] starting from address [addr_caller]. Report an error if some invalid - addresses are traversed in the process. *) + [call_state.astate] starting from address [addr_caller]. Report an error if some invalid + addresses are traversed in the process. *) let rec materialize_pre_from_address callee_proc_name call_location ~pre ~addr_pre ~addr_hist_caller call_state = match visit call_state ~addr_callee:addr_pre ~addr_hist_caller with diff --git a/infer/src/pulse/PulseAbductiveDomain.mli b/infer/src/pulse/PulseAbductiveDomain.mli index 922650ad1..47f7f4951 100644 --- a/infer/src/pulse/PulseAbductiveDomain.mli +++ b/infer/src/pulse/PulseAbductiveDomain.mli @@ -78,7 +78,7 @@ module Memory : sig val eval_edge : AbstractValue.t * ValueHistory.t -> Access.t -> t -> t * (AbstractValue.t * ValueHistory.t) (** [eval_edge (addr,hist) access astate] follows the edge [addr --access--> .] in memory and - returns what it points to or creates a fresh value if that edge didn't exist. *) + returns what it points to or creates a fresh value if that edge didn't exist. *) val get_arithmetic : AbstractValue.t -> t -> (Arithmetic.t * Trace.t) option @@ -104,8 +104,8 @@ module PrePost : sig -> actuals:((AbstractValue.t * ValueHistory.t) * Typ.t) list -> domain_t -> ((domain_t * (AbstractValue.t * ValueHistory.t) option) option, Diagnostic.t) result - (** return the abstract state after the call along with an optional return value, or [None] if - the precondition could not be satisfied (e.g. some aliasing constraints were not satisfied) *) + (** return the abstract state after the call along with an optional return value, or [None] if the + precondition could not be satisfied (e.g. some aliasing constraints were not satisfied) *) end val discard_unreachable : t -> t diff --git a/infer/src/pulse/PulseArithmetic.ml b/infer/src/pulse/PulseArithmetic.ml index b01f8f1fb..737494522 100644 --- a/infer/src/pulse/PulseArithmetic.ml +++ b/infer/src/pulse/PulseArithmetic.ml @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd module F = Format module L = Logging diff --git a/infer/src/pulse/PulseArithmetic.mli b/infer/src/pulse/PulseArithmetic.mli index 25adbe31d..a9365e4d4 100644 --- a/infer/src/pulse/PulseArithmetic.mli +++ b/infer/src/pulse/PulseArithmetic.mli @@ -24,14 +24,13 @@ type abduction_result = val abduce_binop_is_true : negated:bool -> Binop.t -> t option -> t option -> abduction_result (** given [arith_lhs_opt bop arith_rhs_opt] and if not [negated], return either - - [Unsatisfiable] iff lhs bop rhs = ∅ + - [Unsatisfiable] iff lhs bop rhs = ∅ - - [Satisfiable (abduced_lhs_opt,abduced_rhs_opt)] iff lhs bop rhs ≠ ∅, such that (taking lhs=true - if lhs_opt is [None], same for rhs) [abduced_lhs_opt=Some alhs] if (lhs bop rhs ≠ ∅ => alhs⇔lhs) - (and similarly for rhs) + - [Satisfiable (abduced_lhs_opt,abduced_rhs_opt)] iff lhs bop rhs ≠ ∅, such that (taking + lhs=true if lhs_opt is [None], same for rhs) [abduced_lhs_opt=Some alhs] if (lhs bop rhs ≠ + ∅ => alhs⇔lhs) (and similarly for rhs) - If [negated] then imagine a similar explanation replacing "= ∅" with "≠ ∅" and vice-versa. -*) + If [negated] then imagine a similar explanation replacing "= ∅" with "≠ ∅" and vice-versa. *) val binop : Binop.t -> t -> t -> t option diff --git a/infer/src/pulse/PulseAttribute.ml b/infer/src/pulse/PulseAttribute.ml index 7a4c47171..c2c3935cf 100644 --- a/infer/src/pulse/PulseAttribute.ml +++ b/infer/src/pulse/PulseAttribute.ml @@ -11,12 +11,11 @@ module Invalidation = PulseInvalidation module Trace = PulseTrace module ValueHistory = PulseValueHistory -(** Make sure we don't depend on {!AbstractValue} to avoid attributes depending on - values. Otherwise they become a pain to handle when comparing memory states. +(** Make sure we don't depend on {!AbstractValue} to avoid attributes depending on values. Otherwise + they become a pain to handle when comparing memory states. - If you find you need to make attributes depend on {!AbstractValue} then remember to modify - graph operations of {!PulseDomain} and the interprocedural operations in {!PulseAbductiveDomain} -*) + If you find you need to make attributes depend on {!AbstractValue} then remember to modify graph + operations of {!PulseDomain} and the interprocedural operations in {!PulseAbductiveDomain} *) include struct [@@@warning "-60"] diff --git a/infer/src/pulse/PulseBaseDomain.ml b/infer/src/pulse/PulseBaseDomain.ml index 71fcee2b1..866497105 100644 --- a/infer/src/pulse/PulseBaseDomain.ml +++ b/infer/src/pulse/PulseBaseDomain.ml @@ -26,8 +26,9 @@ let empty = (** comparison between two elements of the domain to determine the [<=] relation Given two states [lhs] and [rhs], try to find a bijection [lhs_to_rhs] (with inverse - [rhs_to_lhs]) between the addresses of [lhs] and [rhs] such that [lhs_to_rhs(reachable(lhs)) = - reachable(rhs)] (where addresses are reachable if they are reachable from stack variables). *) + [rhs_to_lhs]) between the addresses of [lhs] and [rhs] such that + [lhs_to_rhs(reachable(lhs)) = reachable(rhs)] (where addresses are reachable if they are + reachable from stack variables). *) module GraphComparison = struct module AddressMap = PrettyPrintable.MakePPMap (AbstractValue) @@ -140,8 +141,8 @@ module GraphComparison = struct (** check that the memory graph induced by the addresses in [lhs] reachable from the variables in - [stack_lhs] is a isograph of the same graph in [rhs] starting from [stack_rhs], up to some - [mapping] *) + [stack_lhs] is a isograph of the same graph in [rhs] starting from [stack_rhs], up to some + [mapping] *) let rec isograph_map_from_stack ~lhs ~stack_lhs ~rhs ~stack_rhs mapping = match (stack_lhs, stack_rhs) with | [], [] -> diff --git a/infer/src/pulse/PulseBaseDomain.mli b/infer/src/pulse/PulseBaseDomain.mli index 0e5a19954..eea5cc9db 100644 --- a/infer/src/pulse/PulseBaseDomain.mli +++ b/infer/src/pulse/PulseBaseDomain.mli @@ -15,8 +15,8 @@ val empty : t include AbstractDomain.NoJoin with type t := t val reachable_addresses : t -> AbstractValue.Set.t -(** compute the set of abstract addresses that are "used" in the abstract state, i.e. reachable - from the stack variables *) +(** compute the set of abstract addresses that are "used" in the abstract state, i.e. reachable from + the stack variables *) type mapping diff --git a/infer/src/pulse/PulseOperations.mli b/infer/src/pulse/PulseOperations.mli index a5e0e9f35..6850e4aee 100644 --- a/infer/src/pulse/PulseOperations.mli +++ b/infer/src/pulse/PulseOperations.mli @@ -124,4 +124,4 @@ val unknown_call : -> t -> t (** performs a call to a function with no summary by optimistically havoc'ing the by-ref actuals and - the return value as appropriate *) + the return value as appropriate *) diff --git a/infer/src/pulse/PulseTrace.mli b/infer/src/pulse/PulseTrace.mli index e12bd0d80..6fafbb724 100644 --- a/infer/src/pulse/PulseTrace.mli +++ b/infer/src/pulse/PulseTrace.mli @@ -21,8 +21,8 @@ type t = val pp : pp_immediate:(F.formatter -> unit) -> F.formatter -> t -> unit val get_outer_location : t -> Location.t -(** skip histories and go straight to the where the action is: either the action itself or the - call that leads to the action *) +(** skip histories and go straight to the where the action is: either the action itself or the call + that leads to the action *) val get_start_location : t -> Location.t (** initial step in the history if not empty, or else same as {!get_outer_location} *) diff --git a/infer/src/quandary/TaintSpec.ml b/infer/src/quandary/TaintSpec.ml index f15659ea1..ac036a60b 100644 --- a/infer/src/quandary/TaintSpec.ml +++ b/infer/src/quandary/TaintSpec.ml @@ -23,8 +23,8 @@ 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 - (** return a summary for handling an unknown call at the given site with the given return type - and actuals *) + (** 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 diff --git a/infer/src/scripts/checkCopyright.ml b/infer/src/scripts/checkCopyright.ml index 66c7e582e..238f30597 100644 --- a/infer/src/scripts/checkCopyright.ml +++ b/infer/src/scripts/checkCopyright.ml @@ -16,8 +16,8 @@ let exit_code_of_event = function CopyrightModified -> 1 | CopyrightMalformed -> type comment_style = | Line of string * bool - (** line comments, eg "#" for shell, and whether there should be a - newline before the copyright notice *) + (** line comments, eg "#" for shell, and whether there should be a newline before the + copyright notice *) | Block of string * string * string * bool (** block comments, eg ("(*", "*", "*)") for ocaml *) [@@deriving compare] diff --git a/infer/src/scuba/LogEntry.ml b/infer/src/scuba/LogEntry.ml index 4bd988be8..f1f8aed08 100644 --- a/infer/src/scuba/LogEntry.ml +++ b/infer/src/scuba/LogEntry.ml @@ -27,10 +27,9 @@ let mk_time ~label ~duration_ms = {label; created_at_ts; data} -(** What _global_ mean at this point is subject to discussion. Right now - there is only one use-case which is Scuba+Scribe logging at the end of - execution. But there might be more. Let's change the naming accordingly - when the purpose gets clearer. *) +(** What _global_ mean at this point is subject to discussion. Right now there is only one use-case + which is Scuba+Scribe logging at the end of execution. But there might be more. Let's change the + naming accordingly when the purpose gets clearer. *) let global_entry_log : t list ref = ref [] let global_log_get () = List.rev !global_entry_log diff --git a/infer/src/scuba/LogEntry.mli b/infer/src/scuba/LogEntry.mli index a33fc949a..e73197c15 100644 --- a/infer/src/scuba/LogEntry.mli +++ b/infer/src/scuba/LogEntry.mli @@ -7,10 +7,8 @@ open! IStd -(** - Log entry data model, global log entry store and functions to manipulate it. - Direct access to the store is not exposed. -*) +(** Log entry data model, global log entry store and functions to manipulate it. Direct access to + the store is not exposed. *) type count_entry_data = {value: int} diff --git a/infer/src/scuba/Scuba.mli b/infer/src/scuba/Scuba.mli index 4de568520..07acfda7b 100644 --- a/infer/src/scuba/Scuba.mli +++ b/infer/src/scuba/Scuba.mli @@ -9,13 +9,10 @@ open! IStd (* FB-ONLY *) -(** - Low-level Scuba logging functionality. - Provides functionality to log anything to any scuba table. - (Note that Scuba is a schema-free storage, so it won't require any changes). - Don't use this module directly for logging to tables with known structure. - Use high-level functions that are aware of the table structure. - *) +(** Low-level Scuba logging functionality. Provides functionality to log anything to any scuba + table. (Note that Scuba is a schema-free storage, so it won't require any changes). Don't use + this module directly for logging to tables with known structure. Use high-level functions that + are aware of the table structure. *) (** A scuba table *) type table = InferEvents @@ -24,22 +21,16 @@ type table = InferEvents type sample val new_sample : time:int option -> sample -(** Create an empty sample with given creation timestamp. If time is not specified, - corresponds to current timestamp. *) +(** Create an empty sample with given creation timestamp. If time is not specified, corresponds to + current timestamp. *) val add_int : name:string -> value:int -> sample -> sample -(** - Set a new integer field and its value to the sample. - Overwrites if a field with this name was already set. - *) +(** Set a new integer field and its value to the sample. Overwrites if a field with this name was + already set. *) val add_normal : name:string -> value:string -> sample -> sample -(** - Set a new string (normal in Scuba terminology) field and its value to the sample. - Overwrites if a field with this name was already set. - *) +(** Set a new string (normal in Scuba terminology) field and its value to the sample. Overwrites if + a field with this name was already set. *) val log : table -> sample list -> unit -(** - The main function. Log a collection of samples to the given table. - *) +(** The main function. Log a collection of samples to the given table. *) diff --git a/infer/src/scuba/ScubaLogging.ml b/infer/src/scuba/ScubaLogging.ml index 0b00a564b..949e0f659 100644 --- a/infer/src/scuba/ScubaLogging.ml +++ b/infer/src/scuba/ScubaLogging.ml @@ -54,8 +54,8 @@ let log_many entries = Scuba.log Scuba.InferEvents samples -(** If scuba logging is disabled, we would not log anyway, but let's not even try - to create samples to save perf *) +(** If scuba logging is disabled, we would not log anyway, but let's not even try to create samples + to save perf *) let log_many = if Config.scuba_logging then log_many else fun _ -> () let log_one entry = log_many [entry] diff --git a/infer/src/scuba/ScubaLogging.mli b/infer/src/scuba/ScubaLogging.mli index 826cd9fa3..6988838e9 100644 --- a/infer/src/scuba/ScubaLogging.mli +++ b/infer/src/scuba/ScubaLogging.mli @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. *) +[@@@ocamlformat "parse-docstrings = false"] + open! IStd (* FB-ONLY *) diff --git a/infer/src/topl/Topl.ml b/infer/src/topl/Topl.ml index 8f89d9157..a5102cf56 100644 --- a/infer/src/topl/Topl.ml +++ b/infer/src/topl/Topl.ml @@ -50,7 +50,7 @@ let get_max_args () = let get_transitions_count () = ToplAutomaton.tcount (Lazy.force automaton) (** Checks whether the method name and the number of arguments matches the conditions in a -transition label. Possible optimization: also evaluate if arguments equal certain constants. *) + transition label. Possible optimization: also evaluate if arguments equal certain constants. *) let evaluate_static_guard label (e_fun, arg_ts) = let match_name () = match e_fun with @@ -165,12 +165,12 @@ let instrument tenv procdesc = tt "add types %d@\n" !max_args ; add_types tenv ; tt "done@\n" ) -(** [lookup_static_var var prop] expects [var] to have the form [Exp.Lfield (obj, fieldname)], -and looks up inside the spatial part of [prop]. This function is currently used only to get -around some limitations: - (a) one cannot do boolean-conjunction on symbolic heaps; and - (b) the prover fails to see that 0!=o.f * o|-f->0 is inconsistent -*) +(** [lookup_static_var var prop] expects [var] to have the form [Exp.Lfield (obj, fieldname)], and + looks up inside the spatial part of [prop]. This function is currently used only to get around + some limitations: + + + one cannot do boolean-conjunction on symbolic heaps; and + + the prover fails to see that 0!=o.f * o|-f->0 is inconsistent *) let lookup_static_var env (var : Exp.t) (prop : 'a Prop.t) : Exp.t option = let from_strexp = function Sil.Eexp (e, _) -> Some e | _ -> None in let get_field field (f, e) = if Typ.Fieldname.equal field f then from_strexp e else None in @@ -210,21 +210,22 @@ let conjoin_props env post pre = List.fold ~init:post ~f:(Prop.prop_atom_and env) (Prop.get_pure pre) -(** -For each (pre, post) pair of symbolic heaps and each (start, error) pair of Topl automata states, -define - φ := pre & post & (state_pre==start) - ψ := φ & (state_post!=error) -where & stands for boolean conjunction, in pre all program variables get suffix "_pre", and in post -all program variables get suffix "_post". +(** For each (pre, post) pair of symbolic heaps and each (start, error) pair of Topl automata + states, define + + φ := pre & post & (state_pre==start) + + ψ := φ & (state_post!=error) + + where & stands for boolean conjunction, in pre all program variables get suffix "_pre", and in + post all program variables get suffix "_post". -Warn when φ is consistent and ψ is inconsistent. (TODO: experiment with asking if it is not forced -but *possible* to get to error.) + Warn when φ is consistent and ψ is inconsistent. (TODO: experiment with asking if it is not + forced but *possible* to get to error.) -To compute (pre & post) the function [conjoin_props] from above is used, which returns a weaker -formula: in particular, the spatial part of pre is dropped. To get around some limitations of the -prover we also use [lookup_static_var]; if a call to this function fails, we don't warn. -*) + To compute (pre & post) the function [conjoin_props] from above is used, which returns a weaker + formula: in particular, the spatial part of pre is dropped. To get around some limitations of + the prover we also use [lookup_static_var]; if a call to this function fails, we don't warn. *) let add_errors exe_env summary = let proc_desc = summary.Summary.proc_desc in let proc_name = Procdesc.get_proc_name proc_desc in diff --git a/infer/src/topl/Topl.mli b/infer/src/topl/Topl.mli index ac9c128e9..22cfbaecd 100644 --- a/infer/src/topl/Topl.mli +++ b/infer/src/topl/Topl.mli @@ -17,16 +17,16 @@ val get_proc_desc : Typ.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 -(** Inserts calls to the TOPL automaton. Mutates the arguments: it is the caller's responsibility -to instrument procedures at most once. *) +(** Inserts calls to the TOPL automaton. Mutates the arguments: it is the caller's responsibility to + instrument procedures at most once. *) val add_errors : Exe_env.t -> Summary.t -> unit (** Adds error using {!Reporting}. *) val sourcefile : unit -> SourceFile.t (** The (fake) sourcefile in which synthesized code resides. This function has a side-effect, -because that's how [SourceFile] works, so do NOT call when Topl is inactive. *) + because that's how [SourceFile] works, so do NOT call when Topl is inactive. *) val cfg : unit -> Cfg.t (** The CFG of the synthesized code. This function has a side-effect, because that's how [Cfg] -works, so do NOT call when Topl is inactive.*) + works, so do NOT call when Topl is inactive.*) diff --git a/infer/src/topl/ToplAutomaton.ml b/infer/src/topl/ToplAutomaton.ml index 5b81bc075..aa5efc3af 100644 --- a/infer/src/topl/ToplAutomaton.ml +++ b/infer/src/topl/ToplAutomaton.ml @@ -26,9 +26,9 @@ type tindex = int type transition = {source: vindex; target: vindex; label: ToplAst.label} -(** INV1: Array.length states = Array.length outgoing - INV2: each index of [transitions] occurs exactly once in one of [outgoing]'s lists - INV3: max_args is the maximum length of the arguments list in a label on a transition *) +(** - INV1: Array.length states = Array.length outgoing + - INV2: each index of [transitions] occurs exactly once in one of [outgoing]'s lists + - INV3: max_args is the maximum length of the arguments list in a label on a transition *) type t = { states: vname array ; transitions: transition array diff --git a/infer/src/topl/ToplAutomaton.mli b/infer/src/topl/ToplAutomaton.mli index 20fb76df4..b02b617a3 100644 --- a/infer/src/topl/ToplAutomaton.mli +++ b/infer/src/topl/ToplAutomaton.mli @@ -47,5 +47,5 @@ val max_args : t -> int val get_start_error_pairs : t -> (vindex * vindex) list (** Returns pairs [(i,j)] of vertex indices corresponding to pairs [((p, "start"), (p, "error"))] of -vertex names, where [p] ranges over property names. -POST: no vertex index occurs more than once in the result. *) + vertex names, where [p] ranges over property names. POST: no vertex index occurs more than once + in the result. *) diff --git a/infer/src/topl/ToplMonitor.ml b/infer/src/topl/ToplMonitor.ml index 3bf212df1..2159a4b56 100644 --- a/infer/src/topl/ToplMonitor.ml +++ b/infer/src/topl/ToplMonitor.ml @@ -48,10 +48,10 @@ type succ_setter = Procdesc.Node.t -> Procdesc.Node.t list -> unit type block = {start_node: Procdesc.Node.t; exit_node: Procdesc.Node.t} -(** [node_generator]s are the main concept used for organizing the code below. The main property -of node generators is that they compose, because of their return type. The two arguments -([node_creator] and [succ_setter]) are there mainly to ensure that there is a thin interface -with the underlying (heavily imperative) cfg data-structure from [Procdesc]. *) +(** [node_generator]s are the main concept used for organizing the code below. The main property of + node generators is that they compose, because of their return type. The two arguments + ([node_creator] and [succ_setter]) are there mainly to ensure that there is a thin interface + with the underlying (heavily imperative) cfg data-structure from [Procdesc]. *) type node_generator = node_creator -> succ_setter -> block let procedure proc_name (make_body : node_generator) : Procdesc.t = @@ -99,9 +99,9 @@ let sequence (gens : node_generator list) : node_generator = (** Substitutes a fresh logical variable for any subexpression that is not an operator, a logical -variable or a constant. Also returns assignments from subexpressions to the logical variables -that replaced them. The goal is to get a Sil.Prune condition in a shape friendly to symbolic -execution. *) + variable or a constant. Also returns assignments from subexpressions to the logical variables + that replaced them. The goal is to get a Sil.Prune condition in a shape friendly to symbolic + execution. *) let pure_exp e : Exp.t * Sil.instr list = let rec pluck = let open Exp in diff --git a/infer/src/topl/ToplMonitor.mli b/infer/src/topl/ToplMonitor.mli index 99664e9cd..2ccc6bc6e 100644 --- a/infer/src/topl/ToplMonitor.mli +++ b/infer/src/topl/ToplMonitor.mli @@ -8,13 +8,14 @@ open! IStd val generate : ToplAutomaton.t -> Typ.Procname.t -> Procdesc.t option -(** [generate automaton proc_name] returns a CFG, provided that [proc_name] is a recognized procedure name *) +(** [generate automaton proc_name] returns a CFG, provided that [proc_name] is a recognized + procedure name *) val sourcefile : unit -> SourceFile.t (** For debug. *) val cfg : unit -> Cfg.t (** For debug. This datastructure accumulates all the procedures that were synthesized by the -current process. If the implementation is correct, then different processes synthesize the same -procedures, given the same set of Topl properties. However, for debug, we print the datastructure -in a filename that contains the PID, which is why [sourcefile] is exposed. *) + current process. If the implementation is correct, then different processes synthesize the same + procedures, given the same set of Topl properties. However, for debug, we print the + datastructure in a filename that contains the PID, which is why [sourcefile] is exposed. *) diff --git a/infer/src/topl/ToplUtils.mli b/infer/src/topl/ToplUtils.mli index 258f17be6..bc5b752ee 100644 --- a/infer/src/topl/ToplUtils.mli +++ b/infer/src/topl/ToplUtils.mli @@ -24,8 +24,8 @@ val local_var : Typ.Procname.t -> string -> Exp.t val constant_int : int -> Exp.t val topl_call : Ident.t -> Typ.desc -> Location.t -> string -> (Exp.t * Typ.t) list -> Sil.instr -(** 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].*) +(** 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 diff --git a/infer/src/unit/analyzerTester.ml b/infer/src/unit/analyzerTester.ml index 163ef3843..cbc307191 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -20,8 +20,9 @@ module StructuredSil = struct | Cmd of Sil.instr | If of Exp.t * structured_instr list * structured_instr list | While of Exp.t * structured_instr list - (** try/catch/finally. note: there is no throw. the semantics are that every command in the try - block is assumed to be possibly-excepting, and the catch block captures all exceptions *) + (** try/catch/finally. note: there is no throw. the semantics are that every command in the + try block is assumed to be possibly-excepting, and the catch block captures all + exceptions *) | Try of structured_instr list * structured_instr list * structured_instr list | Invariant of assertion * label (** gets autotranslated into assertions about abstract state *) diff --git a/sledge/.ocamlformat b/sledge/.ocamlformat index 9d6fdf6d3..e6ef8fdec 100644 --- a/sledge/.ocamlformat +++ b/sledge/.ocamlformat @@ -1,4 +1,5 @@ profile = compact break-before-in = fit-or-vertical margin = 76 +parse-docstrings = true wrap-comments = true diff --git a/sledge/src/import/import.mli b/sledge/src/import/import.mli index adaff7758..40a1e6758 100644 --- a/sledge/src/import/import.mli +++ b/sledge/src/import/import.mli @@ -44,8 +44,8 @@ val trd3 : _ * _ * 'a -> 'a (** Function combinators *) val ( >> ) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c -(** Composition of functions: [(f >> g) x] is exactly equivalent to [g (f - (x))]. Left associative. *) +(** Composition of functions: [(f >> g) x] is exactly equivalent to + [g (f (x))]. Left associative. *) val ( << ) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c (** Reverse composition of functions: [(g << f) x] is exactly equivalent to @@ -56,8 +56,8 @@ val ( $ ) : ('a -> unit) -> ('a -> 'b) -> 'a -> 'b to [(f x) ; (g x)]. Left associative. *) val ( $> ) : 'a -> ('a -> unit) -> 'a -(** Reverse apply and ignore function: [x $> f] is exactly equivalent to [f - x ; x]. Left associative. *) +(** Reverse apply and ignore function: [x $> f] is exactly equivalent to + [f x ; x]. Left associative. *) val ( <$ ) : ('a -> unit) -> 'a -> 'a (** Apply and ignore function: [f <$ x] is exactly equivalent to [f x ; x]. diff --git a/sledge/src/llair/term.mli b/sledge/src/llair/term.mli index cbb678e65..c43c33165 100644 --- a/sledge/src/llair/term.mli +++ b/sledge/src/llair/term.mli @@ -18,9 +18,9 @@ type op1 = signed integer. That is, it two's-complement--decodes the low [n] bits of the infinite two's-complement encoding of [arg]. *) | Unsigned of {bits: int} - (** [Ap1 (Unsigned {bits= n}, arg)] is [arg] interpreted as an [n]-bit - unsigned integer. That is, it unsigned-binary--decodes the low [n] - bits of the infinite two's-complement encoding of [arg]. *) + (** [Ap1 (Unsigned {bits= n}, arg)] is [arg] interpreted as an + [n]-bit unsigned integer. That is, it unsigned-binary--decodes the + low [n] bits of the infinite two's-complement encoding of [arg]. *) | Convert of {src: Typ.t; dst: Typ.t} (** [Ap1 (Convert {src; dst}, arg)] is [arg] converted from type [src] to type [dst], possibly with loss of information. The [src] and diff --git a/sledge/src/ppx_trace/ppx_trace.ml b/sledge/src/ppx_trace/ppx_trace.ml index 0022d1b0c..1d7f24163 100644 --- a/sledge/src/ppx_trace/ppx_trace.ml +++ b/sledge/src/ppx_trace/ppx_trace.ml @@ -10,18 +10,24 @@ This ppx rewriter declares a [--debug] command line option, to be passed by the build system in debug but not optimized build modes. - It rewrites [[%Trace.info f]] to a call [Trace.info mod_name fun_name f] - where [mod_name] and [fun_name] are the enclosing module and function - names in the parsetree. This is only done in debug mode, if [--debug] is - not passed, then [[%Trace.info f]] is rewritten to [()]. + It rewrites [\[%Trace.info f\]] to a call + [\[Trace.info mod_name fun_name f\]] where [mod_name] and [fun_name] are + the enclosing module and function names in the parsetree. This is only + done in debug mode, if [--debug] is not passed, then [\[%Trace.info f\]] + is rewritten to [()]. - Similarly, [[%Trace.call]] is rewritten to a call to [Trace.call] or - [()], and [[%Trace.retn]] to a call to [Trace.retn] or [Fn.id]. + Similarly, [\[%Trace.call\]] is rewritten to a call to [Trace.call] or + [()], and [\[%Trace.retn\]] to a call to [Trace.retn] or [Fn.id]. For example, this enables writing - [%Trace.call fun {pf} -> pf "%a" pp_arg_type arg] ; func arg |> - [%Trace.retn fun {pf} -> pf "%a" pp_result_type] + {[ + [%Trace.call fun {pf} -> pf "%a" pp_arg_type arg] + ; + func arg + |> + [%Trace.retn fun {pf} -> pf "%a" pp_result_type] + ]} to trace calls to [f] in debug mode while completely compiling out the debug code in non-debug builds. @@ -29,7 +35,7 @@ This mechanism can also be used e.g. to dynamically check assertions only in debug mode. - Additionally, [[%debug]] is rewritten to the compile-time boolean + Additionally, [\[%debug\]] is rewritten to the compile-time boolean constant determined by whether or not [--debug] is passed. *) open Ppxlib diff --git a/sledge/src/symbheap/equality.mli b/sledge/src/symbheap/equality.mli index 6dcdf15eb..67e8eb551 100644 --- a/sledge/src/symbheap/equality.mli +++ b/sledge/src/symbheap/equality.mli @@ -46,8 +46,8 @@ val entails : t -> t -> bool (** Test if one relation entails another. *) val class_of : t -> Term.t -> Term.t list -(** Equivalence class of [e]: all the terms [f] in the relation such that [e - = f] is implied by the relation. *) +(** Equivalence class of [e]: all the terms [f] in the relation such that + [e = f] is implied by the relation. *) val normalize : t -> Term.t -> Term.t (** Normalize a term [e] to [e'] such that [e = e'] is implied by the diff --git a/sledge/src/symbheap/exec.ml b/sledge/src/symbheap/exec.ml index c3f9e529b..316cf6588 100644 --- a/sledge/src/symbheap/exec.ml +++ b/sledge/src/symbheap/exec.ml @@ -9,7 +9,7 @@ [@@@warning "+9"] -(** generic command: ∀xs. {foot ∧ sub} ms := - {post} *) +(** generic command: [∀xs. {foot ∧ sub} ms := - {post}] *) type spec = {xs: Var.Set.t; foot: Sh.t; sub: Var.Subst.t; ms: Var.Set.t; post: Sh.t}