vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

The second "CHECK:" failed in the testcase without the code change.

http://reviews.llvm.org/D19905

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/ClassTest.cpp

Index: test/clang-rename/ClassTest.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/ClassTest.cpp
@@ -0,0 +1,15 @@
+class Cla  // CHECK: class Hector
+{
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+int main()
+{
+    Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+    return 0;
+}
+
+// Use grep -FUbo 'Cla' <file> to get the correct offset of Cla when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===================================================================
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -45,6 +45,18 @@
     return true;
   }
 
+  bool VisitVarDecl(clang::VarDecl *Decl) {
+    clang::QualType Type = Decl->getType();
+    const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl();
+    if (RecordDecl) {
+      if (getUSRForDecl(RecordDecl) == USR) {
+        // The declaration refers to a type that is to be renamed.
+        LocationsFound.push_back(Decl->getTypeSpecStartLoc());
+      }
+    }
+    return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {


Index: test/clang-rename/ClassTest.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/ClassTest.cpp
@@ -0,0 +1,15 @@
+class Cla  // CHECK: class Hector
+{
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+int main()
+{
+    Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+    return 0;
+}
+
+// Use grep -FUbo 'Cla' <file> to get the correct offset of Cla when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===================================================================
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -45,6 +45,18 @@
     return true;
   }
 
+  bool VisitVarDecl(clang::VarDecl *Decl) {
+    clang::QualType Type = Decl->getType();
+    const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl();
+    if (RecordDecl) {
+      if (getUSRForDecl(RecordDecl) == USR) {
+        // The declaration refers to a type that is to be renamed.
+        LocationsFound.push_back(Decl->getTypeSpecStartLoc());
+      }
+    }
+    return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to