diff --git a/infer/src/backend/cfg.ml b/infer/src/backend/cfg.ml index aa4851634..c759c4030 100644 --- a/infer/src/backend/cfg.ml +++ b/infer/src/backend/cfg.ml @@ -498,19 +498,6 @@ module Node = struct proc_desc.pd_attributes.ProcAttributes.locals <- proc_desc.pd_attributes.ProcAttributes.locals @ new_locals - (** Get the cyclomatic complexity for the procedure *) - let proc_desc_get_cyclomatic proc_desc = - let num_edges = ref 0 in - let num_nodes = ref 0 in - let num_connected = 1 in (* always one connected component in a procedure's cfg *) - let nodes = proc_desc_get_nodes proc_desc in - let do_node node = - incr num_nodes; - num_edges := !num_edges + IList.length (get_succs node) in - IList.iter do_node nodes; - let cyclo = !num_edges - !num_nodes + 2 * num_connected in (* formula for cyclomatic complexity *) - cyclo - (** Print extended instructions for the node, highlighting the given subinstruction if present *) let pp_instr pe0 ~sub_instrs instro fmt node = let pe = match instro with @@ -638,7 +625,6 @@ module Procdesc = struct let remove = Node.proc_desc_remove let find_from_name = Node.proc_desc_from_name let get_attributes = Node.proc_desc_get_attributes - let get_cyclomatic = Node.proc_desc_get_cyclomatic let get_err_log = Node.proc_desc_get_err_log let get_exit_node = Node.proc_desc_get_exit_node let get_flags = Node.proc_desc_get_flags diff --git a/infer/src/backend/cfg.mli b/infer/src/backend/cfg.mli index 7c9e23217..31e63a624 100644 --- a/infer/src/backend/cfg.mli +++ b/infer/src/backend/cfg.mli @@ -44,9 +44,6 @@ module Procdesc : sig (** Get the attributes of the procedure. *) val get_attributes : t -> ProcAttributes.t - (** Get the cyclomatic complexity for the procedure *) - val get_cyclomatic : t -> int - val get_err_log : t -> Errlog.t val get_exit_node : t -> node diff --git a/infer/src/backend/inferprint.ml b/infer/src/backend/inferprint.ml index 06768a344..6b48f9fb0 100644 --- a/infer/src/backend/inferprint.ml +++ b/infer/src/backend/inferprint.ml @@ -348,7 +348,7 @@ type summary_val = vin_calls : int; vout_calls : int; vproof_trace : string; - vcyclomatic : int } + } (** compute values from summary data to export to csv and xml format *) let summary_values top_proc_set summary = @@ -389,7 +389,6 @@ let summary_values top_proc_set summary = pp_to_string pp_failure_kind failure in - let cyclomatic = stats.Specs.cyclomatic in { vname = Procname.to_string proc_name; vname_id = Procname.to_filename proc_name; vspecs = IList.length specs; @@ -411,13 +410,32 @@ let summary_values top_proc_set summary = vin_calls = in_calls; vout_calls = out_calls; vproof_trace = proof_trace; - vcyclomatic = cyclomatic } + } module ProcsCsv = struct (** Print the header of the procedures csv file, with column names *) let pp_header fmt () = - Format.fprintf fmt "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s@\n" Io_infer.Xml.tag_name Io_infer.Xml.tag_name_id Io_infer.Xml.tag_specs Io_infer.Xml.tag_time Io_infer.Xml.tag_to Io_infer.Xml.tag_symop Io_infer.Xml.tag_err Io_infer.Xml.tag_file Io_infer.Xml.tag_line Io_infer.Xml.tag_loc Io_infer.Xml.tag_top Io_infer.Xml.tag_signature Io_infer.Xml.tag_weight Io_infer.Xml.tag_proof_coverage Io_infer.Xml.tag_rank Io_infer.Xml.tag_in_calls Io_infer.Xml.tag_out_calls Io_infer.Xml.tag_proof_trace Io_infer.Xml.tag_cyclomatic + Format.fprintf fmt + "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s@\n" + Io_infer.Xml.tag_name + Io_infer.Xml.tag_name_id + Io_infer.Xml.tag_specs + Io_infer.Xml.tag_time + Io_infer.Xml.tag_to + Io_infer.Xml.tag_symop + Io_infer.Xml.tag_err + Io_infer.Xml.tag_file + Io_infer.Xml.tag_line + Io_infer.Xml.tag_loc + Io_infer.Xml.tag_top + Io_infer.Xml.tag_signature + Io_infer.Xml.tag_weight + Io_infer.Xml.tag_proof_coverage + Io_infer.Xml.tag_rank + Io_infer.Xml.tag_in_calls + Io_infer.Xml.tag_out_calls + Io_infer.Xml.tag_proof_trace (** Write proc summary stats in csv format *) let pp_summary fname top_proc_set fmt summary = @@ -441,7 +459,6 @@ module ProcsCsv = struct pp "%d," sv.vin_calls; pp "%d," sv.vout_calls; pp "%s," sv.vproof_trace; - pp "%d@\n" sv.vcyclomatic end module ProcsXml = struct @@ -475,7 +492,6 @@ module ProcsXml = struct subtree Io_infer.Xml.tag_in_calls (string_of_int sv.vin_calls); subtree Io_infer.Xml.tag_out_calls (string_of_int sv.vin_calls); subtree Io_infer.Xml.tag_proof_trace sv.vproof_trace; - subtree Io_infer.Xml.tag_cyclomatic (string_of_int sv.vcyclomatic); subtree Io_infer.Xml.tag_flags (string_of_int (Hashtbl.length sv.vflags)); ] in Io_infer.Xml.create_tree "procedure" attributes forest in @@ -701,7 +717,14 @@ end module CallsCsv = struct (** Print the header of the calls csv file, with column names *) let pp_header fmt () = - Format.fprintf fmt "%s,%s,%s,%s,%s,%s,%s@\n" Io_infer.Xml.tag_caller Io_infer.Xml.tag_caller_id Io_infer.Xml.tag_callee Io_infer.Xml.tag_callee_id Io_infer.Xml.tag_file Io_infer.Xml.tag_line Io_infer.Xml.tag_call_trace + Format.fprintf fmt "%s,%s,%s,%s,%s,%s,%s@\n" + Io_infer.Xml.tag_caller + Io_infer.Xml.tag_caller_id + Io_infer.Xml.tag_callee + Io_infer.Xml.tag_callee_id + Io_infer.Xml.tag_file + Io_infer.Xml.tag_line + Io_infer.Xml.tag_call_trace (** Write proc summary stats in csv format *) let pp_calls fname fmt summary = diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index ca1e70b47..9bd2dc594 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1254,7 +1254,6 @@ let do_analysis exe_env = let proc_flags = Cfg.Procdesc.get_flags pdesc in let static_err_log = Cfg.Procdesc.get_err_log pdesc in (** err log from translation *) let calls = get_calls pdesc in - let cyclomatic = Cfg.Procdesc.get_cyclomatic pdesc in let attributes = { (Cfg.Procdesc.get_attributes pdesc) with ProcAttributes.err_log = static_err_log; } in @@ -1262,7 +1261,7 @@ let do_analysis exe_env = Callbacks.proc_inline_synthetic_methods cfg pdesc; Specs.init_summary (dep, nodes, proc_flags, - calls, cyclomatic, None, attributes) in + calls, None, attributes) in let filter = if !Config.only_skips then (filter_skipped_procs cg procs_and_defined_children) else if !Config.only_nospecs then filter_nospecs diff --git a/infer/src/backend/io_infer.ml b/infer/src/backend/io_infer.ml index 747b80907..79b12058a 100644 --- a/infer/src/backend/io_infer.ml +++ b/infer/src/backend/io_infer.ml @@ -195,7 +195,6 @@ module Xml = struct let tag_callee_id = "callee_id" let tag_caller = "caller" let tag_caller_id = "caller_id" - let tag_cyclomatic = "cyclomatic" let tag_class = "class" let tag_code = "code" let tag_description = "description" diff --git a/infer/src/backend/io_infer.mli b/infer/src/backend/io_infer.mli index 1e9a38588..c672ee757 100644 --- a/infer/src/backend/io_infer.mli +++ b/infer/src/backend/io_infer.mli @@ -39,7 +39,6 @@ module Xml : sig val tag_callee_id : string val tag_caller : string val tag_caller_id : string - val tag_cyclomatic : string val tag_class : string val tag_code : string val tag_description : string diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index 6318e8541..b740286ff 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -294,7 +294,6 @@ type stats = mutable nodes_visited_fp : IntSet.t; (** Nodes visited during the footprint phase *) mutable nodes_visited_re : IntSet.t; (** Nodes visited during the re-execution phase *) call_stats : call_stats; - cyclomatic : int; } type status = ACTIVE | INACTIVE | STALE @@ -465,7 +464,7 @@ let pp_summary pe whole_seconds fmt summary = let pp_spec_table pe whole_seconds fmt () = Procname.Hash.iter (fun proc_name (summ, orig) -> F.fprintf fmt "PROC %a@\n%a@\n" Procname.pp proc_name (pp_summary pe whole_seconds) summ) spec_tbl -let empty_stats calls cyclomatic in_out_calls_opt = +let empty_stats calls in_out_calls_opt = { stats_time = 0.0; stats_failure = None; stats_calls = @@ -476,7 +475,6 @@ let empty_stats calls cyclomatic in_out_calls_opt = nodes_visited_fp = IntSet.empty; nodes_visited_re = IntSet.empty; call_stats = CallStats.init calls; - cyclomatic = cyclomatic; } let rec post_equal pl1 pl2 = match pl1, pl2 with @@ -799,11 +797,11 @@ let empty_payload = } (** [init_summary (depend_list, nodes, - proc_flags, calls, cyclomatic, in_out_calls_opt, proc_attributes)] + proc_flags, calls, in_out_calls_opt, proc_attributes)] initializes the summary for [proc_name] given dependent procs in list [depend_list]. *) let init_summary (depend_list, nodes, - proc_flags, calls, cyclomatic, in_out_calls_opt, + proc_flags, calls, in_out_calls_opt, proc_attributes) = let dependency_map = mk_initial_dependency_map depend_list in let summary = @@ -813,7 +811,7 @@ let init_summary phase = FOOTPRINT; sessions = ref 0; payload = empty_payload; - stats = empty_stats calls cyclomatic in_out_calls_opt; + stats = empty_stats calls in_out_calls_opt; status = INACTIVE; timestamp = 0; attributes = @@ -835,7 +833,6 @@ let reset_summary call_graph proc_name attributes_opt = [], proc_flags_empty (), [], - 0, Some (Cg.get_calls call_graph proc_name), proc_attributes ) diff --git a/infer/src/backend/specs.mli b/infer/src/backend/specs.mli index a9f68dfc5..510313f56 100644 --- a/infer/src/backend/specs.mli +++ b/infer/src/backend/specs.mli @@ -108,7 +108,6 @@ type stats = mutable nodes_visited_fp : IntSet.t; (** Nodes visited during the footprint phase *) mutable nodes_visited_re : IntSet.t; (** Nodes visited during the re-execution phase *) call_stats : CallStats.t; - cyclomatic : int; } type status = ACTIVE | INACTIVE | STALE @@ -220,7 +219,6 @@ val init_summary : int list * (** nodes *) proc_flags * (** procedure flags *) (Procname.t * Location.t) list * (** calls *) - int * (** cyclomatic *) (Cg.in_out_calls option) * (** in and out calls *) ProcAttributes.t) (** attributes of the procedure *) -> unit