diff --git a/check/threshold-3-0.5/threshold-3-0.5.exp b/check/threshold-3-0.5/threshold-3-0.5.exp index 25f517a..caf0925 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.exp +++ b/check/threshold-3-0.5/threshold-3-0.5.exp @@ -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) @@ -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) diff --git a/check/threshold-3-0.5/threshold-3-0.5.ref b/check/threshold-3-0.5/threshold-3-0.5.ref index c6683b2..68b1204 100644 --- a/check/threshold-3-0.5/threshold-3-0.5.ref +++ b/check/threshold-3-0.5/threshold-3-0.5.ref @@ -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) @@ -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) @@ -1086,7 +1088,7 @@ Nothing else to report in this section -------------------------------------------------------------------------------- -Total: 920 -Success: 920 +Total: 923 +Success: 923 Failed: 0 Ratio: 100.% diff --git a/src/deadCode.ml b/src/deadCode.ml index 616fdb0..8a87659 100644 --- a/src/deadCode.ml +++ b/src/deadCode.ml @@ -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 @@ -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 =