summaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-06 09:12:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-06-06 09:12:25 +0200
commitfeb699d7a1dd037463254e0f24263e36d517f820 (patch)
tree1923292e909c381af53317842a5c459ab753f330 /clang
parent26667ea7490f9e21a859d33ca4efc87d328f8a1b (diff)
clang: handle dynamic_cast in rename
Refactor to do the same as what is done already for static_cast.
Diffstat (limited to 'clang')
-rw-r--r--clang/qa/data/rename-cxx-dynamic-cast-expr.cxx12
-rw-r--r--clang/qa/data/rename-cxx-dynamic-cast-expr.cxx.expected12
-rwxr-xr-xclang/qa/test-rename.sh4
-rw-r--r--clang/rename.cxx14
4 files changed, 41 insertions, 1 deletions
diff --git a/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx b/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx
new file mode 100644
index 00000000..753c44ea
--- /dev/null
+++ b/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx
@@ -0,0 +1,12 @@
+class C
+{
+public:
+ int getValue() const { return 0; }
+};
+
+int main()
+{
+ C* pC = new C();
+ dynamic_cast<const C&>(*pC).getValue();
+ dynamic_cast<const C*>(pC)->getValue();
+}
diff --git a/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx.expected b/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx.expected
new file mode 100644
index 00000000..4eb064a2
--- /dev/null
+++ b/clang/qa/data/rename-cxx-dynamic-cast-expr.cxx.expected
@@ -0,0 +1,12 @@
+class D
+{
+public:
+ int getValue() const { return 0; }
+};
+
+int main()
+{
+ D* pC = new D();
+ dynamic_cast<const D&>(*pC).getValue();
+ dynamic_cast<const D*>(pC)->getValue();
+}
diff --git a/clang/qa/test-rename.sh b/clang/qa/test-rename.sh
index 67557796..c18fd0aa 100755
--- a/clang/qa/test-rename.sh
+++ b/clang/qa/test-rename.sh
@@ -95,6 +95,10 @@ declare_rename_test "testCXXStaticCastExpr" "rename-cxx-static-cast-expr.cxx"
bin/rename -old-name=C -new-name=D $test_input --
test_assert_equal $test_expected $test_output
+declare_rename_test "testCXXDynamicCastExpr" "rename-cxx-dynamic-cast-expr.cxx"
+bin/rename -old-name=C -new-name=D $test_input --
+test_assert_equal $test_expected $test_output
+
declare_rename_test "testCXXDestructorDecl" "rename-cxx-destructor-decl.cxx"
bin/rename -old-name=C -new-name=D $test_input --
test_assert_equal $test_expected $test_output
diff --git a/clang/rename.cxx b/clang/rename.cxx
index 892e33ab..329aacdb 100644
--- a/clang/rename.cxx
+++ b/clang/rename.cxx
@@ -268,8 +268,10 @@ public:
*
* ... static_cast<const C&>(...) ...;
* ^ ... and this.
+ *
+ * ... and the same for dynamic_cast<>().
*/
- bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr* pExpr)
+ bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr* pExpr)
{
clang::QualType pType = pExpr->getType();
const clang::RecordDecl* pDecl = pType->getPointeeCXXRecordDecl();
@@ -283,6 +285,16 @@ public:
}
return true;
}
+
+ bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr* pExpr)
+ {
+ return handleCXXNamedCastExpr(pExpr);
+ }
+
+ bool VisitCXXDynamicCastExpr(clang::CXXDynamicCastExpr* pExpr)
+ {
+ return handleCXXNamedCastExpr(pExpr);
+ }
};
class RenameASTConsumer : public clang::ASTConsumer