forked from OSchip/llvm-project
clang-rename: implement renaming of classes with a dtor
The declaration wasn't renamed. Also neither part of the declaration wasn't renamed. Reviewers: klimek Differential Revision: http://reviews.llvm.org/D21364 llvm-svn: 272816
This commit is contained in:
parent
41974f1e4d
commit
7712bf3f53
|
@ -87,6 +87,28 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VisitCXXDestructorDecl(clang::CXXDestructorDecl *DestructorDecl) {
|
||||
if (getUSRForDecl(DestructorDecl->getParent()) == USR) {
|
||||
// Handles "~Foo" from "Foo::~Foo".
|
||||
SourceLocation Location = DestructorDecl->getLocation();
|
||||
const ASTContext &Context = DestructorDecl->getASTContext();
|
||||
StringRef TokenName = Lexer::getSourceText(
|
||||
CharSourceRange::getTokenRange(Location), Context.getSourceManager(),
|
||||
Context.getLangOpts());
|
||||
// 1 is the length of the "~" string that is not to be touched by the
|
||||
// rename.
|
||||
assert(TokenName.startswith("~"));
|
||||
LocationsFound.push_back(Location.getLocWithOffset(1));
|
||||
|
||||
if (DestructorDecl->isThisDeclarationADefinition()) {
|
||||
// Handles "Foo" from "Foo::~Foo".
|
||||
LocationsFound.push_back(DestructorDecl->getLocStart());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Expression visitors:
|
||||
|
||||
bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// RUN: cat %s > %t.cpp
|
||||
// RUN: clang-rename -offset=135 -new-name=Bar %t.cpp -i --
|
||||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
|
||||
class Foo {
|
||||
public:
|
||||
Foo();
|
||||
~Foo(); // CHECK: ~Bar();
|
||||
};
|
||||
|
||||
Foo::Foo() {
|
||||
}
|
||||
|
||||
Foo::~Foo() { // CHECK: Bar::~Bar()
|
||||
}
|
||||
|
||||
// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing
|
||||
// this file.
|
Loading…
Reference in New Issue