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

David Blaikie dblaikie at gmail.com
Sun Jan 13 17:10:51 PST 2013


On Jan 13, 2013 12:27 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?

I believe the approach for some current tools is to compute all the edits
over the entire codebase, considering all the contents in each TU. Then
take all those edits and deduplicate them (as well as detecting conflicts)
before applying them.

>
> 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?
>
> - 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).
>
> Is there a "standard" way to deal with this?
>
> -- Sean Silva
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

On Jan 13, 2013 12:27 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?
>
> - 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).
>
> Is there a "standard" way to deal with this?
>
> -- Sean Silva
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130113/890648f2/attachment.html>


More information about the cfe-dev mailing list