compilerplugins/clang/redundantfcast.cxx              |   35 ++++++++----------
 compilerplugins/clang/sharedvisitor/sharedvisitor.cxx |   30 +++++++++++++++
 2 files changed, 47 insertions(+), 18 deletions(-)

New commits:
commit 70c6651e02c4582d66d8e1c1286406c4f01a7d4b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jul 16 12:35:16 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jul 16 21:31:07 2019 +0200

    convert redundantfcast to LO_CLANG_SHARED_PLUGINS
    
    Change-Id: I8c1c990d91676b33f2fd508025acfa93a66f4950
    Reviewed-on: https://gerrit.libreoffice.org/75724
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/compilerplugins/clang/redundantfcast.cxx 
b/compilerplugins/clang/redundantfcast.cxx
index 43049700ee35..a53c42d73add 100644
--- a/compilerplugins/clang/redundantfcast.cxx
+++ b/compilerplugins/clang/redundantfcast.cxx
@@ -6,6 +6,7 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
+#ifndef LO_CLANG_SHARED_PLUGINS
 
 #include "check.hxx"
 #include "compat.hxx"
@@ -23,15 +24,6 @@ public:
     {
     }
 
-    bool TraverseFunctionDecl(FunctionDecl* functionDecl)
-    {
-        auto prev = m_CurrentFunctionDecl;
-        m_CurrentFunctionDecl = functionDecl;
-        auto rv = 
RecursiveASTVisitor<RedundantFCast>::TraverseFunctionDecl(functionDecl);
-        m_CurrentFunctionDecl = prev;
-        return rv;
-    }
-
     bool VisitReturnStmt(ReturnStmt const* returnStmt)
     {
         if (ignoreLocation(returnStmt))
@@ -206,25 +198,32 @@ public:
         return true;
     }
 
-private:
-    void run() override
+    bool preRun() override
     {
         if (!compiler.getLangOpts().CPlusPlus)
-            return;
+            return false;
         std::string fn = handler.getMainFileName();
         loplugin::normalizeDotDotInFilePath(fn);
         // necessary on some other platforms
         if (fn == SRCDIR "/sal/osl/unx/socket.cxx")
-            return;
+            return false;
         // compile-time check of constant
         if (fn == SRCDIR "/bridges/source/jni_uno/jni_bridge.cxx")
-            return;
-        TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+            return false;
+        return true;
+    }
+
+    void run() override
+    {
+        if (preRun())
+            TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
-    FunctionDecl const* m_CurrentFunctionDecl;
 };
 
-static loplugin::Plugin::Registration<RedundantFCast> reg("redundantfcast");
-}
+static loplugin::Plugin::Registration<RedundantFCast> 
redundantfcast("redundantfcast");
+
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx 
b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index d48343171646..714aa3fd589f 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -25,6 +25,7 @@
 #include "../inlinevisible.cxx"
 #include "../loopvartoosmall.cxx"
 #include "../privatebase.cxx"
+#include "../redundantfcast.cxx"
 #include "../redundantinline.cxx"
 #include "../redundantpointerops.cxx"
 #include "../reservedid.cxx"
@@ -77,6 +78,7 @@ public:
         , inlineVisible( nullptr )
         , loopVarTooSmall( nullptr )
         , privateBase( nullptr )
+        , redundantFCast( nullptr )
         , redundantInline( nullptr )
         , redundantPointerOps( nullptr )
         , reservedId( nullptr )
@@ -131,6 +133,8 @@ public:
             loopVarTooSmall = nullptr;
         if( privateBase && !privateBase->preRun())
             privateBase = nullptr;
+        if( redundantFCast && !redundantFCast->preRun())
+            redundantFCast = nullptr;
         if( redundantInline && !redundantInline->preRun())
             redundantInline = nullptr;
         if( redundantPointerOps && !redundantPointerOps->preRun())
@@ -209,6 +213,8 @@ public:
             loopVarTooSmall->postRun();
         if( privateBase )
             privateBase->postRun();
+        if( redundantFCast )
+            redundantFCast->postRun();
         if( redundantInline )
             redundantInline->postRun();
         if( redundantPointerOps )
@@ -293,6 +299,8 @@ public:
             loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin );
         else if( strcmp( name, "privatebase" ) == 0 )
             privateBase = static_cast< PrivateBase* >( plugin );
+        else if( strcmp( name, "redundantfcast" ) == 0 )
+            redundantFCast = static_cast< RedundantFCast* >( plugin );
         else if( strcmp( name, "redundantinline" ) == 0 )
             redundantInline = static_cast< RedundantInline* >( plugin );
         else if( strcmp( name, "redundantpointerops" ) == 0 )
@@ -446,6 +454,11 @@ public:
     {
         if( ignoreLocation( arg ))
             return true;
+        if( redundantFCast != nullptr )
+        {
+            if( !redundantFCast->VisitCXXConstructExpr( arg ))
+                redundantFCast = nullptr;
+        }
         if( simplifyConstruct != nullptr )
         {
             if( !simplifyConstruct->VisitCXXConstructExpr( arg ))
@@ -468,6 +481,11 @@ public:
     {
         if( ignoreLocation( arg ))
             return true;
+        if( redundantFCast != nullptr )
+        {
+            if( !redundantFCast->VisitCXXFunctionalCastExpr( arg ))
+                redundantFCast = nullptr;
+        }
         if( salUnicodeLiteral != nullptr )
         {
             if( !salUnicodeLiteral->VisitCXXFunctionalCastExpr( arg ))
@@ -586,6 +604,11 @@ public:
             if( !dbgUnhandledException->VisitCallExpr( arg ))
                 dbgUnhandledException = nullptr;
         }
+        if( redundantFCast != nullptr )
+        {
+            if( !redundantFCast->VisitCallExpr( arg ))
+                redundantFCast = nullptr;
+        }
         if( salLogAreas != nullptr )
         {
             if( !salLogAreas->VisitCallExpr( arg ))
@@ -815,6 +838,11 @@ public:
     {
         if( ignoreLocation( arg ))
             return true;
+        if( redundantFCast != nullptr )
+        {
+            if( !redundantFCast->VisitReturnStmt( arg ))
+                redundantFCast = nullptr;
+        }
         if( stringStatic != nullptr )
         {
             if( !stringStatic->VisitReturnStmt( arg ))
@@ -1061,6 +1089,7 @@ private:
             || inlineVisible != nullptr
             || loopVarTooSmall != nullptr
             || privateBase != nullptr
+            || redundantFCast != nullptr
             || redundantInline != nullptr
             || redundantPointerOps != nullptr
             || reservedId != nullptr
@@ -1099,6 +1128,7 @@ private:
     InlineVisible* inlineVisible;
     LoopVarTooSmall* loopVarTooSmall;
     PrivateBase* privateBase;
+    RedundantFCast* redundantFCast;
     RedundantInline* redundantInline;
     RedundantPointerOps* redundantPointerOps;
     ReservedId* reservedId;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to