[PATCH] D20635: clang-rename: fix renaming heap allocations

Miklos Vajna via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 13:06:56 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL271572: clang-rename: fix renaming heap allocations (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20635?vs=58467&id=59447#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20635

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/ConstructExpr.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
@@ -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: clang-tools-extra/trunk/test/clang-rename/ConstructExpr.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/ConstructExpr.cpp
+++ clang-tools-extra/trunk/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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20635.59447.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160602/d1869bee/attachment.bin>


More information about the cfe-commits mailing list