From 250d9cb8b3d7b43780142145f55917a1ca78f668 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Mon, 1 May 2017 12:38:45 -0700 Subject: [PATCH] [infer] the function to pretty-print the call graph does not need to access the analysis summaries Summary: This function is always used in the frontend where summaries don't exist yet Reviewed By: akotulski Differential Revision: D4979132 fbshipit-source-id: 8d49c52 --- infer/src/IR/Cg.re | 27 +++++---------------------- infer/src/IR/Cg.rei | 2 +- infer/src/clang/cFrontend.ml | 2 +- infer/src/java/jMain.ml | 2 +- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/infer/src/IR/Cg.re b/infer/src/IR/Cg.re index c4b50437d..c12502c6f 100644 --- a/infer/src/IR/Cg.re +++ b/infer/src/IR/Cg.re @@ -372,18 +372,8 @@ let store_to_file (filename: DB.filename) (call_graph: t) => Serialization.write_to_file callgraph_serializer filename data::(call_graph.source, get_nodes_and_edges call_graph); -let pp_graph_dotty get_specs (g: t) fmt => { +let pp_graph_dotty (g: t) fmt => { let nodes_with_calls = get_all_nodes g; - let num_specs n => - try (List.length (get_specs n)) { - | exn when SymOp.exn_not_failure exn => (-1) - }; - let get_color (n, _) => - if (num_specs n != 0) { - "green" - } else { - "red" - }; let get_shape (n, _) => if (node_defined g n) { "box" @@ -392,14 +382,7 @@ let pp_graph_dotty get_specs (g: t) fmt => { }; let pp_node fmt (n, _) => F.fprintf fmt "\"%s\"" (Typ.Procname.to_filename n); let pp_node_label fmt (n, calls) => - F.fprintf - fmt - "\"%a | calls=%d %d | specs=%d)\"" - Typ.Procname.pp - n - calls.in_calls - calls.out_calls - (num_specs n); + F.fprintf fmt "\"%a | calls=%d %d)\"" Typ.Procname.pp n calls.in_calls calls.out_calls; F.fprintf fmt "digraph {@\n"; List.iter f::( @@ -411,7 +394,7 @@ let pp_graph_dotty get_specs (g: t) fmt => { nc pp_node_label nc - (get_color nc) + "red" (get_shape nc) ) nodes_with_calls; @@ -421,11 +404,11 @@ let pp_graph_dotty get_specs (g: t) fmt => { /** Print the call graph as a dotty file. */ -let save_call_graph_dotty source get_specs (g: t) => { +let save_call_graph_dotty source (g: t) => { let fname_dot = DB.Results_dir.path_to_filename (DB.Results_dir.Abs_source_dir source) ["call_graph.dot"]; let outc = open_out (DB.filename_to_string fname_dot); let fmt = F.formatter_of_out_channel outc; - pp_graph_dotty get_specs g fmt; + pp_graph_dotty g fmt; Out_channel.close outc }; diff --git a/infer/src/IR/Cg.rei b/infer/src/IR/Cg.rei index 3615d888a..4f55b3ec4 100644 --- a/infer/src/IR/Cg.rei +++ b/infer/src/IR/Cg.rei @@ -117,7 +117,7 @@ let remove_node_defined: t => Typ.Procname.t => unit; /** Print the call graph as a dotty file. */ -let save_call_graph_dotty: SourceFile.t => (Typ.Procname.t => list 'a) => t => unit; +let save_call_graph_dotty: SourceFile.t => t => unit; /** Save a call graph into a file */ diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 9267513a3..dcd73bbf2 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -66,7 +66,7 @@ let do_source_file translation_unit_context ast = || Config.frontend_tests || Option.is_some Config.icfg_dotty_outfile then (Dotty.print_icfg_dotty source_file cfg; - Cg.save_call_graph_dotty source_file Specs.get_specs call_graph); + Cg.save_call_graph_dotty source_file call_graph); Logging.out_debug "%a" Cfg.pp_proc_signatures cfg; (* NOTE: nothing should be written to source_dir after this *) DB.mark_file_updated (DB.source_dir_to_string source_dir) diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index 24cbf6bdb..b344694a5 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -43,7 +43,7 @@ let store_icfg source_file tenv cg cfg = if Config.debug_mode || Config.frontend_tests then begin Dotty.print_icfg_dotty source_file cfg; - Cg.save_call_graph_dotty source_file Specs.get_specs cg + Cg.save_call_graph_dotty source_file cg end; (* NOTE: nothing should be written to source_dir after this *) DB.mark_file_updated (DB.source_dir_to_string source_dir)