<div dir="ltr"><font style="font-family:arial,sans-serif;font-size:13px"><font><font>Hey everyone, I can answer some of the questions as well.</font></font></font><div style="font-family:arial,sans-serif;font-size:13px"><br>
</div><div style="font-family:arial,sans-serif;font-size:13px"><font><font>It:</font></font></div><div class="im" style="font-family:arial,sans-serif;font-size:13px"><font><font>> </font></font><font><font>What does it mean to rename a lambda capture (or an operator)?</font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font><font>It means that we can rename symbols that appear in lambda captures. For operators, we are able to change which operator was being overloaded. For example, we can change all instances of "foo::operator ++" to "foo::operator --". This functionality is pretty limited but works in most cases.</font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><font><font>Also, I really like the idea of generating a path.</font></font></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><font><font>Richard:</font></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><font><font>Right now, there is only one command line tool, aptly called clang-rename. Right now, the type of renaming is much simpler than what you want: given a location in the code that refers to a symbol, all semantically (and syntactically) equivalent instances of that symbol will be renamed. So no, the tool cannot semantic grep, but there are plenty of tools to rename things based on regexps.</font></font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><font><font>In the case that you specify, no renaming will take place, unfortunately. Not at least renaming T::Foo bar is a bug, but one that can be fixed later. It was thought that erring on the side of not renaming was a better idea than making a guess :). Templates are tricky, and they're one of the few things that are not handled as substantially as they could be.</font></font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><font><font>Which brings me to how renaming takes place: we find a USR at a location, then we find every instance of that USR (and equivalent USRs for constructors/destructors), and then we rename based on those locations. Therefore, any USR that is not dependent on file name (which is almost all of them) can be used to find locations in other files. Thus, renaming in multiple source files works very smoothly.</font></font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><font><font>I hope that addressed your questions sufficiently.</font></font></font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font face="arial, sans-serif"><font><font>-Matt</font></font></font></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">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>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">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 class="h5">
<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>
</blockquote></div><br></div>