[clang-tools-extra] r268484 - When renaming a class, ename pointers to that class as well.
Manuel Klimek via cfe-commits
cfe-commits at lists.llvm.org
Wed May 4 02:45:44 PDT 2016
Author: klimek
Date: Wed May 4 04:45:44 2016
New Revision: 268484
URL: http://llvm.org/viewvc/llvm-project?rev=268484&view=rev
Log:
When renaming a class, ename pointers to that class as well.
Patch by Miklos Vajna.
Added:
clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=268484&r1=268483&r2=268484&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed May 4 04:45:44 2016
@@ -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) {
Added: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp?rev=268484&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp Wed May 4 04:45:44 2016
@@ -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.
More information about the cfe-commits
mailing list