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.
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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits