Skip to content

Commit c3c4587

Browse files
committed
[src][sourcepath] remove .pp extension from sourcepath
Rather than removing the `.pp` extension in `Utils.unit`, it is directly removed from the sourcepaths read in `.cmt` files. This way, compilation units remain consistent; and file paths read in locations are now also consistent with the sourcepaths. More details on why this fixes the observed FN and FP below. With this change, I measured a gain of ~10s (from ~22s to ~12s) when running the analyzer with `-v --all` on [Frama-C 31.0](https://git.frama-c.com/pub/frama-c/-/tree/31.0?ref_type=tags) on my machine. This is coherent with the few computations of the cmts' sourcepaths (once per `.cmt` read) vs the amount of time the compilation unit is computed (on every potentially meaningful location). As mentionned in f090928, there was a difference between the compilation unit of a preprocessed file and the one of an unpreprocessed file. Forcing them to have the same compilation unit by removing the `.pp` extension is sufficient in most cases. However, in the case of optional arguments, some computations relied on finding whether a location belongs to the current or a previously analyzed sourcefile, or if it belongs to an unknown (potentially analyzed later) sourcefile. In particular, `VdNode.eof` relies on this to discard "internal" locations and, thus, dissociate them from their corresponding "external" locations. This property is checked in `DeadCommon.VdNode.seen` by verifying if the location has a corresponding sourcepath in the `DeadCommon.abspath` table. This table associates compilation units (as obtained by `Utils.unit`) with sourcepaths (read in the `.cmi` and `.cmt` files) and is filled when starting the analysis of either a `.cmi` or a `.cmt`. Verifying that a location belongs to a known file is done by checking if its filename is a suffix of one of the sourcepaths associated with its compilation unit. The sourcepath of a `.cmt` file may end with `.pp.ml`, while locaitons found in the typedtree will not contain the `.pp` part. Therefore, the inconsistency observed in f090928 still remains for sourcepaths. Because of this inconsistency, the internal and external locations are not dissociated at the end of the analysis of a `.cmt`, leading to the observed FN and FP.
1 parent 2b8f7e2 commit c3c4587

File tree

7 files changed

+62
-69
lines changed

7 files changed

+62
-69
lines changed

check/classic/classic.ref

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,12 @@ Nothing else to report in this section
243243
.> OPTIONAL ARGUMENTS: ALWAYS:
244244
=============================
245245
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?always
246-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally: Not detected
246+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally
247247
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?always
248248
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?always
249-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?always: Should not be detected
250-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always: Not detected
251-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally: Not detected
252-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always: Not detected
249+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always
250+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally
251+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always
253252
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?always
254253
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?always
255254
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?always
@@ -388,15 +387,14 @@ Nothing else to report in this section
388387

389388
.> OPTIONAL ARGUMENTS: NEVER:
390389
============================
391-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally: Not detected
390+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally
392391
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?never
393392
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?never
394393
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?never
395-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?never: Should not be detected
396394
./examples/using_dune/preprocessed_lib/preprocessed.ml:84: ?opt
397-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally: Not detected
398-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never: Not detected
399-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never: Not detected
395+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally
396+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never
397+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never
400398
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?never
401399
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?never
402400
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?never
@@ -552,7 +550,7 @@ Nothing else to report in this section
552550
--------------------------------------------------------------------------------
553551

554552

555-
Total: 479
556-
Success: 469
557-
Failed: 10
558-
Ratio: 97.9123173278%
553+
Total: 477
554+
Success: 477
555+
Failed: 0
556+
Ratio: 100.%

check/internal/internal.ref

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,12 @@ Nothing else to report in this section
210210
.> OPTIONAL ARGUMENTS: ALWAYS:
211211
=============================
212212
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?always
213-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally: Not detected
213+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally
214214
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?always
215215
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?always
216-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?always: Should not be detected
217-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always: Not detected
218-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally: Not detected
219-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always: Not detected
216+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always
217+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally
218+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always
220219
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?always
221220
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?always
222221
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?always
@@ -355,15 +354,14 @@ Nothing else to report in this section
355354

356355
.> OPTIONAL ARGUMENTS: NEVER:
357356
============================
358-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally: Not detected
357+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally
359358
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?never
360359
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?never
361360
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?never
362-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?never: Should not be detected
363361
./examples/using_dune/preprocessed_lib/preprocessed.ml:84: ?opt
364-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally: Not detected
365-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never: Not detected
366-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never: Not detected
362+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally
363+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never
364+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never
367365
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?never
368366
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?never
369367
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?never
@@ -519,7 +517,7 @@ Nothing else to report in this section
519517
--------------------------------------------------------------------------------
520518

521519

522-
Total: 448
523-
Success: 438
524-
Failed: 10
525-
Ratio: 97.7678571429%
520+
Total: 446
521+
Success: 446
522+
Failed: 0
523+
Ratio: 100.%

check/threshold-1/threshold-1.ref

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,12 @@ Nothing else to report in this section
518518
.> OPTIONAL ARGUMENTS: ALWAYS:
519519
=============================
520520
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?always
521-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally: Not detected
521+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally
522522
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?always
523523
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?always
524-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?always: Should not be detected
525-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always: Not detected
526-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally: Not detected
527-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always: Not detected
524+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always
525+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally
526+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always
528527
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?always
529528
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?always
530529
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?always
@@ -663,15 +662,14 @@ Nothing else to report in this section
663662

664663
.> OPTIONAL ARGUMENTS: NEVER:
665664
============================
666-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally: Not detected
665+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally
667666
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?never
668667
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?never
669668
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?never
670-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?never: Should not be detected
671669
./examples/using_dune/preprocessed_lib/preprocessed.ml:84: ?opt
672-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally: Not detected
673-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never: Not detected
674-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never: Not detected
670+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally
671+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never
672+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never
675673
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?never
676674
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?never
677675
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?never
@@ -827,7 +825,7 @@ Nothing else to report in this section
827825
--------------------------------------------------------------------------------
828826

829827

830-
Total: 719
831-
Success: 709
832-
Failed: 10
833-
Ratio: 98.6091794159%
828+
Total: 717
829+
Success: 717
830+
Failed: 0
831+
Ratio: 100.%

check/threshold-3-0.5/threshold-3-0.5.ref

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,12 @@ Nothing else to report in this section
711711
.> OPTIONAL ARGUMENTS: ALWAYS:
712712
=============================
713713
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?always
714-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally: Not detected
714+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally
715715
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?always
716716
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?always
717-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?always: Should not be detected
718-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always: Not detected
719-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally: Not detected
720-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always: Not detected
717+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?always
718+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?externally
719+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?always
721720
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?always
722721
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?always
723722
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?always
@@ -854,12 +853,9 @@ Nothing else to report in this section
854853

855854
.>-> OPTIONAL ARGUMENTS: ALMOST ALWAYS: Except 1 time(s):
856855
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
857-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally (1/2 calls): Should not be detected
858-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally (1/2 calls): Should not be detected
859856
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?sometimes (1/2 calls)
860857
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?sometimes (1/2 calls)
861-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?sometimes (1/2 calls): Should not be detected
862-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?sometimes (1/2 calls): Not detected
858+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?sometimes (1/2 calls)
863859
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?externally (1/2 calls)
864860
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?internally (1/2 calls)
865861
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?sometimes (1/2 calls)
@@ -955,15 +951,14 @@ Nothing else to report in this section
955951

956952
.> OPTIONAL ARGUMENTS: NEVER:
957953
============================
958-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally: Not detected
954+
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally
959955
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?never
960956
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?never
961957
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?never
962-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?never: Should not be detected
963958
./examples/using_dune/preprocessed_lib/preprocessed.ml:84: ?opt
964-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally: Not detected
965-
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never: Not detected
966-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never: Not detected
959+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?internally
960+
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: ?never
961+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?never
967962
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?never
968963
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?never
969964
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:64: ?never
@@ -1070,12 +1065,9 @@ Nothing else to report in this section
10701065

10711066
.>-> OPTIONAL ARGUMENTS: ALMOST NEVER: Except 1 time(s):
10721067
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1073-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?externally (1/2 calls): Should not be detected
1074-
./examples/using_dune/preprocessed_lib/preprocessed.ml:53: ?internally (1/2 calls): Should not be detected
10751068
./examples/using_dune/preprocessed_lib/preprocessed.ml:59: ?sometimes (1/2 calls)
10761069
./examples/using_dune/preprocessed_lib/preprocessed.ml:64: ?sometimes (1/2 calls)
1077-
./examples/using_dune/preprocessed_lib/preprocessed.ml:69: ?sometimes (1/2 calls): Should not be detected
1078-
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?sometimes (1/2 calls): Not detected
1070+
./examples/using_dune/preprocessed_lib/preprocessed.mli:44: ?sometimes (1/2 calls)
10791071
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?externally (1/2 calls)
10801072
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:53: ?internally (1/2 calls)
10811073
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:59: ?sometimes (1/2 calls)
@@ -1202,7 +1194,7 @@ Nothing else to report in this section
12021194
--------------------------------------------------------------------------------
12031195

12041196

1205-
Total: 1022
1206-
Success: 1004
1207-
Failed: 18
1208-
Ratio: 98.2387475538%
1197+
Total: 1014
1198+
Success: 1014
1199+
Failed: 0
1200+
Ratio: 100.%

src/state/file_infos.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ let empty = {
2323
let init_from_cmt_infos cmt_infos cmt_file =
2424
let builddir = cmt_infos.Cmt_format.cmt_builddir in
2525
let sourcepath =
26-
Option.map (Filename.concat builddir) cmt_infos.cmt_sourcefile
26+
Option.map Utils.remove_pp cmt_infos.cmt_sourcefile
27+
|> Option.map (Filename.concat builddir)
2728
in
2829
let modname = cmt_infos.cmt_modname in
2930
{empty with cmti_file = cmt_file;

src/utils.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
let remove_pp fn =
2+
let ext = Filename.extension fn in
3+
let no_ext = Filename.remove_extension fn in
4+
match Filename.extension no_ext with
5+
| ".pp" -> Filename.remove_extension no_ext ^ ext
6+
| _ -> fn
7+
18
let unit fn =
2-
let u = Filename.remove_extension (Filename.basename fn) in
3-
match Filename.extension u with
4-
| ".pp" -> Filename.remove_extension u
5-
| _ -> u
9+
Filename.remove_extension (Filename.basename fn)
610

src/utils.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
val remove_pp : string -> string
2+
13
val unit : string -> string

0 commit comments

Comments
 (0)