[clang-tools-extra] r269952 - clang-rename: handle non-inline ctor definitions when renaming classes
Miklos Vajna via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 09:12:49 PDT 2016
Author: vmiklos
Date: Wed May 18 11:12:48 2016
New Revision: 269952
URL: http://llvm.org/viewvc/llvm-project?rev=269952&view=rev
Log:
clang-rename: handle non-inline ctor definitions when renaming classes
The result of the test was C::D(), not D::D().
Reviewers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D20356
Added:
clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=269952&r1=269951&r2=269952&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed May 18 11:12:48 2016
@@ -79,6 +79,11 @@ public:
}
}
}
+
+ 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;
}
Added: clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp?rev=269952&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp Wed May 18 11:12:48 2016
@@ -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.
More information about the cfe-commits
mailing list