summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-rename/USRLocFinder.cpp5
-rw-r--r--clang-tools-extra/test/clang-rename/CtorDefTest.cpp15
2 files changed, 20 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-rename/USRLocFinder.cpp b/clang-tools-extra/clang-rename/USRLocFinder.cpp
index 9a2356b1e06..cac7c01c66a 100644
--- a/clang-tools-extra/clang-rename/USRLocFinder.cpp
+++ b/clang-tools-extra/clang-rename/USRLocFinder.cpp
@@ -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;
}
diff --git a/clang-tools-extra/test/clang-rename/CtorDefTest.cpp b/clang-tools-extra/test/clang-rename/CtorDefTest.cpp
new file mode 100644
index 00000000000..192028a25c0
--- /dev/null
+++ b/clang-tools-extra/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.
OpenPOWER on IntegriCloud