[PATCH] D20537: clang-rename: fix renaming non-members variables when referenced as macro arguments
Miklos Vajna via cfe-commits
cfe-commits at lists.llvm.org
Mon May 23 12:49:50 PDT 2016
vmiklos created this revision.
vmiklos added reviewers: klimek, cfe-commits.
The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).
http://reviews.llvm.org/D20537
Files:
clang-rename/USRLocFinder.cpp
test/clang-rename/DeclRefExpr.cpp
Index: test/clang-rename/DeclRefExpr.cpp
===================================================================
--- /dev/null
+++ 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.
Index: clang-rename/USRLocFinder.cpp
===================================================================
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -94,7 +94,9 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20537.58136.patch
Type: text/x-patch
Size: 1186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160523/c1d94946/attachment.bin>
More information about the cfe-commits
mailing list