dead_code_analyzer
dead_code_analyzer copied to clipboard
OCaml 5.3 compatibility
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 :
-
.cmtifiles are used instead of.cmifiles. Thecmi_infosare now read from either the.cmtiif it exists or the.cmtotherwise. This simplifies a lot the initialization ofState.File_infos.t. This type has evolved to only expose the information used from the variouscm*_infosread. Using.cmtiprovides information used in the next point. - the
cmt_infos.cmt_value_dependenciesis recreated (as a list of pairs of locations, to only expose what is actually used). Indeed, it is replaced bycmt_declaration_dependencieswhich exposes a lot more dependencies than only values, and some uids in that list are missing in thecmt_infos.cmt_uid_to_decl. To recreate the value dependencies , the latter field of both the.cmtand.cmtifiles are used, and missing uids' locations are retrieved in the signatures ofincludes 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.