Tool to delete unneeded methods/enums, etc.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julek

    Tool to delete unneeded methods/enums, etc.

    Hi,
    is there a tool which parses cpp and h files, finds unused things, and
    deletes them from code? 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).

    Thanks in advance!
  • Jerry Coffin

    #2
    Re: Tool to delete unneeded methods/enums, etc.

    In article <62e3029a-2655-4b63-9511-d561acba7a89@
    34g2000hsh.goog legroups.com>, julekmen@go2.pl says...
    Hi,
    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.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

    Comment

    • James Kanze

      #3
      Re: Tool to delete unneeded methods/enums, etc.

      On Jun 30, 5:57 pm, Jerry Coffin <jcof...@taeus. comwrote:
      In article <62e3029a-2655-4b63-9511-d561acba7a89@
      34g2000hsh.goog legroups.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 helpful---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.kan ze@gmail.com
      Conseils en informatique orientée objet/
      Beratung in objektorientier ter Datenverarbeitu ng
      9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

      Comment

      Working...