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' to get the correct offset of foo when changing +// this file.