convert some plugins to LO_CLANG_SHARED_PLUGINS
Change-Id: I63c9e010d83c24e18a36164ceb0441e48b757142 Reviewed-on: https://gerrit.libreoffice.org/75725 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -41,12 +42,8 @@ private:
|
|||||||
|
|
||||||
void OverrideParam::run()
|
void OverrideParam::run()
|
||||||
{
|
{
|
||||||
/*
|
if (preRun())
|
||||||
StringRef fn(handler.getMainFileName());
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
if (fn == SRCDIR "/include/svx/checklbx.hxx")
|
|
||||||
return;
|
|
||||||
*/
|
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
|
bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
|
||||||
@@ -164,8 +161,10 @@ bool OverrideParam::hasSameDefaultParams(const ParmVarDecl * parmVarDecl, const
|
|||||||
// that would probably have unwanted side-effects)
|
// that would probably have unwanted side-effects)
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration< OverrideParam > X("overrideparam");
|
loplugin::Plugin::Registration< OverrideParam > overrideparam("overrideparam");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
/**
|
/**
|
||||||
Look for calls where the param is bool but the call-site-arg is pointer.
|
Look for calls where the param is bool but the call-site-arg is pointer.
|
||||||
*/
|
*/
|
||||||
|
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -31,7 +32,11 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
|
virtual void run() override
|
||||||
|
{
|
||||||
|
if (preRun())
|
||||||
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
|
}
|
||||||
|
|
||||||
bool VisitCallExpr(CallExpr const*);
|
bool VisitCallExpr(CallExpr const*);
|
||||||
|
|
||||||
@@ -117,7 +122,10 @@ llvm::Optional<APSInt> PointerBool::getCallValue(const Expr* arg)
|
|||||||
return llvm::Optional<APSInt>();
|
return llvm::Optional<APSInt>();
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration<PointerBool> X("pointerbool", true);
|
loplugin::Plugin::Registration<PointerBool> pointerbool("pointerbool");
|
||||||
}
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -33,7 +34,8 @@ public:
|
|||||||
|
|
||||||
virtual void run() override
|
virtual void run() override
|
||||||
{
|
{
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
if (preRun())
|
||||||
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldVisitTemplateInstantiations () const { return true; }
|
bool shouldVisitTemplateInstantiations () const { return true; }
|
||||||
@@ -80,8 +82,10 @@ bool PtrVector::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr* expr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loplugin::Plugin::Registration< PtrVector > X("ptrvector");
|
loplugin::Plugin::Registration< PtrVector > ptrvector("ptrvector");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -29,7 +30,8 @@ public:
|
|||||||
FilteringPlugin(data) {}
|
FilteringPlugin(data) {}
|
||||||
|
|
||||||
virtual void run() override {
|
virtual void run() override {
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
if (preRun())
|
||||||
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitCXXForRangeStmt( const CXXForRangeStmt* stmt );
|
bool VisitCXXForRangeStmt( const CXXForRangeStmt* stmt );
|
||||||
@@ -59,8 +61,10 @@ bool RangedForCopy::VisitCXXForRangeStmt( const CXXForRangeStmt* stmt )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loplugin::Plugin::Registration< RangedForCopy > X("rangedforcopy");
|
loplugin::Plugin::Registration< RangedForCopy > rangedforcopy("rangedforcopy");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -24,7 +24,10 @@
|
|||||||
#include "../externvar.cxx"
|
#include "../externvar.cxx"
|
||||||
#include "../inlinevisible.cxx"
|
#include "../inlinevisible.cxx"
|
||||||
#include "../loopvartoosmall.cxx"
|
#include "../loopvartoosmall.cxx"
|
||||||
|
#include "../overrideparam.cxx"
|
||||||
|
#include "../pointerbool.cxx"
|
||||||
#include "../privatebase.cxx"
|
#include "../privatebase.cxx"
|
||||||
|
#include "../rangedforcopy.cxx"
|
||||||
#include "../redundantfcast.cxx"
|
#include "../redundantfcast.cxx"
|
||||||
#include "../redundantinline.cxx"
|
#include "../redundantinline.cxx"
|
||||||
#include "../redundantpointerops.cxx"
|
#include "../redundantpointerops.cxx"
|
||||||
@@ -50,6 +53,7 @@
|
|||||||
#include "../weakbase.cxx"
|
#include "../weakbase.cxx"
|
||||||
#include "../weakobject.cxx"
|
#include "../weakobject.cxx"
|
||||||
#include "../dyncastvisibility.cxx"
|
#include "../dyncastvisibility.cxx"
|
||||||
|
#include "../ptrvector.cxx"
|
||||||
#include "../vclwidgets.cxx"
|
#include "../vclwidgets.cxx"
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
@@ -77,7 +81,10 @@ public:
|
|||||||
, externVar( nullptr )
|
, externVar( nullptr )
|
||||||
, inlineVisible( nullptr )
|
, inlineVisible( nullptr )
|
||||||
, loopVarTooSmall( nullptr )
|
, loopVarTooSmall( nullptr )
|
||||||
|
, overrideParam( nullptr )
|
||||||
|
, pointerBool( nullptr )
|
||||||
, privateBase( nullptr )
|
, privateBase( nullptr )
|
||||||
|
, rangedForCopy( nullptr )
|
||||||
, redundantFCast( nullptr )
|
, redundantFCast( nullptr )
|
||||||
, redundantInline( nullptr )
|
, redundantInline( nullptr )
|
||||||
, redundantPointerOps( nullptr )
|
, redundantPointerOps( nullptr )
|
||||||
@@ -131,8 +138,14 @@ public:
|
|||||||
inlineVisible = nullptr;
|
inlineVisible = nullptr;
|
||||||
if( loopVarTooSmall && !loopVarTooSmall->preRun())
|
if( loopVarTooSmall && !loopVarTooSmall->preRun())
|
||||||
loopVarTooSmall = nullptr;
|
loopVarTooSmall = nullptr;
|
||||||
|
if( overrideParam && !overrideParam->preRun())
|
||||||
|
overrideParam = nullptr;
|
||||||
|
if( pointerBool && !pointerBool->preRun())
|
||||||
|
pointerBool = nullptr;
|
||||||
if( privateBase && !privateBase->preRun())
|
if( privateBase && !privateBase->preRun())
|
||||||
privateBase = nullptr;
|
privateBase = nullptr;
|
||||||
|
if( rangedForCopy && !rangedForCopy->preRun())
|
||||||
|
rangedForCopy = nullptr;
|
||||||
if( redundantFCast && !redundantFCast->preRun())
|
if( redundantFCast && !redundantFCast->preRun())
|
||||||
redundantFCast = nullptr;
|
redundantFCast = nullptr;
|
||||||
if( redundantInline && !redundantInline->preRun())
|
if( redundantInline && !redundantInline->preRun())
|
||||||
@@ -211,8 +224,14 @@ public:
|
|||||||
inlineVisible->postRun();
|
inlineVisible->postRun();
|
||||||
if( loopVarTooSmall )
|
if( loopVarTooSmall )
|
||||||
loopVarTooSmall->postRun();
|
loopVarTooSmall->postRun();
|
||||||
|
if( overrideParam )
|
||||||
|
overrideParam->postRun();
|
||||||
|
if( pointerBool )
|
||||||
|
pointerBool->postRun();
|
||||||
if( privateBase )
|
if( privateBase )
|
||||||
privateBase->postRun();
|
privateBase->postRun();
|
||||||
|
if( rangedForCopy )
|
||||||
|
rangedForCopy->postRun();
|
||||||
if( redundantFCast )
|
if( redundantFCast )
|
||||||
redundantFCast->postRun();
|
redundantFCast->postRun();
|
||||||
if( redundantInline )
|
if( redundantInline )
|
||||||
@@ -297,8 +316,14 @@ public:
|
|||||||
inlineVisible = static_cast< InlineVisible* >( plugin );
|
inlineVisible = static_cast< InlineVisible* >( plugin );
|
||||||
else if( strcmp( name, "loopvartoosmall" ) == 0 )
|
else if( strcmp( name, "loopvartoosmall" ) == 0 )
|
||||||
loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin );
|
loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin );
|
||||||
|
else if( strcmp( name, "overrideparam" ) == 0 )
|
||||||
|
overrideParam = static_cast< OverrideParam* >( plugin );
|
||||||
|
else if( strcmp( name, "pointerbool" ) == 0 )
|
||||||
|
pointerBool = static_cast< PointerBool* >( plugin );
|
||||||
else if( strcmp( name, "privatebase" ) == 0 )
|
else if( strcmp( name, "privatebase" ) == 0 )
|
||||||
privateBase = static_cast< PrivateBase* >( plugin );
|
privateBase = static_cast< PrivateBase* >( plugin );
|
||||||
|
else if( strcmp( name, "rangedforcopy" ) == 0 )
|
||||||
|
rangedForCopy = static_cast< RangedForCopy* >( plugin );
|
||||||
else if( strcmp( name, "redundantfcast" ) == 0 )
|
else if( strcmp( name, "redundantfcast" ) == 0 )
|
||||||
redundantFCast = static_cast< RedundantFCast* >( plugin );
|
redundantFCast = static_cast< RedundantFCast* >( plugin );
|
||||||
else if( strcmp( name, "redundantinline" ) == 0 )
|
else if( strcmp( name, "redundantinline" ) == 0 )
|
||||||
@@ -477,6 +502,17 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
|
bool VisitCXXForRangeStmt(const class clang::CXXForRangeStmt * arg)
|
||||||
|
{
|
||||||
|
if( ignoreLocation( arg ))
|
||||||
|
return true;
|
||||||
|
if( rangedForCopy != nullptr )
|
||||||
|
{
|
||||||
|
if( !rangedForCopy->VisitCXXForRangeStmt( arg ))
|
||||||
|
rangedForCopy = nullptr;
|
||||||
|
}
|
||||||
|
return anyPluginActive();
|
||||||
|
}
|
||||||
bool VisitCXXFunctionalCastExpr(const class clang::CXXFunctionalCastExpr * arg)
|
bool VisitCXXFunctionalCastExpr(const class clang::CXXFunctionalCastExpr * arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
@@ -508,6 +544,11 @@ public:
|
|||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
return true;
|
return true;
|
||||||
|
if( overrideParam != nullptr )
|
||||||
|
{
|
||||||
|
if( !overrideParam->VisitCXXMethodDecl( arg ))
|
||||||
|
overrideParam = nullptr;
|
||||||
|
}
|
||||||
if( typedefParam != nullptr )
|
if( typedefParam != nullptr )
|
||||||
{
|
{
|
||||||
if( !typedefParam->VisitCXXMethodDecl( arg ))
|
if( !typedefParam->VisitCXXMethodDecl( arg ))
|
||||||
@@ -604,6 +645,11 @@ public:
|
|||||||
if( !dbgUnhandledException->VisitCallExpr( arg ))
|
if( !dbgUnhandledException->VisitCallExpr( arg ))
|
||||||
dbgUnhandledException = nullptr;
|
dbgUnhandledException = nullptr;
|
||||||
}
|
}
|
||||||
|
if( pointerBool != nullptr )
|
||||||
|
{
|
||||||
|
if( !pointerBool->VisitCallExpr( arg ))
|
||||||
|
pointerBool = nullptr;
|
||||||
|
}
|
||||||
if( redundantFCast != nullptr )
|
if( redundantFCast != nullptr )
|
||||||
{
|
{
|
||||||
if( !redundantFCast->VisitCallExpr( arg ))
|
if( !redundantFCast->VisitCallExpr( arg ))
|
||||||
@@ -1088,7 +1134,10 @@ private:
|
|||||||
|| externVar != nullptr
|
|| externVar != nullptr
|
||||||
|| inlineVisible != nullptr
|
|| inlineVisible != nullptr
|
||||||
|| loopVarTooSmall != nullptr
|
|| loopVarTooSmall != nullptr
|
||||||
|
|| overrideParam != nullptr
|
||||||
|
|| pointerBool != nullptr
|
||||||
|| privateBase != nullptr
|
|| privateBase != nullptr
|
||||||
|
|| rangedForCopy != nullptr
|
||||||
|| redundantFCast != nullptr
|
|| redundantFCast != nullptr
|
||||||
|| redundantInline != nullptr
|
|| redundantInline != nullptr
|
||||||
|| redundantPointerOps != nullptr
|
|| redundantPointerOps != nullptr
|
||||||
@@ -1127,7 +1176,10 @@ private:
|
|||||||
ExternVar* externVar;
|
ExternVar* externVar;
|
||||||
InlineVisible* inlineVisible;
|
InlineVisible* inlineVisible;
|
||||||
LoopVarTooSmall* loopVarTooSmall;
|
LoopVarTooSmall* loopVarTooSmall;
|
||||||
|
OverrideParam* overrideParam;
|
||||||
|
PointerBool* pointerBool;
|
||||||
PrivateBase* privateBase;
|
PrivateBase* privateBase;
|
||||||
|
RangedForCopy* rangedForCopy;
|
||||||
RedundantFCast* redundantFCast;
|
RedundantFCast* redundantFCast;
|
||||||
RedundantInline* redundantInline;
|
RedundantInline* redundantInline;
|
||||||
RedundantPointerOps* redundantPointerOps;
|
RedundantPointerOps* redundantPointerOps;
|
||||||
@@ -1164,12 +1216,15 @@ public:
|
|||||||
explicit SharedRecursiveASTVisitorVisitTemplates(const InstantiationData& rData)
|
explicit SharedRecursiveASTVisitorVisitTemplates(const InstantiationData& rData)
|
||||||
: FilteringPlugin(rData)
|
: FilteringPlugin(rData)
|
||||||
, dynCastVisibility( nullptr )
|
, dynCastVisibility( nullptr )
|
||||||
|
, ptrVector( nullptr )
|
||||||
, vCLWidgets( nullptr )
|
, vCLWidgets( nullptr )
|
||||||
{}
|
{}
|
||||||
virtual bool preRun() override
|
virtual bool preRun() override
|
||||||
{
|
{
|
||||||
if( dynCastVisibility && !dynCastVisibility->preRun())
|
if( dynCastVisibility && !dynCastVisibility->preRun())
|
||||||
dynCastVisibility = nullptr;
|
dynCastVisibility = nullptr;
|
||||||
|
if( ptrVector && !ptrVector->preRun())
|
||||||
|
ptrVector = nullptr;
|
||||||
if( vCLWidgets && !vCLWidgets->preRun())
|
if( vCLWidgets && !vCLWidgets->preRun())
|
||||||
vCLWidgets = nullptr;
|
vCLWidgets = nullptr;
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
@@ -1178,6 +1233,8 @@ public:
|
|||||||
{
|
{
|
||||||
if( dynCastVisibility )
|
if( dynCastVisibility )
|
||||||
dynCastVisibility->postRun();
|
dynCastVisibility->postRun();
|
||||||
|
if( ptrVector )
|
||||||
|
ptrVector->postRun();
|
||||||
if( vCLWidgets )
|
if( vCLWidgets )
|
||||||
vCLWidgets->postRun();
|
vCLWidgets->postRun();
|
||||||
}
|
}
|
||||||
@@ -1192,6 +1249,8 @@ public:
|
|||||||
{
|
{
|
||||||
if( strcmp( name, "dyncastvisibility" ) == 0 )
|
if( strcmp( name, "dyncastvisibility" ) == 0 )
|
||||||
dynCastVisibility = static_cast< DynCastVisibility* >( plugin );
|
dynCastVisibility = static_cast< DynCastVisibility* >( plugin );
|
||||||
|
else if( strcmp( name, "ptrvector" ) == 0 )
|
||||||
|
ptrVector = static_cast< PtrVector* >( plugin );
|
||||||
else if( strcmp( name, "vclwidgets" ) == 0 )
|
else if( strcmp( name, "vclwidgets" ) == 0 )
|
||||||
vCLWidgets = static_cast< VCLWidgets* >( plugin );
|
vCLWidgets = static_cast< VCLWidgets* >( plugin );
|
||||||
else
|
else
|
||||||
@@ -1254,6 +1313,17 @@ bool shouldVisitTemplateInstantiations() const { return true; }
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
|
bool VisitCXXOperatorCallExpr(const class clang::CXXOperatorCallExpr * arg)
|
||||||
|
{
|
||||||
|
if( ignoreLocation( arg ))
|
||||||
|
return true;
|
||||||
|
if( ptrVector != nullptr )
|
||||||
|
{
|
||||||
|
if( !ptrVector->VisitCXXOperatorCallExpr( arg ))
|
||||||
|
ptrVector = nullptr;
|
||||||
|
}
|
||||||
|
return anyPluginActive();
|
||||||
|
}
|
||||||
bool VisitCallExpr(const class clang::CallExpr * arg)
|
bool VisitCallExpr(const class clang::CallExpr * arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
@@ -1324,9 +1394,11 @@ private:
|
|||||||
bool anyPluginActive() const
|
bool anyPluginActive() const
|
||||||
{
|
{
|
||||||
return dynCastVisibility != nullptr
|
return dynCastVisibility != nullptr
|
||||||
|
|| ptrVector != nullptr
|
||||||
|| vCLWidgets != nullptr;
|
|| vCLWidgets != nullptr;
|
||||||
}
|
}
|
||||||
DynCastVisibility* dynCastVisibility;
|
DynCastVisibility* dynCastVisibility;
|
||||||
|
PtrVector* ptrVector;
|
||||||
VCLWidgets* vCLWidgets;
|
VCLWidgets* vCLWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user