When renaming a class, ename pointers to that class as well.

Patch by Miklos Vajna.

llvm-svn: 268484
This commit is contained in:
Manuel Klimek
2016-05-04 09:45:44 +00:00
parent 69fa1926db
commit 13e2c1a709
2 changed files with 27 additions and 0 deletions

View File

@@ -45,6 +45,18 @@ public:
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) {

View File

@@ -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' <file> to get the correct offset of Cla when changing
// this file.