Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions check/threshold-3-0.5/threshold-3-0.5.exp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn2.mli:2: ?a (2/3 calls)
./examples/using_make/dir/anonFn2.mli:2: ?b (2/3 calls)
./examples/using_make/dir/match_opt.ml:1: ?b (2/3 calls)
./examples/using_make/dir/matchopt.ml:1: ?x (3/4 calls)
./examples/using_make/dir/ref_fn.ml:1: ?a (2/3 calls)
./examples/using_make/dir/ref_fn.ml:1: ?b (2/3 calls)

Expand Down Expand Up @@ -1035,6 +1036,8 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn.mli:3: ?a (1/2 calls)
./examples/using_make/dir/anonFn.mli:3: ?b (1/2 calls)
./examples/using_make/dir/anonFn2.mli:1: ?b (2/3 calls)
./examples/using_make/dir/matchopt.ml:1: ?y (3/4 calls)
./examples/using_make/dir/matchopt.ml:1: ?z (3/4 calls)

./examples/using_make/let_in.ml:1: ?b (2/3 calls)
./examples/using_make/matchopt.ml:1: ?y (3/4 calls)
Expand Down
8 changes: 5 additions & 3 deletions check/threshold-3-0.5/threshold-3-0.5.ref
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn2.mli:2: ?a (2/3 calls)
./examples/using_make/dir/anonFn2.mli:2: ?b (2/3 calls)
./examples/using_make/dir/match_opt.ml:1: ?b (2/3 calls)
./examples/using_make/dir/matchopt.ml:1: ?x (3/4 calls)
./examples/using_make/dir/ref_fn.ml:1: ?a (2/3 calls)
./examples/using_make/dir/ref_fn.ml:1: ?b (2/3 calls)

Expand Down Expand Up @@ -1035,7 +1036,8 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn.mli:3: ?a (1/2 calls)
./examples/using_make/dir/anonFn.mli:3: ?b (1/2 calls)
./examples/using_make/dir/anonFn2.mli:1: ?b (2/3 calls)

./examples/using_make/dir/matchopt.ml:1: ?y (3/4 calls)
./examples/using_make/dir/matchopt.ml:1: ?z (3/4 calls)
./examples/using_make/let_in.ml:1: ?b (2/3 calls)
./examples/using_make/matchopt.ml:1: ?y (3/4 calls)
./examples/using_make/matchopt.ml:1: ?z (3/4 calls)
Expand Down Expand Up @@ -1086,7 +1088,7 @@ Nothing else to report in this section
--------------------------------------------------------------------------------


Total: 920
Success: 920
Total: 923
Success: 923
Failed: 0
Ratio: 100.%
14 changes: 8 additions & 6 deletions src/deadCode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -501,21 +501,21 @@ let rec load_file state fn =
(* Prepare the list of opt_args for report *)
let analyze_opt_args () =
DeadArg.eocb ();
let all = ref [] in
let tbl = Hashtbl.create 256 in
let dec_loc loc = Hashtbl.mem main_files (Utils.unit loc.Lexing.pos_fname) in
let all = ref [] in
let opt_args_tbl = Hashtbl.create 256 in

let analyze = fun opt_arg_use ->
let builddir = opt_arg_use.builddir in
let loc = opt_arg_use.decl_loc in
let lab = opt_arg_use.label in
let slot =
try Hashtbl.find tbl (loc, lab)
try Hashtbl.find opt_args_tbl (builddir, loc, lab)
with Not_found ->
let r = {with_val = []; without_val = []} in
if dec_loc loc then begin
all := (builddir, loc, lab, r) :: !all;
Hashtbl.add tbl (loc, lab) r
Hashtbl.add opt_args_tbl (builddir, loc, lab) r
end;
r
in
Expand Down Expand Up @@ -554,8 +554,10 @@ let report_opt_args s l =
let ratio = float_of_int (List.length l) /. float_of_int total
in (builddir, loc, lab, l, ratio, total))
l
|> List.fast_sort (fun (_, loc1, lab1, slot1, _, _) (_, loc2, lab2, slot2, _, _) ->
compare (DeadCommon.abs loc1, loc1, lab1, slot1) (DeadCommon.abs loc2, loc2, lab2, slot2))
|> List.fast_sort (fun (builddir1, loc1, lab1, slot1, _, _) (builddir2, loc2, lab2, slot2, _, _) ->
let fn1 = Filename.concat builddir1 loc1.Lexing.pos_fname in
let fn2 = Filename.concat builddir2 loc2.Lexing.pos_fname in
compare (fn1, loc1, lab1, slot1) (fn2, loc2, lab2, slot2))
in

let change =
Expand Down