<div dir="ltr">Miklos,<div><br><div>TokenName produces unused variable warning in builds with asserts disabled.<br></div><div>Could you add LLVM_ATTRIBUTE_UNUSED to it?</div><div><br></div><div>Thanks,</div><div>--Artem</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 15, 2016 at 11:35 AM, Miklos Vajna via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vmiklos<br>
Date: Wed Jun 15 13:35:41 2016<br>
New Revision: 272816<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272816&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272816&view=rev</a><br>
Log:<br>
clang-rename: implement renaming of classes with a dtor<br>
<br>
The declaration wasn't renamed. Also neither part of the declaration<br>
wasn't renamed.<br>
<br>
Reviewers: klimek<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21364" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21364</a><br>
<br>
Added:<br>
    clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp<br>
Modified:<br>
    clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp<br>
<br>
Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=272816&r1=272815&r2=272816&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=272816&r1=272815&r2=272816&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed Jun 15 13:35:41 2016<br>
@@ -87,6 +87,28 @@ public:<br>
     return true;<br>
   }<br>
<br>
+  bool VisitCXXDestructorDecl(clang::CXXDestructorDecl *DestructorDecl) {<br>
+    if (getUSRForDecl(DestructorDecl->getParent()) == USR) {<br>
+      // Handles "~Foo" from "Foo::~Foo".<br>
+      SourceLocation Location = DestructorDecl->getLocation();<br>
+      const ASTContext &Context = DestructorDecl->getASTContext();<br>
+      StringRef TokenName = Lexer::getSourceText(<br>
+          CharSourceRange::getTokenRange(Location), Context.getSourceManager(),<br>
+          Context.getLangOpts());<br>
+      // 1 is the length of the "~" string that is not to be touched by the<br>
+      // rename.<br>
+      assert(TokenName.startswith("~"));<br>
+      LocationsFound.push_back(Location.getLocWithOffset(1));<br>
+<br>
+      if (DestructorDecl->isThisDeclarationADefinition()) {<br>
+        // Handles "Foo" from "Foo::~Foo".<br>
+        LocationsFound.push_back(DestructorDecl->getLocStart());<br>
+      }<br>
+    }<br>
+<br>
+    return true;<br>
+  }<br>
+<br>
   // Expression visitors:<br>
<br>
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {<br>
<br>
Added: clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp?rev=272816&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp?rev=272816&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp (added)<br>
+++ clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp Wed Jun 15 13:35:41 2016<br>
@@ -0,0 +1,17 @@<br>
+// RUN: cat %s > %t.cpp<br>
+// RUN: clang-rename -offset=135 -new-name=Bar %t.cpp -i --<br>
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s<br>
+class Foo {<br>
+public:<br>
+  Foo();<br>
+  ~Foo(); // CHECK: ~Bar();<br>
+};<br>
+<br>
+Foo::Foo() {<br>
+}<br>
+<br>
+Foo::~Foo() { // CHECK: Bar::~Bar()<br>
+}<br>
+<br>
+// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing<br>
+// this file.<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Artem Belevich</div></div>
</div>