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>
This commit is contained in:
parent
c62360e4cb
commit
b5b044505a
4 changed files with 99 additions and 14 deletions
|
@ -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: */
|
||||
|
|
|
@ -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: */
|
||||
|
|
|
@ -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: */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue