diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 6a64e3590..edb862819 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -297,13 +297,13 @@ let iter_instrs f pdesc = iter_nodes do_node pdesc -let fold_nodes f acc pdesc = List.fold ~f ~init:acc (List.rev (get_nodes pdesc)) +let fold_nodes pdesc ~init ~f = List.fold ~f ~init (List.rev (get_nodes pdesc)) -let fold_instrs f acc pdesc = +let fold_instrs pdesc ~init ~f = let fold_node acc node = List.fold ~f:(fun acc instr -> f acc node instr) ~init:acc (Node.get_instrs node) in - fold_nodes fold_node acc pdesc + fold_nodes ~f:fold_node ~init pdesc (** iterate between two nodes or until we reach a branching structure *) diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index 022abb88c..6352bb510 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -136,10 +136,10 @@ val create_node : t -> Location.t -> Node.nodekind -> Sil.instr list -> Node.t val did_preanalysis : t -> bool (** true if we ran the preanalysis on the CFG associated with [t] *) -val fold_instrs : ('a -> Node.t -> Sil.instr -> 'a) -> 'a -> t -> 'a +val fold_instrs : t -> init:'accum -> f:('accum -> Node.t -> Sil.instr -> 'accum) -> 'accum (** fold over all nodes and their instructions *) -val fold_nodes : ('a -> Node.t -> 'a) -> 'a -> t -> 'a +val fold_nodes : t -> init:'accum -> f:('accum -> Node.t -> 'accum) -> 'accum (** fold over all nodes *) val from_proc_attributes : ProcAttributes.t -> t diff --git a/infer/src/absint/PatternMatch.ml b/infer/src/absint/PatternMatch.ml index 5cbf7adda..402f7ae01 100644 --- a/infer/src/absint/PatternMatch.ml +++ b/infer/src/absint/PatternMatch.ml @@ -326,7 +326,8 @@ let get_fields_nullified procdesc = (nullified_flds, this_ids) in let nullified_flds, _ = - Procdesc.fold_instrs collect_nullified_flds (Typ.Fieldname.Set.empty, Ident.Set.empty) procdesc + Procdesc.fold_instrs procdesc ~f:collect_nullified_flds + ~init:(Typ.Fieldname.Set.empty, Ident.Set.empty) in nullified_flds diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index aaaa35412..09e2d099f 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -487,7 +487,7 @@ module Report = struct let collect : Specs.summary -> extras ProcData.t -> Analyzer.invariant_map -> PO.ConditionSet.t = fun summary ({pdesc} as pdata) inv_map -> let add_node1 acc node = collect_node summary pdata inv_map acc node in - Procdesc.fold_nodes add_node1 PO.ConditionSet.empty pdesc + Procdesc.fold_nodes pdesc ~f:add_node1 ~init:PO.ConditionSet.empty let make_err_trace : Trace.t -> string -> Errlog.loc_trace = diff --git a/infer/src/checkers/BoundedCallTree.ml b/infer/src/checkers/BoundedCallTree.ml index 70748fa57..74d8df659 100644 --- a/infer/src/checkers/BoundedCallTree.ml +++ b/infer/src/checkers/BoundedCallTree.ml @@ -36,11 +36,9 @@ let line_range_of_pdesc pdesc = let ploc = Procdesc.get_loc pdesc in let start_line = ploc.Location.line in let end_line = - Procdesc.fold_instrs - (fun acc _ instr -> + Procdesc.fold_instrs pdesc ~init:start_line ~f:(fun acc _ instr -> let new_loc = Sil.instr_get_loc instr in max acc new_loc.Location.line ) - start_line pdesc in {Stacktree_j.start_line; end_line}