This revision was automatically updated to reflect the committed changes.
Closed by commit rL270599: clang-rename: fix renaming non-members variables 
when referenced as macro… (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20537?vs=58136&id=58290#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20537

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp

Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/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-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/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;


Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
+++ clang-tools-extra/trunk/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-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to