This is an archive of the discontinued LLVM Phabricator instance.

clang-rename: add a -export-fixes option
ClosedPublic

Authored by vmiklos on Jun 24 2016, 12:15 AM.

Details

Summary

Use case: a class is declared in a header, and defined in two
translation units. clang-rename is asked to rename a class member that's
referenced in both translation units.

Using -i is not possible, as in case the first clang-rename invocation
touches the header, the second invocation will result in compilation
errors. Using -export-fixes handles this situation, each invocation can
work on the original source, and at the end the user can apply the
replacements with clang-apply-replacements.

Diff Detail

Repository
rL LLVM

Event Timeline

vmiklos updated this revision to Diff 61759.Jun 24 2016, 12:15 AM
vmiklos retitled this revision from to clang-rename: add a -s (suffix) option.
vmiklos updated this object.
vmiklos added a reviewer: klimek.
vmiklos added a subscriber: cfe-commits.
klimek edited edge metadata.Jun 24 2016, 2:02 AM

Why don't we output replacements and use clang-apply-replacements?

vmiklos updated this revision to Diff 61833.Jun 24 2016, 1:54 PM
vmiklos edited edge metadata.

This version solves the problem outline in the commit message by implementing an -export-fixes commandline option, quite similar to clang-tidy's matching option.

vmiklos retitled this revision from clang-rename: add a -s (suffix) option to clang-rename: add a -export-fixes option.Jun 24 2016, 1:55 PM
vmiklos updated this object.
klimek accepted this revision.Jun 27 2016, 3:13 AM
klimek edited edge metadata.

lg

This revision is now accepted and ready to land.Jun 27 2016, 3:13 AM
This revision was automatically updated to reflect the committed changes.

Something related: currently in case multiple symbols is to be renamed in the same translation unit, clang-rename has to be invoked multiple times. This is problematic from a performance point of view, in case the symbols are in common headers of a codebase (and clang-rename is invoked for each translation unit). Would a patch that allows multiple renames to be performed with one invocation be welcome? E.g. initially via the -offset + -new-name options (let's say using , as separator), but later it would be probably more friendly to allow an input YAML file that describes what symbols should be renamed to what new names.