clang-rename: fix renaming heap allocations

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

Reviewers: klimek

Differential Revision: http://reviews.llvm.org/D20635

llvm-svn: 271572
This commit is contained in:
Miklos Vajna 2016-06-02 20:00:22 +00:00
parent d1097a38e2
commit 617409f0c0
2 changed files with 25 additions and 0 deletions

View File

@ -112,6 +112,17 @@ public:
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

View File

@ -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.