dead_code_analyzer icon indicating copy to clipboard operation
dead_code_analyzer copied to clipboard

OCaml 5.3 compatibility

Open fantazio opened this issue 2 months ago • 0 comments

Includes https://github.com/LexiFi/dead_code_analyzer/pull/35, and https://github.com/LexiFi/dead_code_analyzer/pull/41. To be reviewed after 1.0.1.

Other than updating the OCaml version to 5.3 and fixing the compilation mistakes, this PR includes 2 import changes :

  • .cmti files are used instead of .cmi files. The cmi_infos are now read from either the .cmti if it exists or the .cmt otherwise. This simplifies a lot the initialization of State.File_infos.t. This type has evolved to only expose the information used from the various cm*_infos read. Using .cmti provides information used in the next point.
  • the cmt_infos.cmt_value_dependencies is recreated (as a list of pairs of locations, to only expose what is actually used). Indeed, it is replaced by cmt_declaration_dependencies which exposes a lot more dependencies than only values, and some uids in that list are missing in the cmt_infos.cmt_uid_to_decl. To recreate the value dependencies , the latter field of both the .cmt and .cmti files are used, and missing uids' locations are retrieved in the signatures of includes found in the implementation[^includes].

All tests pass. There are many inconsistencies when running on Frama-C 31.0 (most are coming from https://github.com/LexiFi/dead_code_analyzer/issues/40)

This is a first step for https://github.com/LexiFi/dead_code_analyzer/issues/39

[^includes]: It feels hacky to have to retrieve uid's loc by exploring the signatures of includes. If the uid appears in the cmt_declaration_dependencies, I would expect to find it in cmt_infos.cmt_uid_to_decl.

fantazio avatar Dec 15 '25 18:12 fantazio