Automated Code Refactoring


If you are working on any C++ refactoring, especially if it involves function calls, spans multiple files or feels like you need a compiler in your head to help you, drop me a note to see if squash can help. Squash provides a great deal of control over the refactoring process because it is not tied to a particular IDE and can be customized to accommodate for special cases.

On Friday, two squash-produced patches landed:

  1. A 212K patch to rename nsIFrame::GetPresContext to PresContext. It took a couple of minutes to produce a patch for mac & linux, and then some manual labour to complete it so it builds on Windows too. Unfortunately, Microsoft C++ is not yet supported by Oink. Windows-specific code will require magnitudes more of human labour until such support is contributed.
  2. A much simpler patch to calls to remove uses of the deprecated ::Recycle(). This took a few minutes once I added support for renaming global functions to squash.


C++ support in dehydra is coming along splendidly. I started working on cross-function analysis support. Currently my goal is to allow the user to build callgraphs of Mozilla. The first application of that is going to be dead code detection.

In the meantime, contact me if you are looking for patterns in the code that grep wont help with : control flow-sensitive code, type & syntax-aware matching, API misuse, etc. Dehydra can probably help.


  1. A doubt…
    is it going to work with any C++ code outside Gecko?

  2. Yes this works fine outside of gecko.

  3. Congratulations! This is extremely cool stuff.

  4. Taras

    I will be interested in hearing about the C++ dead code detector. (Dehydra project). Can you please provide pointers and status of the same ?


  5. Dead code detection is still a work in progress, not sure how long until I can show some results.
    Basic idea is that as the code gets larger and refactored some functions are no longer called and are just sitting there, possibly optimized away by the compiler, but still using up space in the code.