compilerplugins/clang/salunicodeliteral.cxx | 21 compilerplugins/clang/sfxpoolitem.cxx | 7 compilerplugins/clang/sharedvisitor/sharedvisitor.cxx | 381 ------------------ compilerplugins/clang/simplifydynamiccast.cxx | 8 compilerplugins/clang/staticaccess.cxx | 8 compilerplugins/clang/staticanonymous.cxx | 10 compilerplugins/clang/staticconstfield.cxx | 22 - compilerplugins/clang/staticmethods.cxx | 12 compilerplugins/clang/stringconcat.cxx | 8 compilerplugins/clang/stringconstant.cxx | 21 compilerplugins/clang/typedefparam.cxx | 11 compilerplugins/clang/unicodetochar.cxx | 16 compilerplugins/clang/unnecessarycatchthrow.cxx | 8 compilerplugins/clang/unoany.cxx | 17 compilerplugins/clang/unoquery.cxx | 20 compilerplugins/clang/weakbase.cxx | 19 16 files changed, 51 insertions(+), 538 deletions(-)
New commits: commit 574db10513be6b25f24c8cab49cbc9e63aca87d3 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 15 18:18:57 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jul 15 18:18:57 2019 +0200 Revert "convert some plugins to use the sharedplugin infrastructure" This reverts commit fc1b213d157afa57704cec5a0fb65ae8c11d7822. I didn't convert these correctly, the Traverse calls need adjusting. diff --git a/compilerplugins/clang/salunicodeliteral.cxx b/compilerplugins/clang/salunicodeliteral.cxx index cfa37396b02b..bdf83694b77e 100644 --- a/compilerplugins/clang/salunicodeliteral.cxx +++ b/compilerplugins/clang/salunicodeliteral.cxx @@ -6,7 +6,6 @@ * 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" @@ -42,18 +41,16 @@ public: return true; } - bool preRun() override { - return compiler.getLangOpts().CPlusPlus - && compiler.getPreprocessor().getIdentifierInfo( - "LIBO_INTERNAL_ONLY")->hasMacroDefinition(); - } - +private: void run() override { - if (preRun()) + if (compiler.getLangOpts().CPlusPlus + && compiler.getPreprocessor().getIdentifierInfo( + "LIBO_INTERNAL_ONLY")->hasMacroDefinition()) + { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } } -private: void check(ExplicitCastExpr const * expr) { if (ignoreLocation(expr) || isInUnoIncludeFile(expr->getExprLoc())) @@ -93,11 +90,9 @@ private: } }; -static loplugin::Plugin::Registration<SalUnicodeLiteral> salunicodeliteral( +static loplugin::Plugin::Registration<SalUnicodeLiteral> reg( "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 ce52336c8e04..bd2870fe06d3 100644 --- a/compilerplugins/clang/sfxpoolitem.cxx +++ b/compilerplugins/clang/sfxpoolitem.cxx @@ -6,7 +6,6 @@ * 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> @@ -125,10 +124,8 @@ bool SfxPoolItem::VisitCXXRecordDecl(const CXXRecordDecl* decl) } -loplugin::Plugin::Registration< SfxPoolItem > sfxpoolitem("sfxpoolitem"); +loplugin::Plugin::Registration< SfxPoolItem > X("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 28adab18e53c..a6df13ca33b4 100644 --- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx +++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx @@ -26,28 +26,13 @@ #include "../loopvartoosmall.cxx" #include "../privatebase.cxx" #include "../reservedid.cxx" -#include "../salunicodeliteral.cxx" -#include "../sfxpoolitem.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 "../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" @@ -79,28 +64,13 @@ public: , loopVarTooSmall( nullptr ) , privateBase( nullptr ) , reservedId( nullptr ) - , salUnicodeLiteral( nullptr ) - , sfxPoolItem( nullptr ) , simplifyConstruct( nullptr ) - , simplifyDynamicCast( nullptr ) - , staticAccess( nullptr ) - , staticAnonymous( nullptr ) - , staticConstField( nullptr ) - , staticMethods( nullptr ) - , stringConcat( nullptr ) - , stringConstant( 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 @@ -135,50 +105,20 @@ 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( 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()) 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(); @@ -215,50 +155,20 @@ public: privateBase->postRun(); if( reservedId ) reservedId->postRun(); - if( salUnicodeLiteral ) - salUnicodeLiteral->postRun(); - if( sfxPoolItem ) - sfxPoolItem->postRun(); if( simplifyConstruct ) 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 ) 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(); } @@ -301,50 +211,20 @@ 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, "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 ) 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 @@ -439,17 +319,6 @@ 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 )) @@ -459,11 +328,6 @@ public: if( !simplifyConstruct->VisitCXXConstructExpr( arg )) simplifyConstruct = nullptr; } - if( stringConstant != nullptr ) - { - if( !stringConstant->VisitCXXConstructExpr( arg )) - stringConstant = nullptr; - } return anyPluginActive(); } bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr * arg) @@ -477,48 +341,10 @@ public: } 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) { if( ignoreLocation( arg )) return true; - if( typedefParam != nullptr ) - { - if( !typedefParam->VisitCXXMethodDecl( arg )) - typedefParam = nullptr; - } if( unnecessaryOverride != nullptr ) { if( !unnecessaryOverride->VisitCXXMethodDecl( arg )) @@ -551,11 +377,6 @@ 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) @@ -567,54 +388,6 @@ 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; - } - 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(); } bool VisitCallExpr(const class clang::CallExpr * arg) @@ -626,16 +399,6 @@ public: if( !dbgUnhandledException->VisitCallExpr( arg )) 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->VisitCallExpr( arg )) @@ -738,16 +501,6 @@ 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 )) @@ -771,17 +524,6 @@ 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 )) @@ -797,11 +539,6 @@ public: { if( ignoreLocation( arg )) return true; - if( staticAccess != nullptr ) - { - if( !staticAccess->VisitMemberExpr( arg )) - staticAccess = nullptr; - } if( unnecessaryParen != nullptr ) { if( !unnecessaryParen->VisitMemberExpr( arg )) @@ -880,17 +617,6 @@ public: } 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) { if( ignoreLocation( arg )) @@ -943,13 +669,6 @@ public: } 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) { SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct; @@ -979,69 +698,6 @@ public: dbgUnhandledException = saveDbgUnhandledException; 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) { UnrefFun* saveUnrefFun = unrefFun; @@ -1059,13 +715,6 @@ public: unrefFun = saveUnrefFun; 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) { SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct; @@ -1108,28 +757,13 @@ private: || loopVarTooSmall != nullptr || privateBase != nullptr || reservedId != nullptr - || salUnicodeLiteral != nullptr - || sfxPoolItem != nullptr || simplifyConstruct != nullptr - || simplifyDynamicCast != nullptr - || staticAccess != nullptr - || staticAnonymous != nullptr - || staticConstField != nullptr - || staticMethods != nullptr - || stringConcat != nullptr - || stringConstant != 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; @@ -1147,28 +781,13 @@ private: LoopVarTooSmall* loopVarTooSmall; PrivateBase* privateBase; ReservedId* reservedId; - SalUnicodeLiteral* salUnicodeLiteral; - SfxPoolItem* sfxPoolItem; SimplifyConstruct* simplifyConstruct; - SimplifyDynamicCast* simplifyDynamicCast; - StaticAccess* staticAccess; - StaticAnonymous* staticAnonymous; - StaticConstField* staticConstField; - StaticMethods* staticMethods; - StringConcat* stringConcat; - StringConstant* stringConstant; 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/simplifydynamiccast.cxx b/compilerplugins/clang/simplifydynamiccast.cxx index bb6e81d6ca58..b1f06179ee71 100644 --- a/compilerplugins/clang/simplifydynamiccast.cxx +++ b/compilerplugins/clang/simplifydynamiccast.cxx @@ -6,7 +6,6 @@ * 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> @@ -112,10 +111,7 @@ bool SimplifyDynamicCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const* static return true; } -loplugin::Plugin::Registration<SimplifyDynamicCast> simplifydynamiccast("simplifydynamiccast"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS +loplugin::Plugin::Registration<SimplifyDynamicCast> X("simplifydynamiccast", true); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/staticaccess.cxx b/compilerplugins/clang/staticaccess.cxx index 9c1abbc5cba4..6b15bfb15349 100644 --- a/compilerplugins/clang/staticaccess.cxx +++ b/compilerplugins/clang/staticaccess.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <cassert> #include "plugin.hxx" @@ -91,10 +89,8 @@ bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) { return true; } -loplugin::Plugin::Registration<StaticAccess> staticaccess("staticaccess"); - -} // namespace +loplugin::Plugin::Registration<StaticAccess> X("staticaccess"); -#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 0fd00f2279e7..f31499af6f73 100644 --- a/compilerplugins/clang/staticanonymous.cxx +++ b/compilerplugins/clang/staticanonymous.cxx @@ -5,8 +5,6 @@ * Based on LLVM/Clang. * */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include "plugin.hxx" /* @@ -24,7 +22,7 @@ class StaticAnonymous public: explicit StaticAnonymous( const InstantiationData& data ); virtual void run() override; - bool VisitFunctionDecl( const FunctionDecl* func ); + bool VisitFunctionDecl( FunctionDecl* func ); }; @@ -39,7 +37,7 @@ void StaticAnonymous::run() } -bool StaticAnonymous::VisitFunctionDecl( const FunctionDecl* func ) +bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func ) { if( ignoreLocation( func ) ) @@ -61,10 +59,8 @@ bool StaticAnonymous::VisitFunctionDecl( const FunctionDecl* func ) } // Register the plugin action with the LO plugin handling. -static Plugin::Registration< StaticAnonymous > staticanonymous("staticanonymous"); +static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true); } // namespace -#endif // LO_CLANG_SHARED_PLUGINS - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx index 3d9d4c6411ae..91a798daa5bd 100644 --- a/compilerplugins/clang/staticconstfield.cxx +++ b/compilerplugins/clang/staticconstfield.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include "plugin.hxx" #include "check.hxx" #include "compat.hxx" @@ -30,7 +28,6 @@ public: { } - bool preRun() override; void run() override; bool TraverseConstructorInitializer(CXXCtorInitializer* init); @@ -47,23 +44,15 @@ private: CXXConstructorDecl* m_currentConstructor = nullptr; }; -bool StaticConstField::preRun() +void StaticConstField::run() { std::string fn = handler.getMainFileName(); 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 if (fn == SRCDIR "/sw/source/core/attr/hints.cxx") - return false; + return; if (fn == SRCDIR "/oox/source/core/contexthandler2.cxx") - return false; - - return true; -} - -void StaticConstField::run() -{ - if (!preRun()) return; TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); @@ -179,10 +168,7 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init) return true; } -loplugin::Plugin::Registration<StaticConstField> staticconstfield("staticconstfield"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS +loplugin::Plugin::Registration<StaticConstField> X("staticconstfield", true); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index 0d82170a4b3e..bc37189eb64b 100644 --- a/compilerplugins/clang/staticmethods.cxx +++ b/compilerplugins/clang/staticmethods.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include "clang/AST/Attr.h" #include "check.hxx" @@ -30,7 +28,7 @@ public: void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } - bool TraverseCXXMethodDecl(CXXMethodDecl * decl); + bool TraverseCXXMethodDecl(const CXXMethodDecl * decl); bool VisitCXXThisExpr(const CXXThisExpr *) { bVisitedThis = true; return true; } // these two indicate that we hit something that makes our analysis unreliable @@ -69,7 +67,7 @@ bool startsWith(const std::string& rStr, const char* pSubStr) { return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; } -bool StaticMethods::TraverseCXXMethodDecl(CXXMethodDecl * pCXXMethodDecl) { +bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl) { if (ignoreLocation(pCXXMethodDecl)) { return true; } @@ -233,10 +231,8 @@ bool StaticMethods::TraverseCXXMethodDecl(CXXMethodDecl * pCXXMethodDecl) { return true; } -loplugin::Plugin::Registration<StaticMethods> staticmethods("staticmethods"); - -} // namespace +loplugin::Plugin::Registration<StaticMethods> X("staticmethods"); -#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 8511f849d64f..da4b212e9f73 100644 --- a/compilerplugins/clang/stringconcat.cxx +++ b/compilerplugins/clang/stringconcat.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include "plugin.hxx" #include "check.hxx" @@ -153,10 +151,8 @@ bool StringConcat::isStringLiteral(Expr const * expr) { != "OSL_THIS_FUNC"); } -loplugin::Plugin::Registration<StringConcat> stringconcat("stringconcat"); - -} // namespace +loplugin::Plugin::Registration<StringConcat> X("stringconcat"); -#endif // LO_CLANG_SHARED_PLUGINS +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 29ff508e8c7c..05cfa03ff711 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <algorithm> #include <cassert> #include <cstdint> @@ -110,8 +108,6 @@ public: explicit StringConstant(loplugin::InstantiationData const & data): FilteringRewritePlugin(data) {} - bool preRun() override; - void run() override; bool TraverseCallExpr(CallExpr * expr); @@ -190,15 +186,14 @@ private: std::stack<Expr const *> calls_; }; -bool StringConstant::preRun() { - return compiler.getLangOpts().CPlusPlus +void StringConstant::run() { + if (compiler.getLangOpts().CPlusPlus && compiler.getPreprocessor().getIdentifierInfo( - "LIBO_INTERNAL_ONLY")->hasMacroDefinition(); + "LIBO_INTERNAL_ONLY")->hasMacroDefinition()) //TODO: some parts of it are useful for external code, too -} -void StringConstant::run() { - if (preRun()) + { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } } bool StringConstant::TraverseCallExpr(CallExpr * expr) { @@ -2092,10 +2087,8 @@ void StringConstant::handleFunArgOstring( } } -loplugin::Plugin::Registration< StringConstant > stringconstant("stringconstant"); +loplugin::Plugin::Registration< StringConstant > X("stringconstant", true); -} // 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 2c7031ff7af0..0b7a74ba1696 100644 --- a/compilerplugins/clang/typedefparam.cxx +++ b/compilerplugins/clang/typedefparam.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <cassert> #include <string> #include <iostream> @@ -33,7 +31,7 @@ public: { } - void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } + virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitFunctionDecl(FunctionDecl const*); bool VisitCXXMethodDecl(CXXMethodDecl const*); @@ -323,10 +321,7 @@ static bool areTypesEqual(QualType lhs, QualType rhs) return lhsType == rhsType; } -loplugin::Plugin::Registration<TypedefParam> typedefparam("typedefparam"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS +loplugin::Plugin::Registration<TypedefParam> X("typedefparam", true); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/unicodetochar.cxx b/compilerplugins/clang/unicodetochar.cxx index 14a59e35f462..e1e381ad2c71 100644 --- a/compilerplugins/clang/unicodetochar.cxx +++ b/compilerplugins/clang/unicodetochar.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <stack> #include "check.hxx" @@ -74,24 +72,18 @@ public: return true; } - bool preRun() override { - return compiler.getLangOpts().CPlusPlus; - } - +private: void run() override { - if (preRun()) { + if (compiler.getLangOpts().CPlusPlus) { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } } -private: std::stack<Expr const *> subExprs_; }; -static loplugin::Plugin::Registration<UnicodeToChar> unicodetochar("unicodetochar"); - -} // namespace +static loplugin::Plugin::Registration<UnicodeToChar> reg("unicodetochar"); -#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 903e903823ab..73cb01456a40 100644 --- a/compilerplugins/clang/unnecessarycatchthrow.cxx +++ b/compilerplugins/clang/unnecessarycatchthrow.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <cassert> #include <string> #include <iostream> @@ -83,10 +81,8 @@ bool UnnecessaryCatchThrow::VisitCXXTryStmt(CXXTryStmt const * tryStmt) } -loplugin::Plugin::Registration< UnnecessaryCatchThrow > unnecessarycatchthrow("unnecessarycatchthrow"); - -} // namespace +loplugin::Plugin::Registration< UnnecessaryCatchThrow > X("unnecessarycatchthrow"); -#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 38e216fed437..7d10a2361878 100644 --- a/compilerplugins/clang/unoany.cxx +++ b/compilerplugins/clang/unoany.cxx @@ -7,12 +7,9 @@ * 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> @@ -20,16 +17,9 @@ class UnoAny: public: explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {} - bool preRun() override { - return compiler.getLangOpts().CPlusPlus; - } - void run() override { - if (preRun()) { - TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); - } + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } - bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr); }; @@ -81,10 +71,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) return true; } -loplugin::Plugin::Registration<UnoAny> unoany("unoany"); - -} // namespace +loplugin::Plugin::Registration<UnoAny> X("unoany"); -#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 82427555fef9..d445aa250623 100644 --- a/compilerplugins/clang/unoquery.cxx +++ b/compilerplugins/clang/unoquery.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include "check.hxx" #include "plugin.hxx" @@ -26,16 +24,7 @@ public: { } - bool preRun() override { return compiler.getLangOpts().CPlusPlus; } - - void run() override - { - if (preRun()) - { - TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); - } - } - + void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*); }; @@ -90,10 +79,7 @@ bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr) return true; } -loplugin::Plugin::Registration<UnoQuery> unoquery("unoquery"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS +loplugin::Plugin::Registration<UnoQuery> unoquery("unoquery", true); +}; /* 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 a0040dd37c30..fbd72955c0ba 100644 --- a/compilerplugins/clang/weakbase.cxx +++ b/compilerplugins/clang/weakbase.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LO_CLANG_SHARED_PLUGINS - #include <string> #include <iostream> #include <map> @@ -30,15 +28,7 @@ public: { } - bool preRun() override { return compiler.getLangOpts().CPlusPlus; } - - void run() override - { - if (preRun()) - { - TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); - } - } + virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitCXXRecordDecl(CXXRecordDecl const*); }; @@ -114,10 +104,7 @@ bool WeakBase::VisitCXXRecordDecl(CXXRecordDecl const* recordDecl) return true; } -loplugin::Plugin::Registration<WeakBase> weakbase("weakbase"); - -} // namespace - -#endif // LO_CLANG_SHARED_PLUGINS +loplugin::Plugin::Registration<WeakBase> WeakBase("weakbase", true); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits