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

The check failed, 'Cla *C = new Cla();' was renamed 'D *C = new Cla();'.

http://reviews.llvm.org/D20635

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

Index: test/clang-rename/ConstructExpr.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/ConstructExpr.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla
+{
+};
+
+int main()
+{
+  Cla *C = new Cla(); // CHECK: D *C = new D();
+}
+
+// Use grep -FUbo 'Cla' <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
@@ -112,6 +112,17 @@
     return true;
   }
 
+  bool VisitCXXConstructExpr(const CXXConstructExpr *Expr) {
+    CXXConstructorDecl *Decl = Expr->getConstructor();
+
+    if (getUSRForDecl(Decl) == USR) {
+      // This takes care of 'new <name>' expressions.
+      LocationsFound.push_back(Expr->getLocation());
+    }
+
+    return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping


Index: test/clang-rename/ConstructExpr.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/ConstructExpr.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla
+{
+};
+
+int main()
+{
+  Cla *C = new Cla(); // CHECK: D *C = new D();
+}
+
+// Use grep -FUbo 'Cla' <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
@@ -112,6 +112,17 @@
     return true;
   }
 
+  bool VisitCXXConstructExpr(const CXXConstructExpr *Expr) {
+    CXXConstructorDecl *Decl = Expr->getConstructor();
+
+    if (getUSRForDecl(Decl) == USR) {
+      // This takes care of 'new <name>' expressions.
+      LocationsFound.push_back(Expr->getLocation());
+    }
+
+    return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to