[cfe-dev] RFC: Formatting replacements in clang-replace

Vane, Edwin edwin.vane at intel.com
Fri Aug 30 11:35:19 PDT 2013


Hi all,

The C++11 Migrator currently has the functionality to track changes made to files and then use libclangFormat to reformat the changed code. I want to get people's feedback on moving this functionality into clang-replace (or whatever is decided to name this tool). Let me provide some motivation.

The next step for the migrator is process-based parallelism to speed up migration of code bases. The plan is a branch-and-gather approach: spawn multiple migrator processes to apply a single transform to multiple files. Each migrator process spits out serialized replacements. All serialized replacements are gathered in a single merge, deduplication, conflict detection, and application process: clang-replace. Then the next transform is applied in parallel. Due to the parallelism, the tracking of which parts of each file were changed is lost when clang-replace terminates. Clearly one option is to make the change tracking info persistent between executions of clang-replace. A simpler option, however, is to simply reformat changes every time clang-replace runs since knowledge of changed source ranges is known at this point.

Reformatting wouldn't be necessary and could just be activated with a command-line switch if necessary.

Beyond the migrator, affording the ability to reformat code after replacements are applied might be generally useful to other users of clang-replace. What say you all?

--
Edwin Vane
  Software Developer
  Intel of Canada, Inc.






More information about the cfe-dev mailing list