[Libreoffice-commits] dev-tools.git: clang/qa clang/rename.cxx

Miklos Vajna vmiklos at collabora.co.uk
Mon Jun 6 07:13:14 UTC 2016


 clang/qa/data/rename-cxx-dynamic-cast-expr.cxx          |   12 ++++++++++++
 clang/qa/data/rename-cxx-dynamic-cast-expr.cxx.expected |   12 ++++++++++++
 clang/qa/test-rename.sh                                 |    4 ++++
 clang/rename.cxx                                        |   14 +++++++++++++-
 4 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit feb699d7a1dd037463254e0f24263e36d517f820
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jun 6 09:12:25 2016 +0200

    clang: handle dynamic_cast in rename
    
    Refactor to do the same as what is done already for static_cast.

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 0000000..753c44e
--- /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 0000000..4eb064a
--- /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 6755779..c18fd0a 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 892e33a..329aacd 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


More information about the Libreoffice-commits mailing list