convert some plugins to use the sharedplugin infrastructure
Change-Id: I690d9df436abdadc51a6d3f7df686a2e37f79f73 Reviewed-on: https://gerrit.libreoffice.org/75624 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
fd55c09eba
commit
fc1b213d15
@ -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 "check.hxx"
|
#include "check.hxx"
|
||||||
#include "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
@ -41,16 +42,18 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
bool preRun() override {
|
||||||
void run() override {
|
return compiler.getLangOpts().CPlusPlus
|
||||||
if (compiler.getLangOpts().CPlusPlus
|
|
||||||
&& compiler.getPreprocessor().getIdentifierInfo(
|
&& compiler.getPreprocessor().getIdentifierInfo(
|
||||||
"LIBO_INTERNAL_ONLY")->hasMacroDefinition())
|
"LIBO_INTERNAL_ONLY")->hasMacroDefinition();
|
||||||
{
|
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run() override {
|
||||||
|
if (preRun())
|
||||||
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
void check(ExplicitCastExpr const * expr) {
|
void check(ExplicitCastExpr const * expr) {
|
||||||
if (ignoreLocation(expr)
|
if (ignoreLocation(expr)
|
||||||
|| isInUnoIncludeFile(expr->getExprLoc()))
|
|| isInUnoIncludeFile(expr->getExprLoc()))
|
||||||
@ -90,9 +93,11 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static loplugin::Plugin::Registration<SalUnicodeLiteral> reg(
|
static loplugin::Plugin::Registration<SalUnicodeLiteral> salunicodeliteral(
|
||||||
"salunicodeliteral");
|
"salunicodeliteral");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
/* 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
|
* 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>
|
||||||
@ -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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -26,13 +26,28 @@
|
|||||||
#include "../loopvartoosmall.cxx"
|
#include "../loopvartoosmall.cxx"
|
||||||
#include "../privatebase.cxx"
|
#include "../privatebase.cxx"
|
||||||
#include "../reservedid.cxx"
|
#include "../reservedid.cxx"
|
||||||
|
#include "../salunicodeliteral.cxx"
|
||||||
|
#include "../sfxpoolitem.cxx"
|
||||||
#include "../simplifyconstruct.cxx"
|
#include "../simplifyconstruct.cxx"
|
||||||
|
#include "../simplifydynamiccast.cxx"
|
||||||
|
#include "../staticaccess.cxx"
|
||||||
|
#include "../staticanonymous.cxx"
|
||||||
|
#include "../staticconstfield.cxx"
|
||||||
|
#include "../staticmethods.cxx"
|
||||||
|
#include "../stringconcat.cxx"
|
||||||
|
#include "../stringconstant.cxx"
|
||||||
#include "../stringstatic.cxx"
|
#include "../stringstatic.cxx"
|
||||||
#include "../subtlezeroinit.cxx"
|
#include "../subtlezeroinit.cxx"
|
||||||
|
#include "../typedefparam.cxx"
|
||||||
|
#include "../unicodetochar.cxx"
|
||||||
|
#include "../unnecessarycatchthrow.cxx"
|
||||||
#include "../unnecessaryoverride.cxx"
|
#include "../unnecessaryoverride.cxx"
|
||||||
#include "../unnecessaryparen.cxx"
|
#include "../unnecessaryparen.cxx"
|
||||||
|
#include "../unoany.cxx"
|
||||||
|
#include "../unoquery.cxx"
|
||||||
#include "../unreffun.cxx"
|
#include "../unreffun.cxx"
|
||||||
#include "../unusedvariablecheck.cxx"
|
#include "../unusedvariablecheck.cxx"
|
||||||
|
#include "../weakbase.cxx"
|
||||||
#include "../weakobject.cxx"
|
#include "../weakobject.cxx"
|
||||||
#include "../dyncastvisibility.cxx"
|
#include "../dyncastvisibility.cxx"
|
||||||
#include "../vclwidgets.cxx"
|
#include "../vclwidgets.cxx"
|
||||||
@ -64,13 +79,28 @@ public:
|
|||||||
, loopVarTooSmall( nullptr )
|
, loopVarTooSmall( nullptr )
|
||||||
, privateBase( nullptr )
|
, privateBase( nullptr )
|
||||||
, reservedId( nullptr )
|
, reservedId( nullptr )
|
||||||
|
, salUnicodeLiteral( nullptr )
|
||||||
|
, sfxPoolItem( nullptr )
|
||||||
, simplifyConstruct( nullptr )
|
, simplifyConstruct( nullptr )
|
||||||
|
, simplifyDynamicCast( nullptr )
|
||||||
|
, staticAccess( nullptr )
|
||||||
|
, staticAnonymous( nullptr )
|
||||||
|
, staticConstField( nullptr )
|
||||||
|
, staticMethods( nullptr )
|
||||||
|
, stringConcat( nullptr )
|
||||||
|
, stringConstant( nullptr )
|
||||||
, stringStatic( nullptr )
|
, stringStatic( nullptr )
|
||||||
, subtleZeroInit( nullptr )
|
, subtleZeroInit( nullptr )
|
||||||
|
, typedefParam( nullptr )
|
||||||
|
, unicodeToChar( nullptr )
|
||||||
|
, unnecessaryCatchThrow( nullptr )
|
||||||
, unnecessaryOverride( nullptr )
|
, unnecessaryOverride( nullptr )
|
||||||
, unnecessaryParen( nullptr )
|
, unnecessaryParen( nullptr )
|
||||||
|
, unoAny( nullptr )
|
||||||
|
, unoQuery( nullptr )
|
||||||
, unrefFun( nullptr )
|
, unrefFun( nullptr )
|
||||||
, unusedVariableCheck( nullptr )
|
, unusedVariableCheck( nullptr )
|
||||||
|
, weakBase( nullptr )
|
||||||
, weakObject( nullptr )
|
, weakObject( nullptr )
|
||||||
{}
|
{}
|
||||||
virtual bool preRun() override
|
virtual bool preRun() override
|
||||||
@ -105,20 +135,50 @@ public:
|
|||||||
privateBase = nullptr;
|
privateBase = nullptr;
|
||||||
if( reservedId && !reservedId->preRun())
|
if( reservedId && !reservedId->preRun())
|
||||||
reservedId = nullptr;
|
reservedId = nullptr;
|
||||||
|
if( salUnicodeLiteral && !salUnicodeLiteral->preRun())
|
||||||
|
salUnicodeLiteral = nullptr;
|
||||||
|
if( sfxPoolItem && !sfxPoolItem->preRun())
|
||||||
|
sfxPoolItem = nullptr;
|
||||||
if( simplifyConstruct && !simplifyConstruct->preRun())
|
if( simplifyConstruct && !simplifyConstruct->preRun())
|
||||||
simplifyConstruct = nullptr;
|
simplifyConstruct = nullptr;
|
||||||
|
if( simplifyDynamicCast && !simplifyDynamicCast->preRun())
|
||||||
|
simplifyDynamicCast = nullptr;
|
||||||
|
if( staticAccess && !staticAccess->preRun())
|
||||||
|
staticAccess = nullptr;
|
||||||
|
if( staticAnonymous && !staticAnonymous->preRun())
|
||||||
|
staticAnonymous = nullptr;
|
||||||
|
if( staticConstField && !staticConstField->preRun())
|
||||||
|
staticConstField = nullptr;
|
||||||
|
if( staticMethods && !staticMethods->preRun())
|
||||||
|
staticMethods = nullptr;
|
||||||
|
if( stringConcat && !stringConcat->preRun())
|
||||||
|
stringConcat = nullptr;
|
||||||
|
if( stringConstant && !stringConstant->preRun())
|
||||||
|
stringConstant = nullptr;
|
||||||
if( stringStatic && !stringStatic->preRun())
|
if( stringStatic && !stringStatic->preRun())
|
||||||
stringStatic = nullptr;
|
stringStatic = nullptr;
|
||||||
if( subtleZeroInit && !subtleZeroInit->preRun())
|
if( subtleZeroInit && !subtleZeroInit->preRun())
|
||||||
subtleZeroInit = nullptr;
|
subtleZeroInit = nullptr;
|
||||||
|
if( typedefParam && !typedefParam->preRun())
|
||||||
|
typedefParam = nullptr;
|
||||||
|
if( unicodeToChar && !unicodeToChar->preRun())
|
||||||
|
unicodeToChar = nullptr;
|
||||||
|
if( unnecessaryCatchThrow && !unnecessaryCatchThrow->preRun())
|
||||||
|
unnecessaryCatchThrow = nullptr;
|
||||||
if( unnecessaryOverride && !unnecessaryOverride->preRun())
|
if( unnecessaryOverride && !unnecessaryOverride->preRun())
|
||||||
unnecessaryOverride = nullptr;
|
unnecessaryOverride = nullptr;
|
||||||
if( unnecessaryParen && !unnecessaryParen->preRun())
|
if( unnecessaryParen && !unnecessaryParen->preRun())
|
||||||
unnecessaryParen = nullptr;
|
unnecessaryParen = nullptr;
|
||||||
|
if( unoAny && !unoAny->preRun())
|
||||||
|
unoAny = nullptr;
|
||||||
|
if( unoQuery && !unoQuery->preRun())
|
||||||
|
unoQuery = nullptr;
|
||||||
if( unrefFun && !unrefFun->preRun())
|
if( unrefFun && !unrefFun->preRun())
|
||||||
unrefFun = nullptr;
|
unrefFun = nullptr;
|
||||||
if( unusedVariableCheck && !unusedVariableCheck->preRun())
|
if( unusedVariableCheck && !unusedVariableCheck->preRun())
|
||||||
unusedVariableCheck = nullptr;
|
unusedVariableCheck = nullptr;
|
||||||
|
if( weakBase && !weakBase->preRun())
|
||||||
|
weakBase = nullptr;
|
||||||
if( weakObject && !weakObject->preRun())
|
if( weakObject && !weakObject->preRun())
|
||||||
weakObject = nullptr;
|
weakObject = nullptr;
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
@ -155,20 +215,50 @@ public:
|
|||||||
privateBase->postRun();
|
privateBase->postRun();
|
||||||
if( reservedId )
|
if( reservedId )
|
||||||
reservedId->postRun();
|
reservedId->postRun();
|
||||||
|
if( salUnicodeLiteral )
|
||||||
|
salUnicodeLiteral->postRun();
|
||||||
|
if( sfxPoolItem )
|
||||||
|
sfxPoolItem->postRun();
|
||||||
if( simplifyConstruct )
|
if( simplifyConstruct )
|
||||||
simplifyConstruct->postRun();
|
simplifyConstruct->postRun();
|
||||||
|
if( simplifyDynamicCast )
|
||||||
|
simplifyDynamicCast->postRun();
|
||||||
|
if( staticAccess )
|
||||||
|
staticAccess->postRun();
|
||||||
|
if( staticAnonymous )
|
||||||
|
staticAnonymous->postRun();
|
||||||
|
if( staticConstField )
|
||||||
|
staticConstField->postRun();
|
||||||
|
if( staticMethods )
|
||||||
|
staticMethods->postRun();
|
||||||
|
if( stringConcat )
|
||||||
|
stringConcat->postRun();
|
||||||
|
if( stringConstant )
|
||||||
|
stringConstant->postRun();
|
||||||
if( stringStatic )
|
if( stringStatic )
|
||||||
stringStatic->postRun();
|
stringStatic->postRun();
|
||||||
if( subtleZeroInit )
|
if( subtleZeroInit )
|
||||||
subtleZeroInit->postRun();
|
subtleZeroInit->postRun();
|
||||||
|
if( typedefParam )
|
||||||
|
typedefParam->postRun();
|
||||||
|
if( unicodeToChar )
|
||||||
|
unicodeToChar->postRun();
|
||||||
|
if( unnecessaryCatchThrow )
|
||||||
|
unnecessaryCatchThrow->postRun();
|
||||||
if( unnecessaryOverride )
|
if( unnecessaryOverride )
|
||||||
unnecessaryOverride->postRun();
|
unnecessaryOverride->postRun();
|
||||||
if( unnecessaryParen )
|
if( unnecessaryParen )
|
||||||
unnecessaryParen->postRun();
|
unnecessaryParen->postRun();
|
||||||
|
if( unoAny )
|
||||||
|
unoAny->postRun();
|
||||||
|
if( unoQuery )
|
||||||
|
unoQuery->postRun();
|
||||||
if( unrefFun )
|
if( unrefFun )
|
||||||
unrefFun->postRun();
|
unrefFun->postRun();
|
||||||
if( unusedVariableCheck )
|
if( unusedVariableCheck )
|
||||||
unusedVariableCheck->postRun();
|
unusedVariableCheck->postRun();
|
||||||
|
if( weakBase )
|
||||||
|
weakBase->postRun();
|
||||||
if( weakObject )
|
if( weakObject )
|
||||||
weakObject->postRun();
|
weakObject->postRun();
|
||||||
}
|
}
|
||||||
@ -211,20 +301,50 @@ public:
|
|||||||
privateBase = static_cast< PrivateBase* >( plugin );
|
privateBase = static_cast< PrivateBase* >( plugin );
|
||||||
else if( strcmp( name, "reservedid" ) == 0 )
|
else if( strcmp( name, "reservedid" ) == 0 )
|
||||||
reservedId = static_cast< ReservedId* >( plugin );
|
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 )
|
else if( strcmp( name, "simplifyconstruct" ) == 0 )
|
||||||
simplifyConstruct = static_cast< SimplifyConstruct* >( plugin );
|
simplifyConstruct = static_cast< SimplifyConstruct* >( plugin );
|
||||||
|
else if( strcmp( name, "simplifydynamiccast" ) == 0 )
|
||||||
|
simplifyDynamicCast = static_cast< SimplifyDynamicCast* >( 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, "staticconstfield" ) == 0 )
|
||||||
|
staticConstField = static_cast< StaticConstField* >( plugin );
|
||||||
|
else if( strcmp( name, "staticmethods" ) == 0 )
|
||||||
|
staticMethods = static_cast< StaticMethods* >( plugin );
|
||||||
|
else if( strcmp( name, "stringconcat" ) == 0 )
|
||||||
|
stringConcat = static_cast< StringConcat* >( plugin );
|
||||||
|
else if( strcmp( name, "stringconstant" ) == 0 )
|
||||||
|
stringConstant = static_cast< StringConstant* >( plugin );
|
||||||
else if( strcmp( name, "stringstatic" ) == 0 )
|
else if( strcmp( name, "stringstatic" ) == 0 )
|
||||||
stringStatic = static_cast< StringStatic* >( plugin );
|
stringStatic = static_cast< StringStatic* >( plugin );
|
||||||
else if( strcmp( name, "subtlezeroinit" ) == 0 )
|
else if( strcmp( name, "subtlezeroinit" ) == 0 )
|
||||||
subtleZeroInit = static_cast< SubtleZeroInit* >( plugin );
|
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 )
|
else if( strcmp( name, "unnecessaryoverride" ) == 0 )
|
||||||
unnecessaryOverride = static_cast< UnnecessaryOverride* >( plugin );
|
unnecessaryOverride = static_cast< UnnecessaryOverride* >( plugin );
|
||||||
else if( strcmp( name, "unnecessaryparen" ) == 0 )
|
else if( strcmp( name, "unnecessaryparen" ) == 0 )
|
||||||
unnecessaryParen = static_cast< UnnecessaryParen* >( plugin );
|
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 )
|
else if( strcmp( name, "unreffun" ) == 0 )
|
||||||
unrefFun = static_cast< UnrefFun* >( plugin );
|
unrefFun = static_cast< UnrefFun* >( plugin );
|
||||||
else if( strcmp( name, "unusedvariablecheck" ) == 0 )
|
else if( strcmp( name, "unusedvariablecheck" ) == 0 )
|
||||||
unusedVariableCheck = static_cast< UnusedVariableCheck* >( plugin );
|
unusedVariableCheck = static_cast< UnusedVariableCheck* >( plugin );
|
||||||
|
else if( strcmp( name, "weakbase" ) == 0 )
|
||||||
|
weakBase = static_cast< WeakBase* >( plugin );
|
||||||
else if( strcmp( name, "weakobject" ) == 0 )
|
else if( strcmp( name, "weakobject" ) == 0 )
|
||||||
weakObject = static_cast< WeakObject* >( plugin );
|
weakObject = static_cast< WeakObject* >( plugin );
|
||||||
else
|
else
|
||||||
@ -319,6 +439,17 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
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)
|
bool VisitCXXConstructExpr(const class clang::CXXConstructExpr * arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
@ -328,6 +459,11 @@ public:
|
|||||||
if( !simplifyConstruct->VisitCXXConstructExpr( arg ))
|
if( !simplifyConstruct->VisitCXXConstructExpr( arg ))
|
||||||
simplifyConstruct = nullptr;
|
simplifyConstruct = nullptr;
|
||||||
}
|
}
|
||||||
|
if( stringConstant != nullptr )
|
||||||
|
{
|
||||||
|
if( !stringConstant->VisitCXXConstructExpr( arg ))
|
||||||
|
stringConstant = nullptr;
|
||||||
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr * arg)
|
bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr * arg)
|
||||||
@ -341,10 +477,48 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
|
bool VisitCXXDependentScopeMemberExpr(const class clang::CXXDependentScopeMemberExpr * arg)
|
||||||
|
{
|
||||||
|
if( ignoreLocation( arg ))
|
||||||
|
return true;
|
||||||
|
if( staticMethods != nullptr )
|
||||||
|
{
|
||||||
|
if( !staticMethods->VisitCXXDependentScopeMemberExpr( arg ))
|
||||||
|
staticMethods = nullptr;
|
||||||
|
}
|
||||||
|
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)
|
bool VisitCXXMethodDecl(const class clang::CXXMethodDecl * arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
return true;
|
return true;
|
||||||
|
if( typedefParam != nullptr )
|
||||||
|
{
|
||||||
|
if( !typedefParam->VisitCXXMethodDecl( arg ))
|
||||||
|
typedefParam = nullptr;
|
||||||
|
}
|
||||||
if( unnecessaryOverride != nullptr )
|
if( unnecessaryOverride != nullptr )
|
||||||
{
|
{
|
||||||
if( !unnecessaryOverride->VisitCXXMethodDecl( arg ))
|
if( !unnecessaryOverride->VisitCXXMethodDecl( arg ))
|
||||||
@ -377,6 +551,11 @@ public:
|
|||||||
if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
|
if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
|
||||||
unnecessaryParen = nullptr;
|
unnecessaryParen = nullptr;
|
||||||
}
|
}
|
||||||
|
if( unoAny != nullptr )
|
||||||
|
{
|
||||||
|
if( !unoAny->VisitCXXOperatorCallExpr( arg ))
|
||||||
|
unoAny = nullptr;
|
||||||
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
bool VisitCXXRecordDecl(const class clang::CXXRecordDecl * arg)
|
bool VisitCXXRecordDecl(const class clang::CXXRecordDecl * arg)
|
||||||
@ -388,6 +567,54 @@ public:
|
|||||||
if( !privateBase->VisitCXXRecordDecl( arg ))
|
if( !privateBase->VisitCXXRecordDecl( arg ))
|
||||||
privateBase = nullptr;
|
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;
|
||||||
|
}
|
||||||
|
if( simplifyDynamicCast != nullptr )
|
||||||
|
{
|
||||||
|
if( !simplifyDynamicCast->VisitCXXStaticCastExpr( arg ))
|
||||||
|
simplifyDynamicCast = nullptr;
|
||||||
|
}
|
||||||
|
return anyPluginActive();
|
||||||
|
}
|
||||||
|
bool VisitCXXThisExpr(const class clang::CXXThisExpr * arg)
|
||||||
|
{
|
||||||
|
if( ignoreLocation( arg ))
|
||||||
|
return true;
|
||||||
|
if( staticMethods != nullptr )
|
||||||
|
{
|
||||||
|
if( !staticMethods->VisitCXXThisExpr( arg ))
|
||||||
|
staticMethods = 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();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
bool VisitCallExpr(const class clang::CallExpr * arg)
|
bool VisitCallExpr(const class clang::CallExpr * arg)
|
||||||
@ -399,6 +626,16 @@ public:
|
|||||||
if( !dbgUnhandledException->VisitCallExpr( arg ))
|
if( !dbgUnhandledException->VisitCallExpr( arg ))
|
||||||
dbgUnhandledException = nullptr;
|
dbgUnhandledException = nullptr;
|
||||||
}
|
}
|
||||||
|
if( stringConcat != nullptr )
|
||||||
|
{
|
||||||
|
if( !stringConcat->VisitCallExpr( arg ))
|
||||||
|
stringConcat = nullptr;
|
||||||
|
}
|
||||||
|
if( stringConstant != nullptr )
|
||||||
|
{
|
||||||
|
if( !stringConstant->VisitCallExpr( arg ))
|
||||||
|
stringConstant = nullptr;
|
||||||
|
}
|
||||||
if( unnecessaryParen != nullptr )
|
if( unnecessaryParen != nullptr )
|
||||||
{
|
{
|
||||||
if( !unnecessaryParen->VisitCallExpr( arg ))
|
if( !unnecessaryParen->VisitCallExpr( arg ))
|
||||||
@ -501,6 +738,16 @@ public:
|
|||||||
if( !inlineVisible->VisitFunctionDecl( arg ))
|
if( !inlineVisible->VisitFunctionDecl( arg ))
|
||||||
inlineVisible = nullptr;
|
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 != nullptr )
|
||||||
{
|
{
|
||||||
if( !unrefFun->VisitFunctionDecl( arg ))
|
if( !unrefFun->VisitFunctionDecl( arg ))
|
||||||
@ -524,6 +771,17 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
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)
|
bool VisitMaterializeTemporaryExpr(const class clang::MaterializeTemporaryExpr * arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
@ -539,6 +797,11 @@ public:
|
|||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
return true;
|
return true;
|
||||||
|
if( staticAccess != nullptr )
|
||||||
|
{
|
||||||
|
if( !staticAccess->VisitMemberExpr( arg ))
|
||||||
|
staticAccess = nullptr;
|
||||||
|
}
|
||||||
if( unnecessaryParen != nullptr )
|
if( unnecessaryParen != nullptr )
|
||||||
{
|
{
|
||||||
if( !unnecessaryParen->VisitMemberExpr( arg ))
|
if( !unnecessaryParen->VisitMemberExpr( arg ))
|
||||||
@ -617,6 +880,17 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
|
bool VisitUnresolvedMemberExpr(const class clang::UnresolvedMemberExpr * arg)
|
||||||
|
{
|
||||||
|
if( ignoreLocation( arg ))
|
||||||
|
return true;
|
||||||
|
if( staticMethods != nullptr )
|
||||||
|
{
|
||||||
|
if( !staticMethods->VisitUnresolvedMemberExpr( arg ))
|
||||||
|
staticMethods = nullptr;
|
||||||
|
}
|
||||||
|
return anyPluginActive();
|
||||||
|
}
|
||||||
bool VisitVarDecl(const class clang::VarDecl *const arg)
|
bool VisitVarDecl(const class clang::VarDecl *const arg)
|
||||||
{
|
{
|
||||||
if( ignoreLocation( arg ))
|
if( ignoreLocation( arg ))
|
||||||
@ -669,6 +943,13 @@ public:
|
|||||||
}
|
}
|
||||||
return anyPluginActive();
|
return anyPluginActive();
|
||||||
}
|
}
|
||||||
|
bool TraverseCStyleCastExpr(class clang::CStyleCastExpr * arg)
|
||||||
|
{
|
||||||
|
UnicodeToChar* saveUnicodeToChar = unicodeToChar;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr( arg );
|
||||||
|
unicodeToChar = saveUnicodeToChar;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr * arg)
|
bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr * arg)
|
||||||
{
|
{
|
||||||
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
||||||
@ -698,6 +979,69 @@ public:
|
|||||||
dbgUnhandledException = saveDbgUnhandledException;
|
dbgUnhandledException = saveDbgUnhandledException;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
bool TraverseCXXConstructExpr(class clang::CXXConstructExpr * arg)
|
||||||
|
{
|
||||||
|
StringConstant* saveStringConstant = stringConstant;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXConstructExpr( arg );
|
||||||
|
stringConstant = saveStringConstant;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXConstructorDecl(class clang::CXXConstructorDecl * arg)
|
||||||
|
{
|
||||||
|
StaticConstField* saveStaticConstField = staticConstField;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXConstructorDecl( arg );
|
||||||
|
staticConstField = saveStaticConstField;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXFunctionalCastExpr(class clang::CXXFunctionalCastExpr * arg)
|
||||||
|
{
|
||||||
|
UnicodeToChar* saveUnicodeToChar = unicodeToChar;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr( arg );
|
||||||
|
unicodeToChar = saveUnicodeToChar;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXMemberCallExpr(class clang::CXXMemberCallExpr * arg)
|
||||||
|
{
|
||||||
|
StringConstant* saveStringConstant = stringConstant;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXMemberCallExpr( arg );
|
||||||
|
stringConstant = saveStringConstant;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXMethodDecl(class clang::CXXMethodDecl * arg)
|
||||||
|
{
|
||||||
|
StaticMethods* saveStaticMethods = staticMethods;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXMethodDecl( arg );
|
||||||
|
staticMethods = saveStaticMethods;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXOperatorCallExpr(class clang::CXXOperatorCallExpr * arg)
|
||||||
|
{
|
||||||
|
StringConstant* saveStringConstant = stringConstant;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXOperatorCallExpr( arg );
|
||||||
|
stringConstant = saveStringConstant;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCXXStaticCastExpr(class clang::CXXStaticCastExpr * arg)
|
||||||
|
{
|
||||||
|
UnicodeToChar* saveUnicodeToChar = unicodeToChar;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr( arg );
|
||||||
|
unicodeToChar = saveUnicodeToChar;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseCallExpr(class clang::CallExpr * arg)
|
||||||
|
{
|
||||||
|
StringConstant* saveStringConstant = stringConstant;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseCallExpr( arg );
|
||||||
|
stringConstant = saveStringConstant;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool TraverseConstructorInitializer(class clang::CXXCtorInitializer * arg)
|
||||||
|
{
|
||||||
|
StaticConstField* saveStaticConstField = staticConstField;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseConstructorInitializer( arg );
|
||||||
|
staticConstField = saveStaticConstField;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool TraverseFriendDecl(class clang::FriendDecl * arg)
|
bool TraverseFriendDecl(class clang::FriendDecl * arg)
|
||||||
{
|
{
|
||||||
UnrefFun* saveUnrefFun = unrefFun;
|
UnrefFun* saveUnrefFun = unrefFun;
|
||||||
@ -715,6 +1059,13 @@ public:
|
|||||||
unrefFun = saveUnrefFun;
|
unrefFun = saveUnrefFun;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
bool TraverseIfStmt(class clang::IfStmt * arg)
|
||||||
|
{
|
||||||
|
SimplifyDynamicCast* saveSimplifyDynamicCast = simplifyDynamicCast;
|
||||||
|
bool ret = RecursiveASTVisitor::TraverseIfStmt( arg );
|
||||||
|
simplifyDynamicCast = saveSimplifyDynamicCast;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool TraverseInitListExpr(class clang::InitListExpr * arg)
|
bool TraverseInitListExpr(class clang::InitListExpr * arg)
|
||||||
{
|
{
|
||||||
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
||||||
@ -757,13 +1108,28 @@ private:
|
|||||||
|| loopVarTooSmall != nullptr
|
|| loopVarTooSmall != nullptr
|
||||||
|| privateBase != nullptr
|
|| privateBase != nullptr
|
||||||
|| reservedId != nullptr
|
|| reservedId != nullptr
|
||||||
|
|| salUnicodeLiteral != nullptr
|
||||||
|
|| sfxPoolItem != nullptr
|
||||||
|| simplifyConstruct != nullptr
|
|| simplifyConstruct != nullptr
|
||||||
|
|| simplifyDynamicCast != nullptr
|
||||||
|
|| staticAccess != nullptr
|
||||||
|
|| staticAnonymous != nullptr
|
||||||
|
|| staticConstField != nullptr
|
||||||
|
|| staticMethods != nullptr
|
||||||
|
|| stringConcat != nullptr
|
||||||
|
|| stringConstant != nullptr
|
||||||
|| stringStatic != nullptr
|
|| stringStatic != nullptr
|
||||||
|| subtleZeroInit != nullptr
|
|| subtleZeroInit != nullptr
|
||||||
|
|| typedefParam != nullptr
|
||||||
|
|| unicodeToChar != nullptr
|
||||||
|
|| unnecessaryCatchThrow != nullptr
|
||||||
|| unnecessaryOverride != nullptr
|
|| unnecessaryOverride != nullptr
|
||||||
|| unnecessaryParen != nullptr
|
|| unnecessaryParen != nullptr
|
||||||
|
|| unoAny != nullptr
|
||||||
|
|| unoQuery != nullptr
|
||||||
|| unrefFun != nullptr
|
|| unrefFun != nullptr
|
||||||
|| unusedVariableCheck != nullptr
|
|| unusedVariableCheck != nullptr
|
||||||
|
|| weakBase != nullptr
|
||||||
|| weakObject != nullptr;
|
|| weakObject != nullptr;
|
||||||
}
|
}
|
||||||
BadStatics* badStatics;
|
BadStatics* badStatics;
|
||||||
@ -781,13 +1147,28 @@ private:
|
|||||||
LoopVarTooSmall* loopVarTooSmall;
|
LoopVarTooSmall* loopVarTooSmall;
|
||||||
PrivateBase* privateBase;
|
PrivateBase* privateBase;
|
||||||
ReservedId* reservedId;
|
ReservedId* reservedId;
|
||||||
|
SalUnicodeLiteral* salUnicodeLiteral;
|
||||||
|
SfxPoolItem* sfxPoolItem;
|
||||||
SimplifyConstruct* simplifyConstruct;
|
SimplifyConstruct* simplifyConstruct;
|
||||||
|
SimplifyDynamicCast* simplifyDynamicCast;
|
||||||
|
StaticAccess* staticAccess;
|
||||||
|
StaticAnonymous* staticAnonymous;
|
||||||
|
StaticConstField* staticConstField;
|
||||||
|
StaticMethods* staticMethods;
|
||||||
|
StringConcat* stringConcat;
|
||||||
|
StringConstant* stringConstant;
|
||||||
StringStatic* stringStatic;
|
StringStatic* stringStatic;
|
||||||
SubtleZeroInit* subtleZeroInit;
|
SubtleZeroInit* subtleZeroInit;
|
||||||
|
TypedefParam* typedefParam;
|
||||||
|
UnicodeToChar* unicodeToChar;
|
||||||
|
UnnecessaryCatchThrow* unnecessaryCatchThrow;
|
||||||
UnnecessaryOverride* unnecessaryOverride;
|
UnnecessaryOverride* unnecessaryOverride;
|
||||||
UnnecessaryParen* unnecessaryParen;
|
UnnecessaryParen* unnecessaryParen;
|
||||||
|
UnoAny* unoAny;
|
||||||
|
UnoQuery* unoQuery;
|
||||||
UnrefFun* unrefFun;
|
UnrefFun* unrefFun;
|
||||||
UnusedVariableCheck* unusedVariableCheck;
|
UnusedVariableCheck* unusedVariableCheck;
|
||||||
|
WeakBase* weakBase;
|
||||||
WeakObject* weakObject;
|
WeakObject* weakObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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 <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -111,7 +112,10 @@ bool SimplifyDynamicCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const* static
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration<SimplifyDynamicCast> X("simplifydynamiccast", true);
|
loplugin::Plugin::Registration<SimplifyDynamicCast> simplifydynamiccast("simplifydynamiccast");
|
||||||
}
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
@ -89,8 +91,10 @@ bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) {
|
|||||||
return true;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
* Based on LLVM/Clang.
|
* Based on LLVM/Clang.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
#include "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,7 +24,7 @@ class StaticAnonymous
|
|||||||
public:
|
public:
|
||||||
explicit StaticAnonymous( const InstantiationData& data );
|
explicit StaticAnonymous( const InstantiationData& data );
|
||||||
virtual void run() override;
|
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 ) )
|
if( ignoreLocation( func ) )
|
||||||
@ -59,8 +61,10 @@ bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register the plugin action with the LO plugin handling.
|
// Register the plugin action with the LO plugin handling.
|
||||||
static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true);
|
static Plugin::Registration< StaticAnonymous > staticanonymous("staticanonymous");
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
#include "check.hxx"
|
#include "check.hxx"
|
||||||
#include "compat.hxx"
|
#include "compat.hxx"
|
||||||
@ -28,6 +30,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool preRun() override;
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
bool TraverseConstructorInitializer(CXXCtorInitializer* init);
|
bool TraverseConstructorInitializer(CXXCtorInitializer* init);
|
||||||
@ -44,15 +47,23 @@ private:
|
|||||||
CXXConstructorDecl* m_currentConstructor = nullptr;
|
CXXConstructorDecl* m_currentConstructor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void StaticConstField::run()
|
bool StaticConstField::preRun()
|
||||||
{
|
{
|
||||||
std::string fn = handler.getMainFileName();
|
std::string fn = handler.getMainFileName();
|
||||||
loplugin::normalizeDotDotInFilePath(fn);
|
loplugin::normalizeDotDotInFilePath(fn);
|
||||||
|
|
||||||
// unusual case where a user constructor sets a field to one value, and a copy constructor sets it to a different value
|
// unusual case where a user constructor sets a field to one value, and a copy constructor sets it to a different value
|
||||||
if (fn == SRCDIR "/sw/source/core/attr/hints.cxx")
|
if (fn == SRCDIR "/sw/source/core/attr/hints.cxx")
|
||||||
return;
|
return false;
|
||||||
if (fn == SRCDIR "/oox/source/core/contexthandler2.cxx")
|
if (fn == SRCDIR "/oox/source/core/contexthandler2.cxx")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticConstField::run()
|
||||||
|
{
|
||||||
|
if (!preRun())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
@ -168,7 +179,10 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration<StaticConstField> X("staticconstfield", true);
|
loplugin::Plugin::Registration<StaticConstField> staticconstfield("staticconstfield");
|
||||||
}
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 "clang/AST/Attr.h"
|
#include "clang/AST/Attr.h"
|
||||||
|
|
||||||
#include "check.hxx"
|
#include "check.hxx"
|
||||||
@ -28,7 +30,7 @@ public:
|
|||||||
void run() override
|
void run() override
|
||||||
{ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
|
{ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
|
||||||
|
|
||||||
bool TraverseCXXMethodDecl(const CXXMethodDecl * decl);
|
bool TraverseCXXMethodDecl(CXXMethodDecl * decl);
|
||||||
|
|
||||||
bool VisitCXXThisExpr(const CXXThisExpr *) { bVisitedThis = true; return true; }
|
bool VisitCXXThisExpr(const CXXThisExpr *) { bVisitedThis = true; return true; }
|
||||||
// these two indicate that we hit something that makes our analysis unreliable
|
// these two indicate that we hit something that makes our analysis unreliable
|
||||||
@ -67,7 +69,7 @@ bool startsWith(const std::string& rStr, const char* pSubStr) {
|
|||||||
return rStr.compare(0, strlen(pSubStr), pSubStr) == 0;
|
return rStr.compare(0, strlen(pSubStr), pSubStr) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl) {
|
bool StaticMethods::TraverseCXXMethodDecl(CXXMethodDecl * pCXXMethodDecl) {
|
||||||
if (ignoreLocation(pCXXMethodDecl)) {
|
if (ignoreLocation(pCXXMethodDecl)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -231,8 +233,10 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration<StaticMethods> X("staticmethods");
|
loplugin::Plugin::Registration<StaticMethods> staticmethods("staticmethods");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
#include "check.hxx"
|
#include "check.hxx"
|
||||||
|
|
||||||
@ -151,8 +153,10 @@ bool StringConcat::isStringLiteral(Expr const * expr) {
|
|||||||
!= "OSL_THIS_FUNC");
|
!= "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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -108,6 +110,8 @@ public:
|
|||||||
explicit StringConstant(loplugin::InstantiationData const & data):
|
explicit StringConstant(loplugin::InstantiationData const & data):
|
||||||
FilteringRewritePlugin(data) {}
|
FilteringRewritePlugin(data) {}
|
||||||
|
|
||||||
|
bool preRun() override;
|
||||||
|
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
bool TraverseCallExpr(CallExpr * expr);
|
bool TraverseCallExpr(CallExpr * expr);
|
||||||
@ -186,14 +190,15 @@ private:
|
|||||||
std::stack<Expr const *> calls_;
|
std::stack<Expr const *> calls_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void StringConstant::run() {
|
bool StringConstant::preRun() {
|
||||||
if (compiler.getLangOpts().CPlusPlus
|
return compiler.getLangOpts().CPlusPlus
|
||||||
&& compiler.getPreprocessor().getIdentifierInfo(
|
&& compiler.getPreprocessor().getIdentifierInfo(
|
||||||
"LIBO_INTERNAL_ONLY")->hasMacroDefinition())
|
"LIBO_INTERNAL_ONLY")->hasMacroDefinition();
|
||||||
//TODO: some parts of it are useful for external code, too
|
//TODO: some parts of it are useful for external code, too
|
||||||
{
|
}
|
||||||
|
void StringConstant::run() {
|
||||||
|
if (preRun())
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StringConstant::TraverseCallExpr(CallExpr * expr) {
|
bool StringConstant::TraverseCallExpr(CallExpr * expr) {
|
||||||
@ -2087,8 +2092,10 @@ void StringConstant::handleFunArgOstring(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loplugin::Plugin::Registration< StringConstant > X("stringconstant", true);
|
loplugin::Plugin::Registration< StringConstant > stringconstant("stringconstant");
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
|
#endif // LO_CLANG_SHARED_PLUGINS
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#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 VisitFunctionDecl(FunctionDecl const*);
|
||||||
bool VisitCXXMethodDecl(CXXMethodDecl const*);
|
bool VisitCXXMethodDecl(CXXMethodDecl const*);
|
||||||
@ -321,7 +323,10 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
|
|||||||
return lhsType == rhsType;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include "check.hxx"
|
#include "check.hxx"
|
||||||
@ -72,18 +74,24 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
bool preRun() override {
|
||||||
|
return compiler.getLangOpts().CPlusPlus;
|
||||||
|
}
|
||||||
|
|
||||||
void run() override {
|
void run() override {
|
||||||
if (compiler.getLangOpts().CPlusPlus) {
|
if (preRun()) {
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
std::stack<Expr const *> subExprs_;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -7,9 +7,12 @@
|
|||||||
* 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 "check.hxx"
|
#include "check.hxx"
|
||||||
#include "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
class UnoAny:
|
class UnoAny:
|
||||||
public loplugin::FilteringPlugin<UnoAny>
|
public loplugin::FilteringPlugin<UnoAny>
|
||||||
@ -17,9 +20,16 @@ class UnoAny:
|
|||||||
public:
|
public:
|
||||||
explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
|
explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
|
||||||
|
|
||||||
void run() override {
|
bool preRun() override {
|
||||||
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
return compiler.getLangOpts().CPlusPlus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run() override {
|
||||||
|
if (preRun()) {
|
||||||
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
|
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,7 +81,10 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
|
|||||||
return true;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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 "check.hxx"
|
#include "check.hxx"
|
||||||
#include "plugin.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*);
|
bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +90,10 @@ bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr)
|
|||||||
return true;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 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>
|
||||||
#include <map>
|
#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*);
|
bool VisitCXXRecordDecl(CXXRecordDecl const*);
|
||||||
};
|
};
|
||||||
@ -104,7 +114,10 @@ bool WeakBase::VisitCXXRecordDecl(CXXRecordDecl const* recordDecl)
|
|||||||
return true;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user