<div dir="ltr">For template specialization the renaming tool would have to generate code, which is a little beyond what I would want a renaming tool to do, and determine which type to specialize to, which could quickly become a very complicated problem. </div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 29, 2014 at 5:22 PM, Eugene Ostroukhov <span dir="ltr"><<a href="mailto:eostroukhov@gmail.com" target="_blank">eostroukhov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Template specialization is also an option:<div><div class=""><div><br></div><div>struct A { typedef int Goo; };</div>
<div>struct B { typedef char Foo; };</div><div>template<typename T> struct X { typename T::Foo bar; };</div>
</div><div>template<> struct X<A> { typename A::Goo bar; };</div><div class=""><div>X<A> a;</div><div>X<B> b;</div></div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
<div class="">On Fri, Jul 25, 2014 at 1:23 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Fri, Jul 25, 2014 at 1:01 PM, Amin Shali <span dir="ltr"><<a href="mailto:amshali@google.com" target="_blank">amshali@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><div>Folks,</div><div><br>
</div>
<div>At Google we are working on a tool and set of APIs for refactoring C++ programs based on LibTooling. Particularly, we have targeted rename refactoring for C++ as our first step. </div>
<div><br></div><div>In our first iteration we want to offer two things:</div><div>1- A command line tool similar to clang-format which will semantically rename a symbol (specified by a position in a file) in a set of input files.</div>
</div></div></blockquote><div><br></div></div><div>Do you intend to provide one command-line tool per refactoring, or one tool that has subcommands for each operation? For command-line / scripting use, it'd seem useful to also be able to specify a symbol by name (at least for names that are not function-local). (For instance, say I want to rename all *Decl classes in clang to *Declaration. I'd like to be able to perform a semantic grep for those, then run them through a command-line rename tool.)</div>
<div><div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">
<div>2- An API for doing the above task which can effectively be used to provide this functionality for any editor (Emacs, Vim, CodeMirror, etc.).</div><div><br></div><div>
== Renaming capabilities</div><div>In the first iteration, we are offering the following features for the rename refactoring:</div><div>=== Supported C++ constructs:</div><div>
- Global and local variables (including function arguments)</div><div> - Functions</div><div> - C and CXX record types (structs/unions/classes)</div><div>
- For classes this includes renaming the constructor and destructor</div><div> - User defined types</div><div> - Enumerations (names and constants)</div>
<div> - Record member variables and methods</div><div> - Namespace specifiers</div><div> - Template parameters</div><div>
- Lambda captures</div><div> - Overloaded operators</div><div>=== Unsupported C++ constructs:</div><div> - Macros</div><div>
- Symbols in comments</div><div><div><br></div><div>== Command line program</div><div>=== Current support:</div><div>
- Input from stdin, output to stdout</div><div> - Input and output from/to disk</div><div> - Option to specify include path</div><div>
- Option to predefine macros</div><div>=== Possible improvements:<br></div><div> - Multiple files from stdin</div><div><div> - Making backups of renamed files</div>
<div><br></div></div><div>We think this tool should reside in clang-tools-extra. </div><div><br></div><div>Please let us know what you think. Any comment and feedback is appreciated. </div></div></div></div></blockquote>
<div><br></div></div></div><div>Do you have any thoughts on how to handle templates? For instance:</div><div><br></div><div>struct A { typedef int Foo; };</div><div>struct B { typedef char Foo; };</div><div>template<typename T> struct X { typename T::Foo bar; };</div>
<div>X<A> a;<br></div><div>X<B> b;</div><div><br></div><div>Suppose we want to rename A::Foo to A::Goo. Our obvious choices are:</div><div>1) Don't rename the use inside X; breaks X<A>.</div><div>2) Do rename the use inside X; breaks X<B>.</div>
<div>3) Rename the use inside X and the use inside B; will surprise users.</div><div>4) Report an error and refuse to rename A::Foo. Tell users they need to rename B::Foo too. (And if the user requests that both are renamed at the same time, do the right thing.)</div>
<div><br></div><div>I think option 4 is the best choice, but it might be a little tricky to get right.</div><div><br></div><div>How do you intend to behave when renaming an entity shared by multiple source files? That might influence the checks you're able to perform for the above case.<br>
</div></div></div></div>
<br></div></div><div class="">_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></div></blockquote></div><br></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>