[clang-tools-extra] r272574 - clang-rename: implement handling of remaining named casts
Miklos Vajna via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 11:50:45 PDT 2016
Author: vmiklos
Date: Mon Jun 13 13:50:45 2016
New Revision: 272574
URL: http://llvm.org/viewvc/llvm-project?rev=272574&view=rev
Log:
clang-rename: implement handling of remaining named casts
const_cast<> and reinterpret_cast<>.
Reviewers: klimek
Differential Revision: http://reviews.llvm.org/D21270
Added:
clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp
clang-tools-extra/trunk/test/clang-rename/ReinterpretCastExpr.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=272574&r1=272573&r2=272574&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Mon Jun 13 13:50:45 2016
@@ -131,6 +131,14 @@ public:
return handleCXXNamedCastExpr(Expr);
}
+ bool VisitCXXReinterpretCastExpr(clang::CXXReinterpretCastExpr *Expr) {
+ return handleCXXNamedCastExpr(Expr);
+ }
+
+ bool VisitCXXConstCastExpr(clang::CXXConstCastExpr *Expr) {
+ return handleCXXNamedCastExpr(Expr);
+ }
+
// Non-visitors:
// \brief Returns a list of unique locations. Duplicate or overlapping
Added: clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp?rev=272574&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp Mon Jun 13 13:50:45 2016
@@ -0,0 +1,17 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla {
+public:
+ int getValue() {
+ return 0;
+ }
+};
+
+int main() {
+ const Cla *C = new Cla();
+ const_cast<Cla *>(C)->getValue(); // CHECK: const_cast<X *>
+}
+
+// Use grep -FUbo 'Cla' <file> to get the correct offset of foo when changing
+// this file.
Added: clang-tools-extra/trunk/test/clang-rename/ReinterpretCastExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ReinterpretCastExpr.cpp?rev=272574&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-rename/ReinterpretCastExpr.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ReinterpretCastExpr.cpp Mon Jun 13 13:50:45 2016
@@ -0,0 +1,17 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla {
+public:
+ int getValue() const {
+ return 0;
+ }
+};
+
+int main() {
+ void *C = new Cla();
+ reinterpret_cast<const Cla *>(C)->getValue(); // CHECK: reinterpret_cast<const X *>
+}
+
+// Use grep -FUbo 'Cla' <file> to get the correct offset of foo when changing
+// this file.
More information about the cfe-commits
mailing list