Skip to content

Commit f1893ff

Browse files
committed
[src][input][3/n] store uid's loc for values
Using information available in the `.cmt`, store locations of uids coming from `include`s in a new state field : `state.signature.uid_to_loc`. Using `.cmt` and `.cmti`, store locations of values' (and patterns in value bindings) uids at the same location for easier lookup. This is done as soon as the files are loaded, before the analysis. The new table tries to be semantically equivalent to the usage of `cmt_value_dependencies` instead of `cmt_declaration_dependencies` before OCaml 5.3. This fixes the FP and FN introduced when moving to OCaml 5.3.
1 parent 9ddceca commit f1893ff

File tree

10 files changed

+415
-529
lines changed

10 files changed

+415
-529
lines changed

check/classic/classic.ref

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242

4343
./examples/using_make/advanced/inc_val.mli:1: x
4444
./examples/using_make/advanced/inc_val.mli:2: y
45-
./examples/using_make/advanced/val.mli:1: x: Should not be detected
46-
./examples/using_make/advanced/val.mli:2: y: Should not be detected
45+
4746
./examples/using_make/bar.ml:1: x
4847
./examples/using_make/bar_fn.ml:3: h
4948
./examples/using_make/baz.mli:1: z
@@ -109,29 +108,31 @@ Nothing else to report in this section
109108
./examples/using_dune/unwrapped_lib/obj/with_class.mli:25: fun_class#unused
110109
./examples/using_dune/unwrapped_lib/obj/with_class.mli:35: _self_used#unused
111110
./examples/using_dune/unwrapped_lib/obj/with_class.mli:41: _self_used_fun_class#unused
112-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_fun: Not detected
113-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_int: Not detected
114-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_fun: Not detected
115-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_int: Not detected
116-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun: Not detected
117-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int: Not detected
118-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun: Not detected
119-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int: Not detected
111+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_fun
112+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_int
113+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_fun
114+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_int
115+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun
116+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int
117+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun
118+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int
119+
120120
./examples/using_dune/wrapped_lib/obj/with_class.mli:1: unused#unused
121121
./examples/using_dune/wrapped_lib/obj/with_class.mli:5: basics#never_used_fun
122122
./examples/using_dune/wrapped_lib/obj/with_class.mli:5: basics#never_used_int
123123
./examples/using_dune/wrapped_lib/obj/with_class.mli:23: unused_fun_class#unused
124124
./examples/using_dune/wrapped_lib/obj/with_class.mli:25: fun_class#unused
125125
./examples/using_dune/wrapped_lib/obj/with_class.mli:35: _self_used#unused
126126
./examples/using_dune/wrapped_lib/obj/with_class.mli:41: _self_used_fun_class#unused
127-
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_fun: Not detected
128-
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_int: Not detected
129-
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_fun: Not detected
130-
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_int: Not detected
131-
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun: Not detected
132-
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int: Not detected
133-
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun: Not detected
134-
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int: Not detected
127+
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_fun
128+
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_int
129+
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_fun
130+
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_int
131+
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun
132+
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int
133+
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun
134+
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int
135+
135136
./examples/using_make/obj/class.mli:1: c#h
136137
./examples/using_make/obj/class_type.mli:9: c#h
137138
./examples/using_make/obj/coerce.mli:6: p#f
@@ -347,8 +348,6 @@ Nothing else to report in this section
347348
./examples/using_make/if_end.ml:5: ?b
348349
./examples/using_make/letIn.mli:1: ?a
349350
./examples/using_make/let_in.ml:1: ?a
350-
./examples/using_make/opt/sig_struct.ml:6: ?x: Should not be detected
351-
./examples/using_make/opt/sig_struct.ml:11: ?x: Should not be detected
352351
./examples/using_make/opt_in_opt.ml:1: ?a
353352
./examples/using_make/opt_in_opt.ml:5: ?a
354353
./examples/using_make/partial_opt.ml:1: ?a
@@ -455,7 +454,6 @@ Nothing else to report in this section
455454
./examples/using_make/foo.ml:1: ?a
456455
./examples/using_make/letIn.mli:1: ?b
457456
./examples/using_make/let_in.ml:1: ?c
458-
./examples/using_make/opt/sig_struct.ml:2: ?x: Should not be detected
459457
./examples/using_make/opt_in_opt.ml:2: ?a
460458
./examples/using_make/opt_in_opt.ml:2: ?b
461459
./examples/using_make/record.ml:12: ?b
@@ -502,7 +500,7 @@ Nothing else to report in this section
502500
--------------------------------------------------------------------------------
503501

504502

505-
Total: 438
506-
Success: 417
507-
Failed: 21
508-
Ratio: 95.2054794521%
503+
Total: 433
504+
Success: 433
505+
Failed: 0
506+
Ratio: 100.%

check/internal/internal.ref

Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
11
.> UNUSED EXPORTED VALUES:
22
=========================
33
./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg
4-
./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:8: internally_used_fun_with_single_never_used_opt_arg: Should not be detected
5-
./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:10: internally_used_fun_with_single_always_used_opt_arg: Should not be detected
6-
./examples/using_dune/unwrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg: Should not be detected
4+
75
./examples/using_dune/unwrapped_lib/values/values.mli:2: unused_int
8-
./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun: Not detected
9-
./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun: Not detected
10-
./examples/using_dune/unwrapped_lib/values/values.mli:25: unused_closure: Not detected
11-
./examples/using_dune/unwrapped_lib/values/values.mli:3: internally_used_int: Should not be detected
12-
./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun: Should not be detected
13-
./examples/using_dune/unwrapped_lib/values/values.mli:15: internally_used_fun: Should not be detected
14-
./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun: Should not be detected
15-
./examples/using_dune/unwrapped_lib/values/values.mli:25: unused_closure: Should not be detected
16-
./examples/using_dune/unwrapped_lib/values/values.mli:26: internally_used_closure: Should not be detected
6+
./examples/using_dune/unwrapped_lib/values/values.mli:14: unused_fun
7+
./examples/using_dune/unwrapped_lib/values/values.mli:20: unused_alias_fun
8+
./examples/using_dune/unwrapped_lib/values/values.mli:25: unused_closure
179
./examples/using_dune/unwrapped_lib/values/values_in_submodules.mli:3: Exported.unused_int
18-
./examples/using_dune/unwrapped_lib/values/values_in_submodules.mli:4: Exported.internally_used_int: Should not be detected
1910
./examples/using_dune/unwrapped_lib/values/values_in_submodules_no_intf.ml:3: Exported.unused_int
2011
./examples/using_dune/unwrapped_lib/values/values_no_intf.ml:2: unused_int
2112
./examples/using_dune/unwrapped_lib/values/values_no_intf.ml:13: unused_fun
2213
./examples/using_dune/unwrapped_lib/values/values_no_intf.ml:20: unused_alias_fun
2314
./examples/using_dune/unwrapped_lib/values/values_no_intf.ml:25: unused_closure
2415

2516
./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:1: unused_fun_with_single_never_used_opt_arg
26-
./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:8: internally_used_fun_with_single_never_used_opt_arg: Should not be detected
27-
./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:10: internally_used_fun_with_single_always_used_opt_arg: Should not be detected
28-
./examples/using_dune/wrapped_lib/opt_args/opt_args.mli:12: internally_used_fun_with_single_sometimes_used_opt_arg: Should not be detected
17+
2918
./examples/using_dune/wrapped_lib/values/values.mli:2: unused_int
30-
./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun: Not detected
31-
./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun: Not detected
32-
./examples/using_dune/wrapped_lib/values/values.mli:25: unused_closure: Not detected
33-
./examples/using_dune/wrapped_lib/values/values.mli:3: internally_used_int: Should not be detected
34-
./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun: Should not be detected
35-
./examples/using_dune/wrapped_lib/values/values.mli:15: internally_used_fun: Should not be detected
36-
./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun: Should not be detected
37-
./examples/using_dune/wrapped_lib/values/values.mli:25: unused_closure: Should not be detected
38-
./examples/using_dune/wrapped_lib/values/values.mli:26: internally_used_closure: Should not be detected
19+
./examples/using_dune/wrapped_lib/values/values.mli:14: unused_fun
20+
./examples/using_dune/wrapped_lib/values/values.mli:20: unused_alias_fun
21+
./examples/using_dune/wrapped_lib/values/values.mli:25: unused_closure
3922
./examples/using_dune/wrapped_lib/values/values_in_submodules.mli:3: Exported.unused_int
40-
./examples/using_dune/wrapped_lib/values/values_in_submodules.mli:4: Exported.internally_used_int: Should not be detected
4123
./examples/using_dune/wrapped_lib/values/values_in_submodules_no_intf.ml:3: Exported.unused_int
4224
./examples/using_dune/wrapped_lib/values/values_no_intf.ml:2: unused_int
4325
./examples/using_dune/wrapped_lib/values/values_no_intf.ml:13: unused_fun
@@ -46,8 +28,7 @@
4628

4729
./examples/using_make/advanced/inc_val.mli:1: x
4830
./examples/using_make/advanced/inc_val.mli:2: y
49-
./examples/using_make/advanced/val.mli:1: x: Should not be detected
50-
./examples/using_make/advanced/val.mli:2: y: Should not be detected
31+
5132
./examples/using_make/bar.ml:1: x
5233
./examples/using_make/bar_fn.ml:3: h
5334
./examples/using_make/baz.mli:1: z
@@ -64,41 +45,25 @@
6445
./examples/using_make/dir/anon_call2.ml:9: h
6546
./examples/using_make/dir/match_opt.ml:8: l
6647
./examples/using_make/dir/matchopt.ml:5: w
67-
./examples/using_make/dir/mod.mli:10: M.f: Should not be detected
6848
./examples/using_make/dir/mod.mli:11: M.g
6949
./examples/using_make/dir/refFn.mli:3: x
7050
./examples/using_make/dir/ref_opt.ml:3: no
7151
./examples/using_make/dir/ref_opt.ml:11: x
7252

73-
./examples/using_make/exported.mli:11: F.times_five: Not detected
74-
./examples/using_make/exported.mli:17: M2.ten: Not detected
75-
./examples/using_make/exported.mli:6: M1.five: Should not be detected
76-
./examples/using_make/exported.mli:10: F.plus_five: Should not be detected
77-
./examples/using_make/exported.mli:11: F.times_five: Should not be detected
78-
./examples/using_make/exported.mli:15: M2.five: Should not be detected
79-
./examples/using_make/exported.mli:16: M2.plus_five: Should not be detected
80-
./examples/using_make/exported.mli:17: M2.ten: Should not be detected
53+
./examples/using_make/exported.mli:11: F.times_five
54+
./examples/using_make/exported.mli:17: M2.ten
8155
./examples/using_make/foo.mli:2: y
8256
./examples/using_make/fooFn.mli:2: g
83-
./examples/using_make/functor.mli:2: M.f: Should not be detected
8457
./examples/using_make/functor.mli:3: M.none
85-
./examples/using_make/functor.mli:7: F.g: Should not be detected
86-
./examples/using_make/functor.mli:11: N.g: Should not be detected
8758
./examples/using_make/let_in.ml:3: parent
8859
./examples/using_make/let_test.ml:3: g
8960
./examples/using_make/matchopt.ml:5: w
90-
./examples/using_make/mod_alias.mli:2: M1.id: Should not be detected
91-
./examples/using_make/mod_alias.mli:6: M2.id: Should not be detected
92-
./examples/using_make/obj/class.mli:7: o: Should not be detected
93-
./examples/using_make/obj/class.mli:9: f: Should not be detected
94-
./examples/using_make/obj/inher.mli:11: o: Should not be detected
95-
./examples/using_make/obj/inher.mli:13: f: Should not be detected
9661
./examples/using_make/opt_in_opt.ml:7: x
9762
./examples/using_make/qux.ml:1: z
9863
./examples/using_make/unused_fn.ml:3: g
9964
./examples/using_make/unused_fn.ml:5: var
10065
./examples/using_make/useless_opt.ml:3: x
101-
./examples/using_make/variant.mli:5: f: Should not be detected
66+
10267
Nothing else to report in this section
10368
--------------------------------------------------------------------------------
10469

@@ -112,29 +77,31 @@ Nothing else to report in this section
11277
./examples/using_dune/unwrapped_lib/obj/with_class.mli:25: fun_class#unused
11378
./examples/using_dune/unwrapped_lib/obj/with_class.mli:35: _self_used#unused
11479
./examples/using_dune/unwrapped_lib/obj/with_class.mli:41: _self_used_fun_class#unused
115-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_fun: Not detected
116-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_int: Not detected
117-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_fun: Not detected
118-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_int: Not detected
119-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun: Not detected
120-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int: Not detected
121-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun: Not detected
122-
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int: Not detected
80+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_fun
81+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:1: immediate#unused_int
82+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_fun
83+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:11: factory#unused_int
84+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun
85+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int
86+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun
87+
./examples/using_dune/unwrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int
88+
12389
./examples/using_dune/wrapped_lib/obj/with_class.mli:1: unused#unused
12490
./examples/using_dune/wrapped_lib/obj/with_class.mli:5: basics#never_used_fun
12591
./examples/using_dune/wrapped_lib/obj/with_class.mli:5: basics#never_used_int
12692
./examples/using_dune/wrapped_lib/obj/with_class.mli:23: unused_fun_class#unused
12793
./examples/using_dune/wrapped_lib/obj/with_class.mli:25: fun_class#unused
12894
./examples/using_dune/wrapped_lib/obj/with_class.mli:35: _self_used#unused
12995
./examples/using_dune/wrapped_lib/obj/with_class.mli:41: _self_used_fun_class#unused
130-
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_fun: Not detected
131-
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_int: Not detected
132-
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_fun: Not detected
133-
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_int: Not detected
134-
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun: Not detected
135-
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int: Not detected
136-
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun: Not detected
137-
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int: Not detected
96+
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_fun
97+
./examples/using_dune/wrapped_lib/obj/without_class.mli:1: immediate#unused_int
98+
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_fun
99+
./examples/using_dune/wrapped_lib/obj/without_class.mli:11: factory#unused_int
100+
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_fun
101+
./examples/using_dune/wrapped_lib/obj/without_class.mli:22: _self_used_immediate#unused_int
102+
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_fun
103+
./examples/using_dune/wrapped_lib/obj/without_class.mli:28: _self_used_factory#unused_int
104+
138105
./examples/using_make/obj/class.mli:1: c#h
139106
./examples/using_make/obj/class_type.mli:9: c#h
140107
./examples/using_make/obj/coerce.mli:6: p#f
@@ -350,8 +317,6 @@ Nothing else to report in this section
350317
./examples/using_make/if_end.ml:5: ?b
351318
./examples/using_make/letIn.mli:1: ?a
352319
./examples/using_make/let_in.ml:1: ?a
353-
./examples/using_make/opt/sig_struct.ml:6: ?x: Should not be detected
354-
./examples/using_make/opt/sig_struct.ml:11: ?x: Should not be detected
355320
./examples/using_make/opt_in_opt.ml:1: ?a
356321
./examples/using_make/opt_in_opt.ml:5: ?a
357322
./examples/using_make/partial_opt.ml:1: ?a
@@ -458,7 +423,6 @@ Nothing else to report in this section
458423
./examples/using_make/foo.ml:1: ?a
459424
./examples/using_make/letIn.mli:1: ?b
460425
./examples/using_make/let_in.ml:1: ?c
461-
./examples/using_make/opt/sig_struct.ml:2: ?x: Should not be detected
462426
./examples/using_make/opt_in_opt.ml:2: ?a
463427
./examples/using_make/opt_in_opt.ml:2: ?b
464428
./examples/using_make/record.ml:12: ?b
@@ -505,7 +469,7 @@ Nothing else to report in this section
505469
--------------------------------------------------------------------------------
506470

507471

508-
Total: 446
509-
Success: 380
510-
Failed: 66
511-
Ratio: 85.201793722%
472+
Total: 404
473+
Success: 404
474+
Failed: 0
475+
Ratio: 100.%

0 commit comments

Comments
 (0)