Background
I have inherited a legacy 60kloc g++ project which I would like to refactor to enforce a consistent naming convention throughout the project.
Question
Is there a free/open-source static analysis tool which can generate a list of:
Approach
My intention is to use vim to edit the generated list of symbols and then use a Ruby-script to do a very rough search-and-replace/mapping on symbols so that at the very least, naming conventions are consistent.
The procedure is a little ugly and I expect the initial compile to fail, but I don't mind going through and fix problems by hand if I can have a more readable set of code.
What kinds of tools do developers of large C++ code bases use to do this kind of refactoring?
Automatic refactoring of C++ is extremely hard, in part to do with the preprocessor (macros and file inclusion), but mostly to do with the interdependency between parsing, name lookup and the rest of the semantic analysis phase (template instantiation, constant expressions, overload resolution, etc, etc). On the very large C++ codebases I have worked on, automatic refactoring is simply not done, and because of the inherent difficulty, the quality of refactoring tools is poor.
Since the emergence of clang though, which specifically has a modular front-end so you can access the AST in a nicer way than other tools, there may be some better refactoring tools based on it - but I wouldn't hold my breath.
Take a look at the AST dump from clang, perhaps you can write a script on the XML to give you a dump that might form a starting point for refactoring it by hand.
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