Afficher un message
Vieux 30/06/2008, 23h10   #3
James Kanze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tool to delete unneeded methods/enums, etc.

On Jun 30, 5:57 pm, Jerry Coffin <jcof...@taeus.com> wrote:
> In article <62e3029a-2655-4b63-9511-d561acba7a89@
> 34g2000hsh.googlegroups.com>, julek...@go2.pl says...


> > is there a tool which parses cpp and h files, finds unused
> > things, and deletes them from code?


> Yes. It's called an "optimizing compiler". :-)


> > For example unused methods, enums, enum
> > values, defines... It doesn't have to be sophisticated (it doesn't
> > have to check, that ClassA::funX is used somewhere, but ClassB::funX
> > is not used anywhere, so we can delete only ClassB::funX).


> Realistically, getting something like this to work correctly would be
> quite difficult -- little short of a full-blown compiler could really do
> the job correctly.


FWIW: one Fortran compiler I used (around 1978) did output a
message when it suppressed a line because it couldn't be
reached, or otherwise did something which had no effect. This
could actually be very ful---in one case, I remember getting
messages to the effect:
line x: removed, because variable YO is never used.
line y: variable Y0 used without being set.
I'm not sure about the relative utility of such a thing in C++,
however. The preprocessor makes it a bit awkward: what if I
don't use the enum E (defined in some header); maybe some other
code in another application does use it.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
  Réponse avec citation
 
Page generated in 0,05907 seconds with 9 queries