diff options
author | Miklos Vajna <vmiklos@vmiklos.hu> | 2016-05-24 19:08:53 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@vmiklos.hu> | 2016-05-24 19:08:53 +0000 |
commit | 10e25748b0ae1e26ded232f22bd1596d3a64e11c (patch) | |
tree | 3bcd00a45a931c4b8c500870f9b48324d9b8b54e /clang-tools-extra | |
parent | c8bc8821cbf1419429f955af67a8f1c3413c3d0c (diff) | |
download | bcm5719-llvm-10e25748b0ae1e26ded232f22bd1596d3a64e11c.tar.gz bcm5719-llvm-10e25748b0ae1e26ded232f22bd1596d3a64e11c.zip |
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
Diffstat (limited to 'clang-tools-extra')
-rw-r--r-- | clang-tools-extra/clang-rename/USRLocFinder.cpp | 4 | ||||
-rw-r--r-- | clang-tools-extra/test/clang-rename/DeclRefExpr.cpp | 24 |
2 files changed, 27 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-rename/USRLocFinder.cpp b/clang-tools-extra/clang-rename/USRLocFinder.cpp index d7eb6305dcc..43e9524541b 100644 --- a/clang-tools-extra/clang-rename/USRLocFinder.cpp +++ b/clang-tools-extra/clang-rename/USRLocFinder.cpp @@ -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; diff --git a/clang-tools-extra/test/clang-rename/DeclRefExpr.cpp b/clang-tools-extra/test/clang-rename/DeclRefExpr.cpp new file mode 100644 index 00000000000..712173bcf93 --- /dev/null +++ b/clang-tools-extra/test/clang-rename/DeclRefExpr.cpp @@ -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. |