/reanalyze-ropas

ReScript static analysis tool, from https://github.com/rescript-association/reanalyze and extended upon by ROPAS@SNU

Primary LanguageOCamlOtherNOASSERTION

reanalyze-ropas

This repository utilizes the frontend developed in reanalyze, and attempts to improve upon the exception analysis feature that reanalyze provides. The dead-code elimination and termination analysis features are not implemented and are kept in their original forms. For improved dead code analysis, refer to Jhuni0123/redder, which also improves upon the worklist algorithm used in this codebase. The code of the original reanalyze repository and the code for exa are licensed under the MIT license.

Exception Analysis

The newly implemented exception analysis follows the approach taken in Ryu and Yi, Towards a Cost-Effective Estimation of Uncaught Exceptions in SML Programs. Support for references and mutable record fields and experimental support for accurate pattern filtering is added as to cover realistic programs, but the hacky implementation in this development makes the analysis unsound. An informal documentation in pdf form can be found here.

Running the analysis prints out what exceptions can be raised from the toplevel of each file, and prints out what the arguments of each exception might contain.

Build for Native Projects

dune build
./_build/default/src/Reanalyze.exe -exception-cmt <path-to-cmt-files>

An example that analyzes possible exceptions in the standard library of OCaml is:

cd ~/.opam/<ocaml-version>/lib/ocaml
<path to binary> -exclude-paths "./compiler-libs,./ocamldoc,./topdirs" -exception-cmt .

To track where the exception originates from, add the flag -exception-track <exception constructor> before -exception-cmt.

Build for ReScript

npm run build406
./_build/default/src/Reanalyze.exe -exception-cmt <path-to-cmt-files>