Often I could use some tools to statically analyze my code in order to help me making it cleaner. Something like compiler warnings, but those are not enough. Every now and then I dream about writing one (using clang libraries or gccxml), but I guess it would take too much work.
Some things that pop to my mind are:
looking for magic numbers (ie: hardcoded constant numbers different from 0).
checking that the rule of three is always respected (each class must have defined either all of destructor, copy-constructor and assignment operator, or none of them).
I also dream (but these things are pure utopia) about a preprocessor which parses some non-standard code and translates it to valid C++ code, a tool able to:
expand template aliases, so that I can have them in C++ (well, with C++0x this is no longer needed)
move inline functions at the end of files, so that I don't have to respect the declare-before-use rule, and am able to write classes inline as in Java.
offer an extended syntax, like supporting custom operators (which will be expanded in function calls), or some ad-hoc syntax/keyword to implement easily some patterns.
Is there any tool out there, able to do a subset of these things?
Otherwise what libraries would you suggest to implement these tasks (clang libs, gccxml, ...), and how much work do you think it would take?
cppcheck is just wonderful.
Google has an interesting tool along with its style guide... called cpplint. It may be helpful for generating cleaner code. Have a look.
http://code.google.com/p/google-styleguide/source/browse/trunk/cpplint/cpplint.py?r=15
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With