clang-rename: fix renaming of field with implicit initializers

The last check failed as Cla::Cla() was rewritten to Cla::hector().

Reviewers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D20150

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@269161 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Miklos Vajna 2016-05-11 08:08:07 +00:00
Родитель 2d7f243949
Коммит 8da84105a1
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -60,6 +60,11 @@ public:
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.

Просмотреть файл

@ -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.