[PATCH] D20356: clang-rename: handle non-inline ctor definitions when renaming classes

Miklos Vajna via cfe-commits cfe-commits at lists.llvm.org
Wed May 18 02:21:19 PDT 2016


vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

The result of the test was C::D(), not D::D().

http://reviews.llvm.org/D20356

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/CtorDefTest.cpp

Index: test/clang-rename/CtorDefTest.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/CtorDefTest.cpp
@@ -0,0 +1,15 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+    C();
+};
+
+C::C() // CHECK: D::D()
+{
+}
+
+// Use grep -FUbo 'C' <file> to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===================================================================
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -79,6 +79,11 @@
         }
       }
     }
+
+    if (getUSRForDecl(ConstructorDecl) == USR) {
+      // This takes care of the class name part of a non-inline ctor definition.
+      LocationsFound.push_back(ConstructorDecl->getLocStart());
+    }
     return true;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20356.57582.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160518/caad154f/attachment.bin>


More information about the cfe-commits mailing list