From c9107d65eaaa0cb4d8bbd4acf2fc73cafe70149d Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Mon, 1 Feb 2021 22:54:17 +0100
Subject: [PATCH] [Callgraph] use Filepath parameters for relevant options

---
 src/plugins/callgraph/Callgraph.mli | 2 +-
 src/plugins/callgraph/options.ml    | 9 ++++++---
 src/plugins/callgraph/options.mli   | 2 +-
 src/plugins/callgraph/register.ml   | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/plugins/callgraph/Callgraph.mli b/src/plugins/callgraph/Callgraph.mli
index 0d649136073..e7ba902325e 100644
--- a/src/plugins/callgraph/Callgraph.mli
+++ b/src/plugins/callgraph/Callgraph.mli
@@ -23,7 +23,7 @@
 (** Callgraph plugin. *)
 
 module Options: sig
-  module Filename: Parameter_sig.String
+  module Filename: Parameter_sig.Filepath
   module Service_roots: Parameter_sig.Kernel_function_set
   module Uncalled: Parameter_sig.Bool
   module Uncalled_leaf: Parameter_sig.Bool
diff --git a/src/plugins/callgraph/options.ml b/src/plugins/callgraph/options.ml
index d42856664a9..04158a6a507 100644
--- a/src/plugins/callgraph/options.ml
+++ b/src/plugins/callgraph/options.ml
@@ -32,10 +32,12 @@ include
     end)
 
 module Filename =
-  Empty_string
+  Filepath
     (struct
       let option_name = "-cg"
       let arg_name = "filename"
+      let file_kind = "DOT"
+      let existence = Fc_Filepath.Indifferent
       let help = "dump the callgraph to the file \
                   <filename> in dot format"
     end)
@@ -97,9 +99,10 @@ module Uncalled_leaf =
 
 let dump output g =
   let file = Filename.get () in
-  feedback ~level:2 "dumping the graph into file %s" file;
+  feedback ~level:2 "dumping the graph into file %a"
+    Fc_Filepath.Normalized.pretty file;
   try
-    let cout = open_out file in
+    let cout = open_out (file:>string) in
     output cout g;
     close_out cout
   with e ->
diff --git a/src/plugins/callgraph/options.mli b/src/plugins/callgraph/options.mli
index aa6fd2e5026..ab238a90b57 100644
--- a/src/plugins/callgraph/options.mli
+++ b/src/plugins/callgraph/options.mli
@@ -23,7 +23,7 @@
 include Plugin.S
 
 val name: string
-module Filename: Parameter_sig.String
+module Filename: Parameter_sig.Filepath
 module Roots: Parameter_sig.Kernel_function_set
 module Service_roots: Parameter_sig.Kernel_function_set
 module Function_pointers: Parameter_sig.Bool
diff --git a/src/plugins/callgraph/register.ml b/src/plugins/callgraph/register.ml
index d7da576b50f..f7dba518b73 100644
--- a/src/plugins/callgraph/register.ml
+++ b/src/plugins/callgraph/register.ml
@@ -21,7 +21,7 @@
 (**************************************************************************)
 
 let main () =
-  if Options.Filename.get () <> "" then
+  if not (Filepath.Normalized.is_unknown (Options.Filename.get ())) then
     if Options.Services.get () then begin
       if not (Services.is_computed ()) then Services.dump ()
     end else
-- 
GitLab