diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-16 10:31:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-16 14:16:55 +0200 |
commit | b5b044505aab03a398a46b0f194fc512b67488e0 (patch) | |
tree | bd838b43d6dfbda7082aef3c44797159122cbb45 /compilerplugins/clang | |
parent | c62360e4cbb605020f9b6b0d40fcd60bca3994b7 (diff) |
convert some plugins to LO_CLANG_SHARED_PLUGINS
Change-Id: I06ccd31248f9671fc96dc3d0e7f3cf696ec07f28
Reviewed-on: https://gerrit.libreoffice.org/75686
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/redundantinline.cxx | 12 | ||||
-rw-r--r-- | compilerplugins/clang/redundantpointerops.cxx | 10 | ||||
-rw-r--r-- | compilerplugins/clang/sallogareas.cxx | 25 | ||||
-rw-r--r-- | compilerplugins/clang/sharedvisitor/sharedvisitor.cxx | 66 |
4 files changed, 99 insertions, 14 deletions
diff --git a/compilerplugins/clang/redundantinline.cxx b/compilerplugins/clang/redundantinline.cxx index 5fab44825afa..3bda99e397cb 100644 --- a/compilerplugins/clang/redundantinline.cxx +++ b/compilerplugins/clang/redundantinline.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 <cassert> @@ -20,7 +21,10 @@ public: explicit RedundantInline(loplugin::InstantiationData const & data): FilteringRewritePlugin(data) {} - void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } + void run() override { + if (preRun()) + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } bool VisitFunctionDecl(FunctionDecl const * decl) { if (ignoreLocation(decl)) { @@ -164,8 +168,10 @@ private: } }; -loplugin::Plugin::Registration<RedundantInline> reg("redundantinline", true); +loplugin::Plugin::Registration<RedundantInline> redundantinline("redundantinline"); + +} // 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/redundantpointerops.cxx b/compilerplugins/clang/redundantpointerops.cxx index bbbc6651f32c..68db603baf11 100644 --- a/compilerplugins/clang/redundantpointerops.cxx +++ b/compilerplugins/clang/redundantpointerops.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 <cassert> #include <string> @@ -43,7 +44,8 @@ public: virtual void run() override { - TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + if (preRun()) + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitFunctionDecl(FunctionDecl const *); @@ -122,8 +124,10 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator return true; } -loplugin::Plugin::Registration< RedundantPointerOps > X("redundantpointerops"); +loplugin::Plugin::Registration< RedundantPointerOps > redundantpointerops("redundantpointerops"); -} +} // namespace + +#endif // LO_CLANG_SHARED_PLUGINS /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index 4d749330abd1..02df2793824e 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -8,6 +8,7 @@ * License. See LICENSE.TXT for details. * */ +#ifndef LO_CLANG_SHARED_PLUGINS #include "plugin.hxx" #include "check.hxx" @@ -27,7 +28,19 @@ class SalLogAreas public: explicit SalLogAreas( const loplugin::InstantiationData& data ) : FilteringPlugin(data), inFunction(nullptr) {} - virtual void run() override; + + bool preRun() override { + return true; + } + + void run() override { + if (preRun()) + { + lastSalDetailLogStreamMacro = SourceLocation(); + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } + } + bool VisitFunctionDecl( const FunctionDecl* function ); bool VisitCallExpr( const CallExpr* call ); private: @@ -51,12 +64,6 @@ report if the area is not listed there. The fix is either use a proper area or a if appropriate. */ -void SalLogAreas::run() - { - lastSalDetailLogStreamMacro = SourceLocation(); - TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); - } - bool SalLogAreas::VisitFunctionDecl( const FunctionDecl* function ) { inFunction = function; @@ -261,8 +268,10 @@ void SalLogAreas::readLogAreas() report( DiagnosticsEngine::Warning, "error reading log areas" ); } -static loplugin::Plugin::Registration< SalLogAreas > X( "sallogareas" ); +static loplugin::Plugin::Registration< SalLogAreas > sallogareas( "sallogareas" ); } // 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 4532bbe250ca..d48343171646 100644 --- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx +++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx @@ -25,7 +25,10 @@ #include "../inlinevisible.cxx" #include "../loopvartoosmall.cxx" #include "../privatebase.cxx" +#include "../redundantinline.cxx" +#include "../redundantpointerops.cxx" #include "../reservedid.cxx" +#include "../sallogareas.cxx" #include "../salunicodeliteral.cxx" #include "../sfxpoolitem.cxx" #include "../simplifyconstruct.cxx" @@ -74,7 +77,10 @@ public: , inlineVisible( nullptr ) , loopVarTooSmall( nullptr ) , privateBase( nullptr ) + , redundantInline( nullptr ) + , redundantPointerOps( nullptr ) , reservedId( nullptr ) + , salLogAreas( nullptr ) , salUnicodeLiteral( nullptr ) , sfxPoolItem( nullptr ) , simplifyConstruct( nullptr ) @@ -125,8 +131,14 @@ public: loopVarTooSmall = nullptr; if( privateBase && !privateBase->preRun()) privateBase = nullptr; + if( redundantInline && !redundantInline->preRun()) + redundantInline = nullptr; + if( redundantPointerOps && !redundantPointerOps->preRun()) + redundantPointerOps = nullptr; if( reservedId && !reservedId->preRun()) reservedId = nullptr; + if( salLogAreas && !salLogAreas->preRun()) + salLogAreas = nullptr; if( salUnicodeLiteral && !salUnicodeLiteral->preRun()) salUnicodeLiteral = nullptr; if( sfxPoolItem && !sfxPoolItem->preRun()) @@ -197,8 +209,14 @@ public: loopVarTooSmall->postRun(); if( privateBase ) privateBase->postRun(); + if( redundantInline ) + redundantInline->postRun(); + if( redundantPointerOps ) + redundantPointerOps->postRun(); if( reservedId ) reservedId->postRun(); + if( salLogAreas ) + salLogAreas->postRun(); if( salUnicodeLiteral ) salUnicodeLiteral->postRun(); if( sfxPoolItem ) @@ -275,8 +293,14 @@ public: loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin ); else if( strcmp( name, "privatebase" ) == 0 ) privateBase = static_cast< PrivateBase* >( plugin ); + else if( strcmp( name, "redundantinline" ) == 0 ) + redundantInline = static_cast< RedundantInline* >( plugin ); + else if( strcmp( name, "redundantpointerops" ) == 0 ) + redundantPointerOps = static_cast< RedundantPointerOps* >( plugin ); else if( strcmp( name, "reservedid" ) == 0 ) reservedId = static_cast< ReservedId* >( plugin ); + else if( strcmp( name, "sallogareas" ) == 0 ) + salLogAreas = static_cast< SalLogAreas* >( plugin ); else if( strcmp( name, "salunicodeliteral" ) == 0 ) salUnicodeLiteral = static_cast< SalUnicodeLiteral* >( plugin ); else if( strcmp( name, "sfxpoolitem" ) == 0 ) @@ -562,6 +586,11 @@ public: if( !dbgUnhandledException->VisitCallExpr( arg )) dbgUnhandledException = nullptr; } + if( salLogAreas != nullptr ) + { + if( !salLogAreas->VisitCallExpr( arg )) + salLogAreas = nullptr; + } if( stringConcat != nullptr ) { if( !stringConcat->VisitCallExpr( arg )) @@ -669,6 +698,21 @@ public: if( !inlineVisible->VisitFunctionDecl( arg )) inlineVisible = nullptr; } + if( redundantInline != nullptr ) + { + if( !redundantInline->VisitFunctionDecl( arg )) + redundantInline = nullptr; + } + if( redundantPointerOps != nullptr ) + { + if( !redundantPointerOps->VisitFunctionDecl( arg )) + redundantPointerOps = nullptr; + } + if( salLogAreas != nullptr ) + { + if( !salLogAreas->VisitFunctionDecl( arg )) + salLogAreas = nullptr; + } if( staticAnonymous != nullptr ) { if( !staticAnonymous->VisitFunctionDecl( arg )) @@ -728,6 +772,11 @@ public: { if( ignoreLocation( arg )) return true; + if( redundantPointerOps != nullptr ) + { + if( !redundantPointerOps->VisitMemberExpr( arg )) + redundantPointerOps = nullptr; + } if( staticAccess != nullptr ) { if( !staticAccess->VisitMemberExpr( arg )) @@ -811,6 +860,17 @@ public: } return anyPluginActive(); } + bool VisitUnaryOperator(const class clang::UnaryOperator * arg) + { + if( ignoreLocation( arg )) + return true; + if( redundantPointerOps != nullptr ) + { + if( !redundantPointerOps->VisitUnaryOperator( arg )) + redundantPointerOps = nullptr; + } + return anyPluginActive(); + } bool VisitVarDecl(const class clang::VarDecl *const arg) { if( ignoreLocation( arg )) @@ -1001,7 +1061,10 @@ private: || inlineVisible != nullptr || loopVarTooSmall != nullptr || privateBase != nullptr + || redundantInline != nullptr + || redundantPointerOps != nullptr || reservedId != nullptr + || salLogAreas != nullptr || salUnicodeLiteral != nullptr || sfxPoolItem != nullptr || simplifyConstruct != nullptr @@ -1036,7 +1099,10 @@ private: InlineVisible* inlineVisible; LoopVarTooSmall* loopVarTooSmall; PrivateBase* privateBase; + RedundantInline* redundantInline; + RedundantPointerOps* redundantPointerOps; ReservedId* reservedId; + SalLogAreas* salLogAreas; SalUnicodeLiteral* salUnicodeLiteral; SfxPoolItem* sfxPoolItem; SimplifyConstruct* simplifyConstruct; |