clang-rename: fix renaming non-members variables when referenced as macro arguments

The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).

Reviewers: klimek

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

llvm-svn: 270599
This commit is contained in:
Miklos Vajna 2016-05-24 19:08:53 +00:00
parent c8bc8821cb
commit 10e25748b0
2 changed files with 27 additions and 1 deletions

View File

@ -94,7 +94,9 @@ public:
checkNestedNameSpecifierLoc(Expr->getQualifierLoc());
if (getUSRForDecl(Decl) == USR) {
LocationsFound.push_back(Expr->getLocation());
const SourceManager &Manager = Decl->getASTContext().getSourceManager();
SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
LocationsFound.push_back(Location);
}
return true;

View File

@ -0,0 +1,24 @@
// RUN: cat %s > %t.cpp
// RUN: clang-rename -offset=158 -new-name=Y %t.cpp -i --
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
class C
{
public:
static int X;
};
int foo(int x)
{
return 0;
}
#define FOO(a) foo(a)
int main()
{
C::X = 1; // CHECK: C::Y
FOO(C::X); // CHECK: C::Y
int y = C::X; // CHECK: C::Y
}
// Use grep -FUbo 'X' <file> to get the correct offset of foo when changing
// this file.