Author |
Topic |
|
rwomack
Junior Member
United Kingdom
15 Posts |
Posted - Dec 16 2006 : 10:27:44 AM
|
It would be good if VA could list all C++ methods and functions that are not referenced in the project, so they could then be deleted from the source code to reduce the size. |
Thanks,
Roger |
|
bugfix
Tomato Guru
Germany
324 Posts |
|
studoot
Senior Member
35 Posts |
Posted - Dec 18 2006 : 08:30:28 AM
|
I would find something like this useful as well (I was only on the forum today to post a suggestion like that!). Also, the linker only removes unused functions if you have the correct option enabled...
Additionally, if you can remove unused functions out of source files, that will cut maintenance load (code review, understanding that the function isn't used etc).
Maybe a slight modification of rwomack's idea - All symbols declared in a certain scope (e.g. file or function, selected depending on where the cursor/mouse is?) that are unused in that scope?
Stuart Dootson |
|
|
bugfix
Tomato Guru
Germany
324 Posts |
Posted - Dec 18 2006 : 09:55:05 AM
|
dead code removal aint that easy:) what happens w/ virtual functions? functions/classes in a lib/dll project? lib/dll projects e.g. might be shared w/ other solutions. there are a lot of problems doing it at source level. just my 2 cents:)
you might want to check: http://www.gimpel.com from features: "find unused macros, typedef's, classes, members, declarations, etc. across the entire project (see weak definials)" |
http://www.mf-sd.de |
Edited by - bugfix on Dec 18 2006 10:01:18 AM |
|
|
studoot
Senior Member
35 Posts |
Posted - Dec 18 2006 : 10:00:25 AM
|
The issues involved with code removal aren't really any different to those encountered (say) by renaming a function. That effectively *deletes* the old function and creates a new one and hopes to find all references to the deleted function and replace them with references to the new one... |
|
|
feline
Whole Tomato Software
United Kingdom
19022 Posts |
Posted - Dec 18 2006 : 11:20:50 AM
|
Scanning for unused variables or functions is in our list of things to consider
case=2335
The current suggestion is to present the user with a list of items that VA thinks are never used, and then let the user which, if any, of these should be removed. Certainly any form of automated removal process would be very unwise.
Ultimately there is nothing stopping you running Find References on something now, and if it is never used you can delete it by hand.
We cannot stop the programmer from doing something stupid, dangerous or unwise, partly because VA is not so brilliant that it can reliably tell the difference between "good" and "bad" |
zen is the art of being at one with the two'ness |
|
|
rwomack
Junior Member
United Kingdom
15 Posts |
Posted - Dec 18 2006 : 11:39:27 AM
|
That sounds like a good solution. I wouldnt want it to delete them automatically. |
Thanks,
Roger |
|
|
studoot
Senior Member
35 Posts |
Posted - Dec 19 2006 : 02:31:05 AM
|
feline - that sounds like exactly the solution I was looking for . As you say, there's nowt to stop you using Find References (guess what - that's what I do currently when I think a function's unused). I'm just getting into the whole Refactoring menu thing and since I've started using it, I've found Find References invaluable. |
|
|
|
Topic |
|