Index: clang-rename/USRLocFinder.cpp =================================================================== --- clang-rename/USRLocFinder.cpp +++ clang-rename/USRLocFinder.cpp @@ -161,6 +161,22 @@ return handleCXXNamedCastExpr(Expr); } + bool VisitCXXMethodDecl(CXXMethodDecl *Decl) { + if (getUSRForDecl(Decl) == USR) { + // This member function was requested to be renamed explicitly. + LocationsFound.push_back(Decl->getLocation()); + } else if (Decl->isVirtual()) { + for (auto *OverridenDecl : Decl->overridden_methods()) { + if (getUSRForDecl(OverridenDecl) == USR) { + // This member function overwrites one that is to be renamed. + LocationsFound.push_back(Decl->getLocation()); + } + } + } + + return true; + } + // Non-visitors: // \brief Returns a list of unique locations. Duplicate or overlapping Index: test/clang-rename/VirtualFunction.cpp =================================================================== --- /dev/null +++ test/clang-rename/VirtualFunction.cpp @@ -0,0 +1,16 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + +class A { +public: + virtual void foo(); // CHECK: virtual void boo(); +}; + +class B : public A { +public: + void foo(); // CHECK: void boo(); +}; + +// Use grep -FUbo 'foo' to get the correct offset of foo when changing +// this file.