[PATCH] D20150: clang-rename: fix renaming of field with implicit initializers
Miklos Vajna via cfe-commits
cfe-commits at lists.llvm.org
Wed May 11 00:44:53 PDT 2016
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.
The last check failed as Cla::Cla() was rewritten to Cla::hector().
http://reviews.llvm.org/D20150
Files:
clang-rename/USRLocFinder.cpp
test/clang-rename/CtorInitializerTest.cpp
Index: test/clang-rename/CtorInitializerTest.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/CtorInitializerTest.cpp
@@ -0,0 +1,20 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=162 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class A
+{
+};
+
+class Cla
+{
+ A foo; // CHECK: hector;
+public:
+ Cla();
+};
+
+Cla::Cla() // CHECK: Cla::Cla()
+{
+}
+
+// Use grep -FUbo 'foo' <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
@@ -60,6 +60,11 @@
bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
const clang::CXXCtorInitializer* Initializer = *it;
+ if (Initializer->getSourceOrder() == -1) {
+ // Ignore implicit initializers.
+ continue;
+ }
+
if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
if (getUSRForDecl(FieldDecl) == USR) {
// The initializer refers to a field that is to be renamed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20150.56854.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160511/3c5b7ccc/attachment.bin>
More information about the cfe-commits
mailing list