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 ' 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' to get the correct offset of foo when changing +// this file.