120
120
(* ---------------------------------------------------------------------- *)
121
121
(* file can be "foo.c" or "foo.c:main" *)
122
(* local function that is parameterized by whether to launch gv *)
123
let local_test_cfg launchgv file =
123
124
let (file, specific_func) =
124
125
if file =~ "\\(.*\\.c\\):\\(.*\\)"
137
138
program +> List.iter (fun (e,_) ->
139
140
match specific_func, e with
141
| None, Ast_c.Definition (defbis,_) ->
142
Some (Ast_c.str_of_name (defbis.Ast_c.f_name))
141
143
| Some s, Ast_c.Definition (defbis,_) ->
142
s =$= Ast_c.str_of_name (defbis.Ast_c.f_name)
144
let nm = Ast_c.str_of_name (defbis.Ast_c.f_name) in
145
if s =$= nm then Some nm else None
148
(* old: Flow_to_ast.test !Flag.show_flow def *)
151
| Some fn -> (* old: Flow_to_ast.test !Flag.show_flow def *)
150
153
let flow = Ast_to_flow.ast_to_control_flow e in
151
154
flow +> do_option (fun flow ->
152
155
Ast_to_flow.deadcode_detection flow;
163
let filename = Filename.temp_file "output" ".dot" in
164
Ograph_extended.print_ograph_mutable flow' (filename) true
168
then Filename.temp_file "output" ".dot"
170
let fl = Filename.chop_extension (Filename.basename file) in
172
Ograph_extended.print_ograph_mutable flow' (filename) launchgv
166
174
with Ast_to_flow.Error (x) -> Ast_to_flow.report_error x
177
let test_cfg = local_test_cfg true
488
498
Common.mk_action_n_arg test_parse;
490
500
"-show_flow", " <file or file:function>",
491
Common.mk_action_1_arg test_cfg;
501
Common.mk_action_1_arg (local_test_cfg true);
492
502
"-control_flow", " <file or file:function>",
493
Common.mk_action_1_arg test_cfg;
503
Common.mk_action_1_arg (local_test_cfg true);
504
"-control_flow_to_file", " <file or file:function>",
505
Common.mk_action_1_arg (local_test_cfg false);
494
506
"-test_cfg_ifdef", " <file>",
495
507
Common.mk_action_1_arg test_cfg_ifdef;
496
508
"-parse_unparse", " <file>",
497
509
Common.mk_action_1_arg test_parse_unparse;
498
"-parse_and_print_sexp", " <file>",
499
Common.mk_action_1_arg parse_and_print_sexp;
510
(* "-parse_and_print_sexp", " <file>",
511
Common.mk_action_1_arg parse_and_print_sexp;*)
500
512
"-type_c", " <file>",
501
513
Common.mk_action_1_arg test_type_c;
502
514
"-compare_c", " <file1> <file2>",