[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang sw/qa

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 16 07:15:33 UTC 2019


 compilerplugins/clang/salunicodeliteral.cxx           |   22 -
 compilerplugins/clang/sfxpoolitem.cxx                 |    7 
 compilerplugins/clang/sharedvisitor/sharedvisitor.cxx |  267 ++++++++++++++++++
 compilerplugins/clang/staticaccess.cxx                |    8 
 compilerplugins/clang/staticanonymous.cxx             |   10 
 compilerplugins/clang/stringconcat.cxx                |    8 
 compilerplugins/clang/typedefparam.cxx                |   11 
 compilerplugins/clang/unicodetochar.cxx               |   52 ++-
 compilerplugins/clang/unnecessarycatchthrow.cxx       |    8 
 compilerplugins/clang/unoany.cxx                      |   17 +
 compilerplugins/clang/unoquery.cxx                    |   20 +
 compilerplugins/clang/weakbase.cxx                    |   19 +
 sw/qa/extras/rtfexport/data/page-border.rtf           |    4 
 sw/qa/extras/rtfexport/rtfexport4.cxx                 |   17 +
 14 files changed, 429 insertions(+), 41 deletions(-)

New commits:
commit 8d4fbc532e2058a906b06471501385404ff31541
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jul 16 08:13:59 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 16 09:15:01 2019 +0200

    convert some plugins to LO_CLANG_SHARED_PLUGINS
    
    Change-Id: I7451a95377101004c7c53c918f3234415e06f555
    Reviewed-on: https://gerrit.libreoffice.org/75670
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/salunicodeliteral.cxx b/compilerplugins/clang/salunicodeliteral.cxx
index bdf83694b77e..4c2a00669ab0 100644
--- a/compilerplugins/clang/salunicodeliteral.cxx
+++ b/compilerplugins/clang/salunicodeliteral.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 "plugin.hxx"
@@ -41,16 +42,18 @@ public:
         return true;
     }
 
-private:
-    void run() override {
-        if (compiler.getLangOpts().CPlusPlus
+    bool preRun() override {
+        return compiler.getLangOpts().CPlusPlus
             && compiler.getPreprocessor().getIdentifierInfo(
-                "LIBO_INTERNAL_ONLY")->hasMacroDefinition())
-        {
+                "LIBO_INTERNAL_ONLY")->hasMacroDefinition();
+    }
+
+    void run() override {
+        if (preRun())
             TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
-        }
     }
 
+private:
     void check(ExplicitCastExpr const * expr) {
         if (ignoreLocation(expr)
             || isInUnoIncludeFile(expr->getExprLoc()))
@@ -90,9 +93,10 @@ private:
     }
 };
 
-static loplugin::Plugin::Registration<SalUnicodeLiteral> reg(
-    "salunicodeliteral");
+static loplugin::Plugin::Registration<SalUnicodeLiteral> salunicodeliteral("salunicodeliteral");
 
-}
+} // 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/sfxpoolitem.cxx b/compilerplugins/clang/sfxpoolitem.cxx
index bd2870fe06d3..ce52336c8e04 100644
--- a/compilerplugins/clang/sfxpoolitem.cxx
+++ b/compilerplugins/clang/sfxpoolitem.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 <string>
 #include <iostream>
@@ -124,8 +125,10 @@ bool SfxPoolItem::VisitCXXRecordDecl(const CXXRecordDecl* decl)
 }
 
 
-loplugin::Plugin::Registration< SfxPoolItem > X("sfxpoolitem");
+loplugin::Plugin::Registration< SfxPoolItem > sfxpoolitem("sfxpoolitem");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index a6df13ca33b4..4532bbe250ca 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -26,13 +26,24 @@
 #include "../loopvartoosmall.cxx"
 #include "../privatebase.cxx"
 #include "../reservedid.cxx"
+#include "../salunicodeliteral.cxx"
+#include "../sfxpoolitem.cxx"
 #include "../simplifyconstruct.cxx"
+#include "../staticaccess.cxx"
+#include "../staticanonymous.cxx"
+#include "../stringconcat.cxx"
 #include "../stringstatic.cxx"
 #include "../subtlezeroinit.cxx"
+#include "../typedefparam.cxx"
+#include "../unicodetochar.cxx"
+#include "../unnecessarycatchthrow.cxx"
 #include "../unnecessaryoverride.cxx"
 #include "../unnecessaryparen.cxx"
+#include "../unoany.cxx"
+#include "../unoquery.cxx"
 #include "../unreffun.cxx"
 #include "../unusedvariablecheck.cxx"
+#include "../weakbase.cxx"
 #include "../weakobject.cxx"
 #include "../dyncastvisibility.cxx"
 #include "../vclwidgets.cxx"
@@ -64,13 +75,24 @@ public:
         , loopVarTooSmall( nullptr )
         , privateBase( nullptr )
         , reservedId( nullptr )
+        , salUnicodeLiteral( nullptr )
+        , sfxPoolItem( nullptr )
         , simplifyConstruct( nullptr )
+        , staticAccess( nullptr )
+        , staticAnonymous( nullptr )
+        , stringConcat( nullptr )
         , stringStatic( nullptr )
         , subtleZeroInit( nullptr )
+        , typedefParam( nullptr )
+        , unicodeToChar( nullptr )
+        , unnecessaryCatchThrow( nullptr )
         , unnecessaryOverride( nullptr )
         , unnecessaryParen( nullptr )
+        , unoAny( nullptr )
+        , unoQuery( nullptr )
         , unrefFun( nullptr )
         , unusedVariableCheck( nullptr )
+        , weakBase( nullptr )
         , weakObject( nullptr )
         {}
     virtual bool preRun() override
@@ -105,20 +127,42 @@ public:
             privateBase = nullptr;
         if( reservedId && !reservedId->preRun())
             reservedId = nullptr;
+        if( salUnicodeLiteral && !salUnicodeLiteral->preRun())
+            salUnicodeLiteral = nullptr;
+        if( sfxPoolItem && !sfxPoolItem->preRun())
+            sfxPoolItem = nullptr;
         if( simplifyConstruct && !simplifyConstruct->preRun())
             simplifyConstruct = nullptr;
+        if( staticAccess && !staticAccess->preRun())
+            staticAccess = nullptr;
+        if( staticAnonymous && !staticAnonymous->preRun())
+            staticAnonymous = nullptr;
+        if( stringConcat && !stringConcat->preRun())
+            stringConcat = nullptr;
         if( stringStatic && !stringStatic->preRun())
             stringStatic = nullptr;
         if( subtleZeroInit && !subtleZeroInit->preRun())
             subtleZeroInit = nullptr;
+        if( typedefParam && !typedefParam->preRun())
+            typedefParam = nullptr;
+        if( unicodeToChar && !unicodeToChar->preRun())
+            unicodeToChar = nullptr;
+        if( unnecessaryCatchThrow && !unnecessaryCatchThrow->preRun())
+            unnecessaryCatchThrow = nullptr;
         if( unnecessaryOverride && !unnecessaryOverride->preRun())
             unnecessaryOverride = nullptr;
         if( unnecessaryParen && !unnecessaryParen->preRun())
             unnecessaryParen = nullptr;
+        if( unoAny && !unoAny->preRun())
+            unoAny = nullptr;
+        if( unoQuery && !unoQuery->preRun())
+            unoQuery = nullptr;
         if( unrefFun && !unrefFun->preRun())
             unrefFun = nullptr;
         if( unusedVariableCheck && !unusedVariableCheck->preRun())
             unusedVariableCheck = nullptr;
+        if( weakBase && !weakBase->preRun())
+            weakBase = nullptr;
         if( weakObject && !weakObject->preRun())
             weakObject = nullptr;
         return anyPluginActive();
@@ -155,20 +199,42 @@ public:
             privateBase->postRun();
         if( reservedId )
             reservedId->postRun();
+        if( salUnicodeLiteral )
+            salUnicodeLiteral->postRun();
+        if( sfxPoolItem )
+            sfxPoolItem->postRun();
         if( simplifyConstruct )
             simplifyConstruct->postRun();
+        if( staticAccess )
+            staticAccess->postRun();
+        if( staticAnonymous )
+            staticAnonymous->postRun();
+        if( stringConcat )
+            stringConcat->postRun();
         if( stringStatic )
             stringStatic->postRun();
         if( subtleZeroInit )
             subtleZeroInit->postRun();
+        if( typedefParam )
+            typedefParam->postRun();
+        if( unicodeToChar )
+            unicodeToChar->postRun();
+        if( unnecessaryCatchThrow )
+            unnecessaryCatchThrow->postRun();
         if( unnecessaryOverride )
             unnecessaryOverride->postRun();
         if( unnecessaryParen )
             unnecessaryParen->postRun();
+        if( unoAny )
+            unoAny->postRun();
+        if( unoQuery )
+            unoQuery->postRun();
         if( unrefFun )
             unrefFun->postRun();
         if( unusedVariableCheck )
             unusedVariableCheck->postRun();
+        if( weakBase )
+            weakBase->postRun();
         if( weakObject )
             weakObject->postRun();
     }
@@ -211,20 +277,42 @@ public:
             privateBase = static_cast< PrivateBase* >( plugin );
         else if( strcmp( name, "reservedid" ) == 0 )
             reservedId = static_cast< ReservedId* >( plugin );
+        else if( strcmp( name, "salunicodeliteral" ) == 0 )
+            salUnicodeLiteral = static_cast< SalUnicodeLiteral* >( plugin );
+        else if( strcmp( name, "sfxpoolitem" ) == 0 )
+            sfxPoolItem = static_cast< SfxPoolItem* >( plugin );
         else if( strcmp( name, "simplifyconstruct" ) == 0 )
             simplifyConstruct = static_cast< SimplifyConstruct* >( plugin );
+        else if( strcmp( name, "staticaccess" ) == 0 )
+            staticAccess = static_cast< StaticAccess* >( plugin );
+        else if( strcmp( name, "staticanonymous" ) == 0 )
+            staticAnonymous = static_cast< StaticAnonymous* >( plugin );
+        else if( strcmp( name, "stringconcat" ) == 0 )
+            stringConcat = static_cast< StringConcat* >( plugin );
         else if( strcmp( name, "stringstatic" ) == 0 )
             stringStatic = static_cast< StringStatic* >( plugin );
         else if( strcmp( name, "subtlezeroinit" ) == 0 )
             subtleZeroInit = static_cast< SubtleZeroInit* >( plugin );
+        else if( strcmp( name, "typedefparam" ) == 0 )
+            typedefParam = static_cast< TypedefParam* >( plugin );
+        else if( strcmp( name, "unicodetochar" ) == 0 )
+            unicodeToChar = static_cast< UnicodeToChar* >( plugin );
+        else if( strcmp( name, "unnecessarycatchthrow" ) == 0 )
+            unnecessaryCatchThrow = static_cast< UnnecessaryCatchThrow* >( plugin );
         else if( strcmp( name, "unnecessaryoverride" ) == 0 )
             unnecessaryOverride = static_cast< UnnecessaryOverride* >( plugin );
         else if( strcmp( name, "unnecessaryparen" ) == 0 )
             unnecessaryParen = static_cast< UnnecessaryParen* >( plugin );
+        else if( strcmp( name, "unoany" ) == 0 )
+            unoAny = static_cast< UnoAny* >( plugin );
+        else if( strcmp( name, "unoquery" ) == 0 )
+            unoQuery = static_cast< UnoQuery* >( plugin );
         else if( strcmp( name, "unreffun" ) == 0 )
             unrefFun = static_cast< UnrefFun* >( plugin );
         else if( strcmp( name, "unusedvariablecheck" ) == 0 )
             unusedVariableCheck = static_cast< UnusedVariableCheck* >( plugin );
+        else if( strcmp( name, "weakbase" ) == 0 )
+            weakBase = static_cast< WeakBase* >( plugin );
         else if( strcmp( name, "weakobject" ) == 0 )
             weakObject = static_cast< WeakObject* >( plugin );
         else
@@ -319,6 +407,17 @@ public:
         }
         return anyPluginActive();
     }
+    bool VisitCStyleCastExpr(const class clang::CStyleCastExpr * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( salUnicodeLiteral != nullptr )
+        {
+            if( !salUnicodeLiteral->VisitCStyleCastExpr( arg ))
+                salUnicodeLiteral = nullptr;
+        }
+        return anyPluginActive();
+    }
     bool VisitCXXConstructExpr(const class clang::CXXConstructExpr * arg)
     {
         if( ignoreLocation( arg ))
@@ -341,10 +440,37 @@ public:
         }
         return anyPluginActive();
     }
+    bool VisitCXXFunctionalCastExpr(const class clang::CXXFunctionalCastExpr * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( salUnicodeLiteral != nullptr )
+        {
+            if( !salUnicodeLiteral->VisitCXXFunctionalCastExpr( arg ))
+                salUnicodeLiteral = nullptr;
+        }
+        return anyPluginActive();
+    }
+    bool VisitCXXMemberCallExpr(const class clang::CXXMemberCallExpr * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( unoQuery != nullptr )
+        {
+            if( !unoQuery->VisitCXXMemberCallExpr( arg ))
+                unoQuery = nullptr;
+        }
+        return anyPluginActive();
+    }
     bool VisitCXXMethodDecl(const class clang::CXXMethodDecl * arg)
     {
         if( ignoreLocation( arg ))
             return true;
+        if( typedefParam != nullptr )
+        {
+            if( !typedefParam->VisitCXXMethodDecl( arg ))
+                typedefParam = nullptr;
+        }
         if( unnecessaryOverride != nullptr )
         {
             if( !unnecessaryOverride->VisitCXXMethodDecl( arg ))
@@ -377,6 +503,11 @@ public:
             if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
                 unnecessaryParen = nullptr;
         }
+        if( unoAny != nullptr )
+        {
+            if( !unoAny->VisitCXXOperatorCallExpr( arg ))
+                unoAny = nullptr;
+        }
         return anyPluginActive();
     }
     bool VisitCXXRecordDecl(const class clang::CXXRecordDecl * arg)
@@ -388,6 +519,38 @@ public:
             if( !privateBase->VisitCXXRecordDecl( arg ))
                 privateBase = nullptr;
         }
+        if( sfxPoolItem != nullptr )
+        {
+            if( !sfxPoolItem->VisitCXXRecordDecl( arg ))
+                sfxPoolItem = nullptr;
+        }
+        if( weakBase != nullptr )
+        {
+            if( !weakBase->VisitCXXRecordDecl( arg ))
+                weakBase = nullptr;
+        }
+        return anyPluginActive();
+    }
+    bool VisitCXXStaticCastExpr(const class clang::CXXStaticCastExpr * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( salUnicodeLiteral != nullptr )
+        {
+            if( !salUnicodeLiteral->VisitCXXStaticCastExpr( arg ))
+                salUnicodeLiteral = nullptr;
+        }
+        return anyPluginActive();
+    }
+    bool VisitCXXTryStmt(const class clang::CXXTryStmt * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( unnecessaryCatchThrow != nullptr )
+        {
+            if( !unnecessaryCatchThrow->VisitCXXTryStmt( arg ))
+                unnecessaryCatchThrow = nullptr;
+        }
         return anyPluginActive();
     }
     bool VisitCallExpr(const class clang::CallExpr * arg)
@@ -399,6 +562,11 @@ public:
             if( !dbgUnhandledException->VisitCallExpr( arg ))
                 dbgUnhandledException = nullptr;
         }
+        if( stringConcat != nullptr )
+        {
+            if( !stringConcat->VisitCallExpr( arg ))
+                stringConcat = nullptr;
+        }
         if( unnecessaryParen != nullptr )
         {
             if( !unnecessaryParen->VisitCallExpr( arg ))
@@ -501,6 +669,16 @@ public:
             if( !inlineVisible->VisitFunctionDecl( arg ))
                 inlineVisible = nullptr;
         }
+        if( staticAnonymous != nullptr )
+        {
+            if( !staticAnonymous->VisitFunctionDecl( arg ))
+                staticAnonymous = nullptr;
+        }
+        if( typedefParam != nullptr )
+        {
+            if( !typedefParam->VisitFunctionDecl( arg ))
+                typedefParam = nullptr;
+        }
         if( unrefFun != nullptr )
         {
             if( !unrefFun->VisitFunctionDecl( arg ))
@@ -524,6 +702,17 @@ public:
         }
         return anyPluginActive();
     }
+    bool VisitImplicitCastExpr(const class clang::ImplicitCastExpr * arg)
+    {
+        if( ignoreLocation( arg ))
+            return true;
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->VisitImplicitCastExpr( arg ))
+                unicodeToChar = nullptr;
+        }
+        return anyPluginActive();
+    }
     bool VisitMaterializeTemporaryExpr(const class clang::MaterializeTemporaryExpr * arg)
     {
         if( ignoreLocation( arg ))
@@ -539,6 +728,11 @@ public:
     {
         if( ignoreLocation( arg ))
             return true;
+        if( staticAccess != nullptr )
+        {
+            if( !staticAccess->VisitMemberExpr( arg ))
+                staticAccess = nullptr;
+        }
         if( unnecessaryParen != nullptr )
         {
             if( !unnecessaryParen->VisitMemberExpr( arg ))
@@ -669,6 +863,23 @@ public:
         }
         return anyPluginActive();
     }
+    bool TraverseCStyleCastExpr(class clang::CStyleCastExpr * arg)
+    {
+        UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PreTraverseCStyleCastExpr( arg ))
+                unicodeToChar = nullptr;
+        }
+        bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr( arg );
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PostTraverseCStyleCastExpr( arg, ret ))
+                saveUnicodeToChar = nullptr;
+        }
+        unicodeToChar = saveUnicodeToChar;
+        return ret;
+    }
     bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr * arg)
     {
         SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
@@ -698,6 +909,40 @@ public:
         dbgUnhandledException = saveDbgUnhandledException;
         return ret;
     }
+    bool TraverseCXXFunctionalCastExpr(class clang::CXXFunctionalCastExpr * arg)
+    {
+        UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PreTraverseCXXFunctionalCastExpr( arg ))
+                unicodeToChar = nullptr;
+        }
+        bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr( arg );
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PostTraverseCXXFunctionalCastExpr( arg, ret ))
+                saveUnicodeToChar = nullptr;
+        }
+        unicodeToChar = saveUnicodeToChar;
+        return ret;
+    }
+    bool TraverseCXXStaticCastExpr(class clang::CXXStaticCastExpr * arg)
+    {
+        UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PreTraverseCXXStaticCastExpr( arg ))
+                unicodeToChar = nullptr;
+        }
+        bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr( arg );
+        if( unicodeToChar != nullptr )
+        {
+            if( !unicodeToChar->PostTraverseCXXStaticCastExpr( arg, ret ))
+                saveUnicodeToChar = nullptr;
+        }
+        unicodeToChar = saveUnicodeToChar;
+        return ret;
+    }
     bool TraverseFriendDecl(class clang::FriendDecl * arg)
     {
         UnrefFun* saveUnrefFun = unrefFun;
@@ -757,13 +1002,24 @@ private:
             || loopVarTooSmall != nullptr
             || privateBase != nullptr
             || reservedId != nullptr
+            || salUnicodeLiteral != nullptr
+            || sfxPoolItem != nullptr
             || simplifyConstruct != nullptr
+            || staticAccess != nullptr
+            || staticAnonymous != nullptr
+            || stringConcat != nullptr
             || stringStatic != nullptr
             || subtleZeroInit != nullptr
+            || typedefParam != nullptr
+            || unicodeToChar != nullptr
+            || unnecessaryCatchThrow != nullptr
             || unnecessaryOverride != nullptr
             || unnecessaryParen != nullptr
+            || unoAny != nullptr
+            || unoQuery != nullptr
             || unrefFun != nullptr
             || unusedVariableCheck != nullptr
+            || weakBase != nullptr
             || weakObject != nullptr;
     }
     BadStatics* badStatics;
@@ -781,13 +1037,24 @@ private:
     LoopVarTooSmall* loopVarTooSmall;
     PrivateBase* privateBase;
     ReservedId* reservedId;
+    SalUnicodeLiteral* salUnicodeLiteral;
+    SfxPoolItem* sfxPoolItem;
     SimplifyConstruct* simplifyConstruct;
+    StaticAccess* staticAccess;
+    StaticAnonymous* staticAnonymous;
+    StringConcat* stringConcat;
     StringStatic* stringStatic;
     SubtleZeroInit* subtleZeroInit;
+    TypedefParam* typedefParam;
+    UnicodeToChar* unicodeToChar;
+    UnnecessaryCatchThrow* unnecessaryCatchThrow;
     UnnecessaryOverride* unnecessaryOverride;
     UnnecessaryParen* unnecessaryParen;
+    UnoAny* unoAny;
+    UnoQuery* unoQuery;
     UnrefFun* unrefFun;
     UnusedVariableCheck* unusedVariableCheck;
+    WeakBase* weakBase;
     WeakObject* weakObject;
 };
 
diff --git a/compilerplugins/clang/staticaccess.cxx b/compilerplugins/clang/staticaccess.cxx
index 6b15bfb15349..9c1abbc5cba4 100644
--- a/compilerplugins/clang/staticaccess.cxx
+++ b/compilerplugins/clang/staticaccess.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <cassert>
 
 #include "plugin.hxx"
@@ -89,8 +91,10 @@ bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) {
     return true;
 }
 
-loplugin::Plugin::Registration<StaticAccess> X("staticaccess");
+loplugin::Plugin::Registration<StaticAccess> staticaccess("staticaccess");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/staticanonymous.cxx b/compilerplugins/clang/staticanonymous.cxx
index f31499af6f73..0fd00f2279e7 100644
--- a/compilerplugins/clang/staticanonymous.cxx
+++ b/compilerplugins/clang/staticanonymous.cxx
@@ -5,6 +5,8 @@
  * Based on LLVM/Clang.
  *
  */
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include "plugin.hxx"
 
 /*
@@ -22,7 +24,7 @@ class StaticAnonymous
     public:
         explicit StaticAnonymous( const InstantiationData& data );
         virtual void run() override;
-        bool VisitFunctionDecl( FunctionDecl* func );
+        bool VisitFunctionDecl( const FunctionDecl* func );
 
     };
 
@@ -37,7 +39,7 @@ void StaticAnonymous::run()
     }
 
 
-bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
+bool StaticAnonymous::VisitFunctionDecl( const FunctionDecl* func )
 
     {
     if( ignoreLocation( func ) )
@@ -59,8 +61,10 @@ bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
     }
 
 // Register the plugin action with the LO plugin handling.
-static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true);
+static Plugin::Registration< StaticAnonymous > staticanonymous("staticanonymous");
 
 } // namespace
 
+#endif // LO_CLANG_SHARED_PLUGINS
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/stringconcat.cxx b/compilerplugins/clang/stringconcat.cxx
index da4b212e9f73..8511f849d64f 100644
--- a/compilerplugins/clang/stringconcat.cxx
+++ b/compilerplugins/clang/stringconcat.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include "plugin.hxx"
 #include "check.hxx"
 
@@ -151,8 +153,10 @@ bool StringConcat::isStringLiteral(Expr const * expr) {
             != "OSL_THIS_FUNC");
 }
 
-loplugin::Plugin::Registration<StringConcat> X("stringconcat");
+loplugin::Plugin::Registration<StringConcat> stringconcat("stringconcat");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/typedefparam.cxx b/compilerplugins/clang/typedefparam.cxx
index 0b7a74ba1696..2c7031ff7af0 100644
--- a/compilerplugins/clang/typedefparam.cxx
+++ b/compilerplugins/clang/typedefparam.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <cassert>
 #include <string>
 #include <iostream>
@@ -31,7 +33,7 @@ public:
     {
     }
 
-    virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+    void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
 
     bool VisitFunctionDecl(FunctionDecl const*);
     bool VisitCXXMethodDecl(CXXMethodDecl const*);
@@ -321,7 +323,10 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
     return lhsType == rhsType;
 }
 
-loplugin::Plugin::Registration<TypedefParam> X("typedefparam", true);
-}
+loplugin::Plugin::Registration<TypedefParam> typedefparam("typedefparam");
+
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/unicodetochar.cxx b/compilerplugins/clang/unicodetochar.cxx
index e1e381ad2c71..3599d3081a9f 100644
--- a/compilerplugins/clang/unicodetochar.cxx
+++ b/compilerplugins/clang/unicodetochar.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <stack>
 
 #include "check.hxx"
@@ -24,24 +26,48 @@ public:
     explicit UnicodeToChar(loplugin::InstantiationData const & data):
         FilteringPlugin(data) {}
 
-    bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+    bool PreTraverseCStyleCastExpr(CStyleCastExpr * expr) {
         subExprs_.push(expr->getSubExpr());
-        bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+        return true;
+    }
+    bool PostTraverseCStyleCastExpr(CStyleCastExpr *, bool ) {
         subExprs_.pop();
+        return true;
+    }
+    bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+        PreTraverseCStyleCastExpr(expr);
+        bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+        PostTraverseCStyleCastExpr(expr, ret);
         return ret;
     }
 
-    bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+    bool PreTraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
         subExprs_.push(expr->getSubExpr());
-        bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+        return true;
+    }
+    bool PostTraverseCXXStaticCastExpr(CXXStaticCastExpr *, bool) {
         subExprs_.pop();
+        return true;
+    }
+    bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+        PreTraverseCXXStaticCastExpr(expr);
+        bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+        PostTraverseCXXStaticCastExpr(expr, ret);
         return ret;
     }
 
-    bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+    bool PreTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
         subExprs_.push(expr->getSubExpr());
-        bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+        return true;
+    }
+    bool PostTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr *, bool) {
         subExprs_.pop();
+        return true;
+    }
+    bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+        PreTraverseCXXFunctionalCastExpr(expr);
+        bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+        PostTraverseCXXFunctionalCastExpr(expr, ret);
         return ret;
     }
 
@@ -72,18 +98,24 @@ public:
         return true;
     }
 
-private:
+    bool preRun() override {
+        return compiler.getLangOpts().CPlusPlus;
+    }
+
     void run() override {
-        if (compiler.getLangOpts().CPlusPlus) {
+        if (preRun()) {
             TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
         }
     }
 
+private:
     std::stack<Expr const *> subExprs_;
 };
 
-static loplugin::Plugin::Registration<UnicodeToChar> reg("unicodetochar");
+static loplugin::Plugin::Registration<UnicodeToChar> unicodetochar("unicodetochar");
+
+} // 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/unnecessarycatchthrow.cxx b/compilerplugins/clang/unnecessarycatchthrow.cxx
index 73cb01456a40..903e903823ab 100644
--- a/compilerplugins/clang/unnecessarycatchthrow.cxx
+++ b/compilerplugins/clang/unnecessarycatchthrow.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <cassert>
 #include <string>
 #include <iostream>
@@ -81,8 +83,10 @@ bool UnnecessaryCatchThrow::VisitCXXTryStmt(CXXTryStmt const * tryStmt)
 }
 
 
-loplugin::Plugin::Registration< UnnecessaryCatchThrow > X("unnecessarycatchthrow");
+loplugin::Plugin::Registration< UnnecessaryCatchThrow > unnecessarycatchthrow("unnecessarycatchthrow");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/unoany.cxx b/compilerplugins/clang/unoany.cxx
index 7d10a2361878..38e216fed437 100644
--- a/compilerplugins/clang/unoany.cxx
+++ b/compilerplugins/clang/unoany.cxx
@@ -7,9 +7,12 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include "check.hxx"
 #include "plugin.hxx"
 
+namespace {
 
 class UnoAny:
     public loplugin::FilteringPlugin<UnoAny>
@@ -17,9 +20,16 @@ class UnoAny:
 public:
     explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
 
+    bool preRun() override {
+        return compiler.getLangOpts().CPlusPlus;
+    }
+
     void run() override {
-        TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+        if (preRun()) {
+            TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+        }
     }
+
     bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
 };
 
@@ -71,7 +81,10 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
     return true;
 }
 
-loplugin::Plugin::Registration<UnoAny> X("unoany");
+loplugin::Plugin::Registration<UnoAny> unoany("unoany");
+
+} // 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/unoquery.cxx b/compilerplugins/clang/unoquery.cxx
index d445aa250623..82427555fef9 100644
--- a/compilerplugins/clang/unoquery.cxx
+++ b/compilerplugins/clang/unoquery.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include "check.hxx"
 #include "plugin.hxx"
 
@@ -24,7 +26,16 @@ public:
     {
     }
 
-    void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+    bool preRun() override { return compiler.getLangOpts().CPlusPlus; }
+
+    void run() override
+    {
+        if (preRun())
+        {
+            TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+        }
+    }
+
     bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*);
 };
 
@@ -79,7 +90,10 @@ bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr)
     return true;
 }
 
-loplugin::Plugin::Registration<UnoQuery> unoquery("unoquery", true);
-};
+loplugin::Plugin::Registration<UnoQuery> unoquery("unoquery");
+
+} // 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/weakbase.cxx b/compilerplugins/clang/weakbase.cxx
index fbd72955c0ba..a0040dd37c30 100644
--- a/compilerplugins/clang/weakbase.cxx
+++ b/compilerplugins/clang/weakbase.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <string>
 #include <iostream>
 #include <map>
@@ -28,7 +30,15 @@ public:
     {
     }
 
-    virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+    bool preRun() override { return compiler.getLangOpts().CPlusPlus; }
+
+    void run() override
+    {
+        if (preRun())
+        {
+            TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+        }
+    }
 
     bool VisitCXXRecordDecl(CXXRecordDecl const*);
 };
@@ -104,7 +114,10 @@ bool WeakBase::VisitCXXRecordDecl(CXXRecordDecl const* recordDecl)
     return true;
 }
 
-loplugin::Plugin::Registration<WeakBase> WeakBase("weakbase", true);
-}
+loplugin::Plugin::Registration<WeakBase> weakbase("weakbase");
+
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5521ac4e152dc9159ac7f7d86d9d2addef443cf4
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jul 15 21:38:19 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jul 16 09:14:52 2019 +0200

    RTF import: add tests for RTF_PGBRDRT/L/B/R
    
    lcov points out these were not covered previously.
    
    Change-Id: I0211cc35be99bf2487c73b4e63889a2af56d02c2
    Reviewed-on: https://gerrit.libreoffice.org/75661
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/rtfexport/data/page-border.rtf b/sw/qa/extras/rtfexport/data/page-border.rtf
new file mode 100644
index 000000000000..a5bb78c48b5f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/page-border.rtf
@@ -0,0 +1,4 @@
+{\rtf1
+\pgbrdrt\brdrs\brdrw10\brsp480 \pgbrdrl\brdrs\brdrw20\brsp480 \pgbrdrb\brdrs\brdrw30\brsp480 \pgbrdrr\brdrs\brdrw40\brsp480
+hello\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx
index f26f558267b2..0d86a00df960 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -129,6 +129,23 @@ DECLARE_RTFEXPORT_TEST(testBtlrCell, "btlr-cell.rtf")
     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode"));
 }
 
+DECLARE_RTFIMPORT_TEST(testPageBorder, "page-border.rtf")
+{
+    uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"),
+                                                   uno::UNO_QUERY);
+    auto aTopBorder = getProperty<table::BorderLine2>(xPageStyle, "TopBorder");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(18), aTopBorder.LineWidth);
+
+    auto aLeftBorder = getProperty<table::BorderLine2>(xPageStyle, "LeftBorder");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(35), aLeftBorder.LineWidth);
+
+    auto aBottomBorder = getProperty<table::BorderLine2>(xPageStyle, "BottomBorder");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(53), aBottomBorder.LineWidth);
+
+    auto aRightBorder = getProperty<table::BorderLine2>(xPageStyle, "RightBorder");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(71), aRightBorder.LineWidth);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list