forked from OSchip/llvm-project
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:
parent
d1097a38e2
commit
617409f0c0
|
@ -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
|
||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue