vmiklos updated this revision to Diff 60801. vmiklos added a comment. Now the correct patch. :-)
http://reviews.llvm.org/D21364 Files: clang-rename/USRLocFinder.cpp test/clang-rename/DtorDefTest.cpp Index: test/clang-rename/DtorDefTest.cpp =================================================================== --- /dev/null +++ test/clang-rename/DtorDefTest.cpp @@ -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. Index: clang-rename/USRLocFinder.cpp =================================================================== --- clang-rename/USRLocFinder.cpp +++ clang-rename/USRLocFinder.cpp @@ -87,6 +87,20 @@ return true; } + bool VisitCXXDestructorDecl(clang::CXXDestructorDecl *DestructorDecl) { + if (getUSRForDecl(DestructorDecl->getParent()) == USR) { + // Handles "~Foo" from "Foo::~Foo". 1 is the length of the "~" string + // that is not to be touched by the rename. + LocationsFound.push_back(DestructorDecl->getLocation().getLocWithOffset(1)); + if (DestructorDecl->isThisDeclarationADefinition()) { + // Handles "Foo" from "Foo::~Foo". + LocationsFound.push_back(DestructorDecl->getLocStart()); + } + } + + return true; + } + // Expression visitors: bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
Index: test/clang-rename/DtorDefTest.cpp =================================================================== --- /dev/null +++ test/clang-rename/DtorDefTest.cpp @@ -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. Index: clang-rename/USRLocFinder.cpp =================================================================== --- clang-rename/USRLocFinder.cpp +++ clang-rename/USRLocFinder.cpp @@ -87,6 +87,20 @@ return true; } + bool VisitCXXDestructorDecl(clang::CXXDestructorDecl *DestructorDecl) { + if (getUSRForDecl(DestructorDecl->getParent()) == USR) { + // Handles "~Foo" from "Foo::~Foo". 1 is the length of the "~" string + // that is not to be touched by the rename. + LocationsFound.push_back(DestructorDecl->getLocation().getLocWithOffset(1)); + if (DestructorDecl->isThisDeclarationADefinition()) { + // Handles "Foo" from "Foo::~Foo". + LocationsFound.push_back(DestructorDecl->getLocStart()); + } + } + + return true; + } + // Expression visitors: bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits