[cfe-dev] Tooling: how to deal with headers?

Manuel Klimek klimek at google.com
Mon Jan 14 02:12:47 PST 2013


On Sun, Jan 13, 2013 at 9:25 PM, Sean Silva <silvas at purdue.edu> wrote:

> Hi Tooling folks, I have a quick question about making changes to
> headers with a clang tool.
>
> Suppose the following basic setup:
>
> - I have a compile_commands.json for a project.
> - I have a tool that renames class Foo to Bar.
>
> So if Foo appears in headers, how do occurrences of Foo in headers get
> renamed?
>
> To my understanding, the compile_commands.json only tracks the ".cpp"
> files that are compiled, rather than each source file in the project.
> This makes me wonder:
>
> - How will a tool will ensure that Foo only gets renamed once if it is
> in a header that is included multiple times?
>

If you use the RefactoringTool, adding Replacement's will auto-deduplicate.


> - Once Foo gets renamed in a header, how will the other files that
> have yet to be processed still see the old name (the new name would
> cause a compilation failure since the references in the other ".cpp"
> file will not have yet been renamed).
>

Use RefactoringTool and make all your replacements in a single tool-run. It
will apply all changes in the very end.

Cheers,
/Manuel


>
> Is there a "standard" way to deal with this?
>
> -- Sean Silva
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130114/86b71238/attachment.html>


More information about the cfe-dev mailing list