Блог пользователя buGMaster

Автор buGMaster, 11 лет назад, По-английски

Hi again...
I need a tool which parses a source code (especially a c++ code) and generates a new one, that's all the unused parts of the original source code (such as includes, macros, functions, variables, ...) is removed in it.
I think, this tool helps in reducing compile time and run time; also makes the code more cleaner which makes debugging easier.
Is there such a tool? If no, how can I produce this tool? (I mean, how can I recognize unused parts of a my code?)
Any help would be appreciated!

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Well, I try to do that in my plugin using CLion API, but sometimes it deletes more than needed because CLion doesn't find references correctly.

See removeUnusedCode and DeletionMarkingVisitor

Maybe you could do something similar or start here and workaround broken search

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I've found ahmed_aly add a unused code cleaner for KawigiEdit (a Topcoder plugin).
Anybody knows this feature and the way it works?

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My caide tool removes (some of) unused C++ code too :). You can test it like this:

mkdir dir
cd dir
caide init
caide problem test
<Put your code into test/main.cpp file and clean test/test.cpp file>
caide make

The file submission.cpp will be created with unused code removed.

I can make a standalone code cleaner if you like it.