473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Code Cleanup Tool

Hi
sorry - I guess this is slightly OT but still ;)

Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any suggestions
there? Google didnt help me much :/

Thanks in advance
Aug 1 '06 #1
6 4140

"Frank Neuhaus" <fn******@uni-koblenz.deschrieb im Newsbeitrag
news:ea**********@cache.uni-koblenz.de...
Hi
sorry - I guess this is slightly OT but still ;)

Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any
suggestions there? Google didnt help me much :/
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"
Aug 1 '06 #2
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit - it
reports unreachable code inside functions, unused parameters and unused
global functions. But unfortunately it doesnt report unused member
functions/variables :(
Aug 1 '06 #3
>Visual Studio >=7.0 with warning level set to
"scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit -
it reports unreachable code inside functions, unused parameters and
unused global functions. But unfortunately it doesnt report unused
member functions/variables :(
unused variables should be listed:

void foo()
{
int a;
int b=0;
}

warning C4101: 'a' : unreferenced local variable
warning C4189: 'b' : local variable is initialized but not referenced

for unused functions - the linker will usually get rid of them. No, I
don't know any tool that can list this for you, because only the
linker knows what functions are used.
Aug 1 '06 #4
Hello Frank,

On Tue, 1 Aug 2006 09:30:08 UTC, "Frank Neuhaus" <fn******@uni-koblenz.dewrote:
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit - it
reports unreachable code inside functions, unused parameters and unused
global functions. But unfortunately it doesnt report unused member
functions/variables :(
You might also try one of the "lint for C++" or static analysis tools
(Klockwork 7?). In general, unused variables and methods in classes
would be very hard to suggest that they weren't used. The linker
could perform such a step if there wasn't a chance that the code/vars
wouldn't be found by other means. Classes do much more than just
group together values and functions that may be unused.

Classes are abstractions of objects that your application may use.
The fact that you don't make use of a particular method doesn't
necessarily mean that it should be removed. You might be planning
on using that component later. The class is a building block for
others to build on. Hopefully the abstraction was valid.

Static analysis tools can find such items to remove. These tools
aren't cheap though. I've not read why you want to remove the
unused components from your code.

I generally review my legacy classes as I work with them to
understand if the abstractions are valid. There are times that
they get rewritten. Certainly if you think a method or value
isn't used -- comment it out, compile, link, and look for the
errors. With less common value/method names you might be able
to get away with a search on the source code.

David
Aug 1 '06 #5
unused variables should be listed:
>
void foo()
{
int a;
int b=0;
}

warning C4101: 'a' : unreferenced local variable
warning C4189: 'b' : local variable is initialized but not referenced

for unused functions - the linker will usually get rid of them. No, I
don't know any tool that can list this for you, because only the linker
knows what functions are used.
I meant member variables - anyway... I know its not relevant for the actual
compiler, but Id like to clean up my code and its kinda hard to do it
manually as the code is too big to instantly know which function is used,
which one is deprecated etc...

So if anyone else has suggestions -...
Aug 1 '06 #6
Frank Neuhaus wrote:
Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any suggestions
there? Google didnt help me much :/
You could try running doxygen over the whole project. If you enable the
"source code browser", it writes a "referenced by..." entry to all
function/member descriptions. You could maybe even tweak it (its
opensource) to output every unreferenced function/member to stderr.

However, beware that virtual member functions are not referenced in this
sense, since this is a static analysis.

Christian
Aug 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: use dmgass at hotmail dot com | last post by:
I'm writing a module and when it is imported by a script I want some code automatically executed when the importing script is finished executing. I'd like it to execute before interactive mode is...
1
by: djw | last post by:
c.l.p- I am having trouble understanding how one is supposed to correctly utilize try:...except:...finally: in real code. If I have a block of code like: def foo(): try: ... some code that...
1
by: KevinGPO | last post by:
I got ASP code (VBScript mixed with HTML & Javascript) and am looking for a clean/tidy program to clean up my code. Should I use Dreamweaver cleanup, tool?
1
by: lee_youjin | last post by:
I needed to defect when the user is clicking the IE X button ( top right). so I could execute the cleanup function. I was able to detect it using onbeforeunload event. Now I need to call the...
1
by: Jason S | last post by:
I haven't used try/catch/finally very much in Javascript. My function (let's call it try_it()) needs to call a function that could throw an exception (let's call it dangerous()) with some setup()...
69
by: MQ | last post by:
Hi all I am just wondering how most people implement cleanup in C functions. In particular, if the function opens a number of resources, these need to be released properly should an error occur...
3
by: Petr Pavlu | last post by:
Hello, I have two questions how the functions should be written. I read the FAQ but didn't find any answer. If there is any please point me out. I. Cleanup code Consider I have to open file1,...
14
by: Alexander Stoyakin | last post by:
Hello! Please advise on the following issue. I have a function which returns 1 or 0 in multiple branches, and it must perform the same code before each return, like this: int fun() { if (some...
66
by: John | last post by:
Hi What are the advantages actually achieved of managed code? I am not talking of theory but in reality. Thanks Regards
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.