Index: clang-rename/USRLocFinder.cpp =================================================================== --- clang-rename/USRLocFinder.cpp +++ clang-rename/USRLocFinder.cpp @@ -45,6 +45,18 @@ return true; } + bool VisitVarDecl(clang::VarDecl *Decl) { + clang::QualType Type = Decl->getType(); + const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl(); + if (RecordDecl) { + if (getUSRForDecl(RecordDecl) == USR) { + // The declaration refers to a type that is to be renamed. + LocationsFound.push_back(Decl->getTypeSpecStartLoc()); + } + } + return true; + } + // Expression visitors: bool VisitDeclRefExpr(const DeclRefExpr *Expr) { Index: test/clang-rename/ClassTest.cpp =================================================================== --- /dev/null +++ test/clang-rename/ClassTest.cpp @@ -0,0 +1,15 @@ +class Cla // CHECK: class Hector +{ +}; +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + +int main() +{ + Cla *Pointer = 0; // CHECK: Hector *Pointer = 0; + return 0; +} + +// Use grep -FUbo 'Cla' to get the correct offset of Cla when changing +// this file.