caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Dead code detection
@ 2013-12-11 14:52 Pierre-Yves Strub
  2013-12-11 14:56 ` Simon Cruanes
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Pierre-Yves Strub @ 2013-12-11 14:52 UTC (permalink / raw)
  To: caml-list

Hi all,

Does any of you know a tool for doing dead code detection?

Thanks,
-- Pierre-Yves.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Dead code detection
  2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
@ 2013-12-11 14:56 ` Simon Cruanes
  2013-12-11 14:56 ` Fabien Renaud
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Simon Cruanes @ 2013-12-11 14:56 UTC (permalink / raw)
  To: Pierre-Yves Strub; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

Le Wed, 11 Dec 2013, Pierre-Yves Strub a écrit :

> Hi all,
> 
> Does any of you know a tool for doing dead code detection?

Hi Pierre-Yves,

I don't use such a tool but I remember that Ocamlpic contains something
similar for shrinking bytecode files. See
http://www.algo-prog.info/ocaml_for_pic/web/index.php?id=OCAPIC:OCamlClean
.

It would be great to have such a standalone tool on opam, though.

Cheers,

-- 
Simon

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Dead code detection
  2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
  2013-12-11 14:56 ` Simon Cruanes
@ 2013-12-11 14:56 ` Fabien Renaud
  2013-12-11 15:07 ` Alain Frisch
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Fabien Renaud @ 2013-12-11 14:56 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

Hi,

You can try https://github.com/Michaaell/dead-code-detection (which
requires OCaml 4).

Fabien

On Wed, Dec 11, 2013 at 3:52 PM, Pierre-Yves Strub <pierre-yves@strub.nu>wrote:

> Hi all,
>
> Does any of you know a tool for doing dead code detection?
>
> Thanks,
> -- Pierre-Yves.
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 1328 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Dead code detection
  2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
  2013-12-11 14:56 ` Simon Cruanes
  2013-12-11 14:56 ` Fabien Renaud
@ 2013-12-11 15:07 ` Alain Frisch
  2013-12-11 16:46 ` oliver
  2013-12-11 21:18 ` Yoann Padioleau
  4 siblings, 0 replies; 6+ messages in thread
From: Alain Frisch @ 2013-12-11 15:07 UTC (permalink / raw)
  To: Pierre-Yves Strub, caml-list

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.
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Dead code detection
  2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
                   ` (2 preceding siblings ...)
  2013-12-11 15:07 ` Alain Frisch
@ 2013-12-11 16:46 ` oliver
  2013-12-11 21:18 ` Yoann Padioleau
  4 siblings, 0 replies; 6+ messages in thread
From: oliver @ 2013-12-11 16:46 UTC (permalink / raw)
  To: Pierre-Yves Strub; +Cc: caml-list

Hello,

On Wed, Dec 11, 2013 at 03:52:54PM +0100, Pierre-Yves Strub wrote:
> Hi all,
> 
> Does any of you know a tool for doing dead code detection?
[...]


-w flags for
    suspicious comment
    partially applied function
    overriden methods
    non-unit statement
    overriden instance variables
  * suspicious unused variables
  * all other unused variables

Especially unused variables may show lurking code,
that was once written in an intermediate state of
code development, and never be used again since then.


Ciao,
   Oliver

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Dead code detection
  2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
                   ` (3 preceding siblings ...)
  2013-12-11 16:46 ` oliver
@ 2013-12-11 21:18 ` Yoann Padioleau
  4 siblings, 0 replies; 6+ messages in thread
From: Yoann Padioleau @ 2013-12-11 21:18 UTC (permalink / raw)
  To: Pierre-Yves Strub; +Cc: <caml-list@inria.fr>

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Hi Pierre,

I made a tool using the .cmt format that visualizes code dependencies:
https://github.com/facebook/pfff/wiki/CodeGraph
https://github.com/facebook/pfff/blob/master/main_codegraph.ml
https://github.com/facebook/pfff/wiki/Main

It also highlights dead code (at different granularities, dead directories,
dead files, dead functions, etc).


On Dec 11, 2013, at 6:52 AM, Pierre-Yves Strub <pierre-yves@strub.nu<mailto:pierre-yves@strub.nu>> wrote:

Hi all,

Does any of you know a tool for doing dead code detection?

Thanks,
-- Pierre-Yves.


--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[-- Attachment #2: Type: text/html, Size: 1591 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-11 21:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11 14:52 [Caml-list] Dead code detection Pierre-Yves Strub
2013-12-11 14:56 ` Simon Cruanes
2013-12-11 14:56 ` Fabien Renaud
2013-12-11 15:07 ` Alain Frisch
2013-12-11 16:46 ` oliver
2013-12-11 21:18 ` Yoann Padioleau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).