This revision was automatically updated to reflect the committed changes. Closed by commit rL270204: clang-rename: fix renaming members when referenced as macro arguments (authored by vmiklos).
Changed prior to commit: http://reviews.llvm.org/D20446?vs=57921&id=57923#toc Repository: rL LLVM http://reviews.llvm.org/D20446 Files: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.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 @@ -103,7 +103,9 @@ bool VisitMemberExpr(const MemberExpr *Expr) { const auto *Decl = Expr->getFoundDecl().getDecl(); if (getUSRForDecl(Decl) == USR) { - LocationsFound.push_back(Expr->getMemberLoc()); + const SourceManager &Manager = Decl->getASTContext().getSourceManager(); + SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc()); + LocationsFound.push_back(Location); } return true; } Index: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp +++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp @@ -0,0 +1,25 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s +class C +{ +public: + int X; +}; + +int foo(int x) +{ + return 0; +} +#define FOO(a) foo(a) + +int main() +{ + C C; + C.X = 1; // CHECK: C.Y + FOO(C.X); // CHECK: C.Y + int y = C.X; // CHECK: C.Y +} + +// Use grep -FUbo 'C' <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 @@ -103,7 +103,9 @@ bool VisitMemberExpr(const MemberExpr *Expr) { const auto *Decl = Expr->getFoundDecl().getDecl(); if (getUSRForDecl(Decl) == USR) { - LocationsFound.push_back(Expr->getMemberLoc()); + const SourceManager &Manager = Decl->getASTContext().getSourceManager(); + SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc()); + LocationsFound.push_back(Location); } return true; } Index: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp +++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp @@ -0,0 +1,25 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s +class C +{ +public: + int X; +}; + +int foo(int x) +{ + return 0; +} +#define FOO(a) foo(a) + +int main() +{ + C C; + C.X = 1; // CHECK: C.Y + FOO(C.X); // CHECK: C.Y + int y = C.X; // CHECK: C.Y +} + +// Use grep -FUbo 'C' <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