Node.pname_opt doesn't have to be an option

Summary:
Now that we got rid of dummy nodes used non-dummily (biabduction state, reporting), `pname` don't need to be an option anymore.
Let's save a boxing on all nodes.

Reviewed By: jeremydubreil

Differential Revision: D9654152

fbshipit-source-id: 83b00f239
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 3b96912f64
commit 56612796e6

@ -93,7 +93,7 @@ module Node = struct
; kind: nodekind (** kind of node *)
; loc: Location.t (** location in the source code *)
; mutable preds: t list (** predecessor nodes in the cfg *)
; pname_opt: Typ.Procname.t option (** name of the procedure the node belongs to *)
; pname: Typ.Procname.t (** name of the procedure the node belongs to *)
; mutable succs: t list (** successor nodes in the cfg *) }
let exn_handler_kind = Stmt_node ExceptionHandler
@ -102,13 +102,13 @@ module Node = struct
let throw_kind = Stmt_node Throw
let dummy pname_opt =
let dummy pname =
{ id= 0
; dist_exit= None
; instrs= Instrs.empty
; kind= Skip_node "dummy"
; loc= Location.dummy
; pname_opt
; pname
; succs= []
; preds= []
; exn= [] }
@ -142,14 +142,7 @@ module Node = struct
let get_exn node = node.exn
(** Get the name of the procedure the node belongs to *)
let get_proc_name node =
match node.pname_opt with
| None ->
L.internal_error "get_proc_name: at node %d@\n" node.id ;
assert false
| Some pname ->
pname
let get_proc_name node = node.pname
(** Get the predecessors of the node *)
let get_preds node = node.preds
@ -408,9 +401,9 @@ type t =
; mutable loop_heads: NodeSet.t option (** loop head nodes of this procedure *) }
let from_proc_attributes attributes =
let pname_opt = Some attributes.ProcAttributes.proc_name in
let start_node = Node.dummy pname_opt in
let exit_node = Node.dummy pname_opt in
let pname = attributes.ProcAttributes.proc_name in
let start_node = Node.dummy pname in
let exit_node = Node.dummy pname in
{attributes; nodes= []; nodes_num= 0; start_node; exit_node; loop_heads= None}
@ -549,7 +542,7 @@ let create_node_internal pdesc loc kind instrs =
; kind
; loc
; preds= []
; pname_opt= Some pdesc.attributes.proc_name
; pname= pdesc.attributes.proc_name
; succs= []
; exn= [] }
in

@ -94,7 +94,7 @@ module Node : sig
val d_instrs : sub_instrs:bool -> Sil.instr option -> t -> unit
(** Dump extended instructions for the node *)
val dummy : Typ.Procname.t option -> t
val dummy : Typ.Procname.t -> t
(** Create a dummy node *)
val equal : t -> t -> bool

@ -65,7 +65,7 @@ module NullifyTransferFunctions = struct
astate
let cache_node = ref (Procdesc.Node.dummy None)
let cache_node = ref (Procdesc.Node.dummy Typ.Procname.Linters_dummy_method)
let cache_instr = ref Sil.skip_instr

@ -371,20 +371,19 @@ end = struct
()
in
iter_shortest_sequence (fun _ p _ _ -> add_node (curr_node p)) None path ;
let max_rep_node = ref (Procdesc.Node.dummy None) in
let max_rep_num = ref 0 in
Procdesc.NodeMap.iter
(fun node num ->
if num > !max_rep_num then (
max_rep_node := node ;
max_rep_num := num ) )
!map ;
(!max_rep_node, !max_rep_num)
let max_rep_opt =
Procdesc.NodeMap.fold
(fun node num max_rep_opt ->
if num > Option.value_map max_rep_opt ~default:0 ~f:fst then Some (num, node)
else max_rep_opt )
!map None
in
Option.value_exn max_rep_opt
let stats_string path =
Invariant.compute_stats true (fun _ -> true) path ;
let node, repetitions = repetitions path in
let repetitions, node = repetitions path in
let str =
"linear paths: "
^ string_of_float (Invariant.get_stats path).linear_num

Loading…
Cancel
Save