[easy] Labels for Procdesc.fold_nodes/instrs

Reviewed By: dulmarod

Differential Revision: D7288933

fbshipit-source-id: 1815273
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 4952f1ea3b
commit 1db6e0c2c6

@ -297,13 +297,13 @@ let iter_instrs f pdesc =
iter_nodes do_node 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 = let fold_node acc node =
List.fold ~f:(fun acc instr -> f acc node instr) ~init:acc (Node.get_instrs node) List.fold ~f:(fun acc instr -> f acc node instr) ~init:acc (Node.get_instrs node)
in 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 *) (** iterate between two nodes or until we reach a branching structure *)

@ -136,10 +136,10 @@ val create_node : t -> Location.t -> Node.nodekind -> Sil.instr list -> Node.t
val did_preanalysis : t -> bool val did_preanalysis : t -> bool
(** true if we ran the preanalysis on the CFG associated with [t] *) (** 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 *) (** 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 *) (** fold over all nodes *)
val from_proc_attributes : ProcAttributes.t -> t val from_proc_attributes : ProcAttributes.t -> t

@ -326,7 +326,8 @@ let get_fields_nullified procdesc =
(nullified_flds, this_ids) (nullified_flds, this_ids)
in in
let nullified_flds, _ = 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 in
nullified_flds nullified_flds

@ -487,7 +487,7 @@ module Report = struct
let collect : Specs.summary -> extras ProcData.t -> Analyzer.invariant_map -> PO.ConditionSet.t = let collect : Specs.summary -> extras ProcData.t -> Analyzer.invariant_map -> PO.ConditionSet.t =
fun summary ({pdesc} as pdata) inv_map -> fun summary ({pdesc} as pdata) inv_map ->
let add_node1 acc node = collect_node summary pdata inv_map acc node in 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 = let make_err_trace : Trace.t -> string -> Errlog.loc_trace =

@ -36,11 +36,9 @@ let line_range_of_pdesc pdesc =
let ploc = Procdesc.get_loc pdesc in let ploc = Procdesc.get_loc pdesc in
let start_line = ploc.Location.line in let start_line = ploc.Location.line in
let end_line = let end_line =
Procdesc.fold_instrs Procdesc.fold_instrs pdesc ~init:start_line ~f:(fun acc _ instr ->
(fun acc _ instr ->
let new_loc = Sil.instr_get_loc instr in let new_loc = Sil.instr_get_loc instr in
max acc new_loc.Location.line ) max acc new_loc.Location.line )
start_line pdesc
in in
{Stacktree_j.start_line; end_line} {Stacktree_j.start_line; end_line}

Loading…
Cancel
Save