Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Pierre-Yves Strub <pierre-yves@strub.nu>, caml-list@inria.fr
Subject: Re: [Caml-list] Dead code detection
Date: Wed, 11 Dec 2013 16:07:35 +0100	[thread overview]
Message-ID: <52A87FB7.8010807@frisch.fr> (raw)
In-Reply-To: <a6230abe4852ccaee38d2cd206495b58@strub.nu>

At LexiFi, we use two different techniques for detecting dead code:

  - Bisect, for a dynamic notion of "dead code" (i.e. code which is not 
exercised by our testsuite).

  - A custom static detection tool, which parses .cmt and .cmi files to 
detect exported components (values, exceptions, etc) used by no other 
module in the project.  This is of course combined with the existing 
compiler warnings on locally unused and non-exported declarations.


The next version of OCaml will make it extremely simple to implement 
such a static detection tool.  This is because of the new -keep-locs 
compiler flag, which allows us to keep the location of exported values 
in .cmi files, and thus retrieve the same locations on references to 
such values in .cmt files.  It makes it very easy to create the link 
between an exported value and its references in external modules, even 
if this goes through e.g. module inclusions.  As a proof of concept of 
this approach, we can already try the tool 
experimental/frisch/unused_exported_values.ml in the trunk:

http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/trunk/experimental/frisch/unused_exported_values.ml?revision=HEAD&view=markup


(-keep-locs also gives "for free" a jump-to-definition feature, just by 
parsing .cmt or .annot files.)


Hope this helps,

Alain




On 12/11/2013 03:52 PM, Pierre-Yves Strub wrote:
> Hi all,
>
> Does any of you know a tool for doing dead code detection?
>
> Thanks,
> -- Pierre-Yves.
>
>


  parent reply	other threads:[~2013-12-11 15:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 14:52 Pierre-Yves Strub
2013-12-11 14:56 ` Simon Cruanes
2013-12-11 14:56 ` Fabien Renaud
2013-12-11 15:07 ` Alain Frisch [this message]
2013-12-11 16:46 ` oliver
2013-12-11 21:18 ` Yoann Padioleau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A87FB7.8010807@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=pierre-yves@strub.nu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox