This revision was automatically updated to reflect the committed changes.
Closed by commit rL268857: clang-rename: when renaming a field, rename 
initializers of that field as well (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D19957?vs=56241&id=56497#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19957

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp

Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
     return true;
   }
 
+  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 (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+        if (getUSRForDecl(FieldDecl) == USR) {
+          // The initializer refers to a field that is to be renamed.
+          LocationsFound.push_back(Initializer->getSourceLocation());
+        }
+      }
+    }
+    return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo' <file> to get the correct offset of foo when changing
+// this file.


Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
     return true;
   }
 
+  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 (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+        if (getUSRForDecl(FieldDecl) == USR) {
+          // The initializer refers to a field that is to be renamed.
+          LocationsFound.push_back(Initializer->getSourceLocation());
+        }
+      }
+    }
+    return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo' <file> to get the correct offset of foo when changing
+// this file.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to