473,503 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!
Jun 30 '08 #1
2 1569
In article <62e3029a-2655-4b63-9511-d561acba7a89@
34g2000hsh.googlegroups.com>, ju******@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.
Jun 30 '08 #2
On Jun 30, 5:57 pm, Jerry Coffin <jcof...@taeus.comwrote:
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 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:ja*********@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
Jun 30 '08 #3

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

Similar topics

125
7069
by: Raymond Hettinger | last post by:
I would like to get everyone's thoughts on two new dictionary methods: def count(self, value, qty=1): try: self += qty except KeyError: self = qty def appendlist(self, key, *values): try:
27
2704
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template...
3
1593
by: Sam Sungshik Kong | last post by:
Hello! While using panel control, I wondered a thing. Panel class is subclass of Control class. Control class has KeyPress event and Focus() method, etc... Then Panel class must have them. I...
10
3010
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal()...
4
1389
by: Oleg Subachev | last post by:
I have .cs source file with a bunch of public and internal members (classes, methods, enums ...) in it. I want to extract declarations of public members into separate file so that I can distribute...
2
4109
by: olympus_mons | last post by:
Hi, I'm just discovering the power of xsd.exe, so maybe I'm doing something wrong. schema files describing requests and responses. So there is an extra xsd file for each response and each...
12
2537
by: Premal | last post by:
Hi, I tried to make delete operator private for my class. Strangely it is giving me error if I compile that code in VC++.NET. But it compiles successfully on VC++6.o. Can anybody give me inputs...
6
2309
by: beantaxi | last post by:
Hello all, I'm looking for a very simple code analysis tool. I have a large codebase to analyze, and all I really need to do is to find all uses of all methods in a few interfaces. Many tools...
37
2166
by: Ian Semmel | last post by:
If I have Enum en { i1, i2, i3 } I reckon I should be able to have
0
7202
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
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
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,...
1
6991
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
5578
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.