summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 08:13:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 09:15:01 +0200
commit8d4fbc532e2058a906b06471501385404ff31541 (patch)
treef6e0116d76e605395bc05444e2eece0574da9ba2 /compilerplugins
parent5521ac4e152dc9159ac7f7d86d9d2addef443cf4 (diff)
convert some plugins to LO_CLANG_SHARED_PLUGINS
Change-Id: I7451a95377101004c7c53c918f3234415e06f555 Reviewed-on: https://gerrit.libreoffice.org/75670 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/salunicodeliteral.cxx22
-rw-r--r--compilerplugins/clang/sfxpoolitem.cxx7
-rw-r--r--compilerplugins/clang/sharedvisitor/sharedvisitor.cxx267
-rw-r--r--compilerplugins/clang/staticaccess.cxx8
-rw-r--r--compilerplugins/clang/staticanonymous.cxx10
-rw-r--r--compilerplugins/clang/stringconcat.cxx8
-rw-r--r--compilerplugins/clang/typedefparam.cxx11
-rw-r--r--compilerplugins/clang/unicodetochar.cxx52
-rw-r--r--compilerplugins/clang/unnecessarycatchthrow.cxx8
-rw-r--r--compilerplugins/clang/unoany.cxx17
-rw-r--r--compilerplugins/clang/unoquery.cxx20
-rw-r--r--compilerplugins/clang/weakbase.cxx19
12 files changed, 408 insertions, 41 deletions
diff --git a/compilerplugins/clang/salunicodeliteral.cxx b/compilerplugins/clang/salunicodeliteral.cxx
index bdf83694b77e..4c2a00669ab0 100644
--- a/compilerplugins/clang/salunicodeliteral.cxx
+++ b/compilerplugins/clang/salunicodeliteral.cxx
@@ -6,6 +6,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
#include "check.hxx"
#include "plugin.hxx"
@@ -41,16 +42,18 @@ public:
return true;
}
-private:
- void run() override {
- if (compiler.getLangOpts().CPlusPlus
+ bool preRun() override {
+ return compiler.getLangOpts().CPlusPlus
&& compiler.getPreprocessor().getIdentifierInfo(
- "LIBO_INTERNAL_ONLY")->hasMacroDefinition())
- {
+ "LIBO_INTERNAL_ONLY")->hasMacroDefinition();
+ }
+
+ void run() override {
+ if (preRun())
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
- }
}
+private:
void check(ExplicitCastExpr const * expr) {
if (ignoreLocation(expr)
|| isInUnoIncludeFile(expr->getExprLoc()))
@@ -90,9 +93,10 @@ private:
}
};
-static loplugin::Plugin::Registration<SalUnicodeLiteral> reg(
- "salunicodeliteral");
+static loplugin::Plugin::Registration<SalUnicodeLiteral> salunicodeliteral("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 bd2870fe06d3..ce52336c8e04 100644
--- a/compilerplugins/clang/sfxpoolitem.cxx
+++ b/compilerplugins/clang/sfxpoolitem.cxx
@@ -6,6 +6,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
#include <string>
#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: */
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index a6df13ca33b4..4532bbe250ca 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -26,13 +26,24 @@
#include "../loopvartoosmall.cxx"
#include "../privatebase.cxx"
#include "../reservedid.cxx"
+#include "../salunicodeliteral.cxx"
+#include "../sfxpoolitem.cxx"
#include "../simplifyconstruct.cxx"
+#include "../staticaccess.cxx"
+#include "../staticanonymous.cxx"
+#include "../stringconcat.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"
@@ -64,13 +75,24 @@ public:
, loopVarTooSmall( nullptr )
, privateBase( nullptr )
, reservedId( nullptr )
+ , salUnicodeLiteral( nullptr )
+ , sfxPoolItem( nullptr )
, simplifyConstruct( nullptr )
+ , staticAccess( nullptr )
+ , staticAnonymous( nullptr )
+ , stringConcat( 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
@@ -105,20 +127,42 @@ 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( staticAccess && !staticAccess->preRun())
+ staticAccess = nullptr;
+ if( staticAnonymous && !staticAnonymous->preRun())
+ staticAnonymous = nullptr;
+ if( stringConcat && !stringConcat->preRun())
+ stringConcat = 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();
@@ -155,20 +199,42 @@ public:
privateBase->postRun();
if( reservedId )
reservedId->postRun();
+ if( salUnicodeLiteral )
+ salUnicodeLiteral->postRun();
+ if( sfxPoolItem )
+ sfxPoolItem->postRun();
if( simplifyConstruct )
simplifyConstruct->postRun();
+ if( staticAccess )
+ staticAccess->postRun();
+ if( staticAnonymous )
+ staticAnonymous->postRun();
+ if( stringConcat )
+ stringConcat->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();
}
@@ -211,20 +277,42 @@ 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, "staticaccess" ) == 0 )
+ staticAccess = static_cast< StaticAccess* >( plugin );
+ else if( strcmp( name, "staticanonymous" ) == 0 )
+ staticAnonymous = static_cast< StaticAnonymous* >( plugin );
+ else if( strcmp( name, "stringconcat" ) == 0 )
+ stringConcat = static_cast< StringConcat* >( 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
@@ -319,6 +407,17 @@ 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 ))
@@ -341,10 +440,37 @@ public:
}
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 ))
@@ -377,6 +503,11 @@ 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)
@@ -388,6 +519,38 @@ 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;
+ }
+ 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)
@@ -399,6 +562,11 @@ public:
if( !dbgUnhandledException->VisitCallExpr( arg ))
dbgUnhandledException = nullptr;
}
+ if( stringConcat != nullptr )
+ {
+ if( !stringConcat->VisitCallExpr( arg ))
+ stringConcat = nullptr;
+ }
if( unnecessaryParen != nullptr )
{
if( !unnecessaryParen->VisitCallExpr( arg ))
@@ -501,6 +669,16 @@ 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 ))
@@ -524,6 +702,17 @@ 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 ))
@@ -539,6 +728,11 @@ public:
{
if( ignoreLocation( arg ))
return true;
+ if( staticAccess != nullptr )
+ {
+ if( !staticAccess->VisitMemberExpr( arg ))
+ staticAccess = nullptr;
+ }
if( unnecessaryParen != nullptr )
{
if( !unnecessaryParen->VisitMemberExpr( arg ))
@@ -669,6 +863,23 @@ public:
}
return anyPluginActive();
}
+ bool TraverseCStyleCastExpr(class clang::CStyleCastExpr * arg)
+ {
+ UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PreTraverseCStyleCastExpr( arg ))
+ unicodeToChar = nullptr;
+ }
+ bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr( arg );
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PostTraverseCStyleCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
+ }
+ unicodeToChar = saveUnicodeToChar;
+ return ret;
+ }
bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr * arg)
{
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
@@ -698,6 +909,40 @@ public:
dbgUnhandledException = saveDbgUnhandledException;
return ret;
}
+ bool TraverseCXXFunctionalCastExpr(class clang::CXXFunctionalCastExpr * arg)
+ {
+ UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PreTraverseCXXFunctionalCastExpr( arg ))
+ unicodeToChar = nullptr;
+ }
+ bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr( arg );
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PostTraverseCXXFunctionalCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
+ }
+ unicodeToChar = saveUnicodeToChar;
+ return ret;
+ }
+ bool TraverseCXXStaticCastExpr(class clang::CXXStaticCastExpr * arg)
+ {
+ UnicodeToChar* saveUnicodeToChar = unicodeToChar;
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PreTraverseCXXStaticCastExpr( arg ))
+ unicodeToChar = nullptr;
+ }
+ bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr( arg );
+ if( unicodeToChar != nullptr )
+ {
+ if( !unicodeToChar->PostTraverseCXXStaticCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
+ }
+ unicodeToChar = saveUnicodeToChar;
+ return ret;
+ }
bool TraverseFriendDecl(class clang::FriendDecl * arg)
{
UnrefFun* saveUnrefFun = unrefFun;
@@ -757,13 +1002,24 @@ private:
|| loopVarTooSmall != nullptr
|| privateBase != nullptr
|| reservedId != nullptr
+ || salUnicodeLiteral != nullptr
+ || sfxPoolItem != nullptr
|| simplifyConstruct != nullptr
+ || staticAccess != nullptr
+ || staticAnonymous != nullptr
+ || stringConcat != 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;
@@ -781,13 +1037,24 @@ private:
LoopVarTooSmall* loopVarTooSmall;
PrivateBase* privateBase;
ReservedId* reservedId;
+ SalUnicodeLiteral* salUnicodeLiteral;
+ SfxPoolItem* sfxPoolItem;
SimplifyConstruct* simplifyConstruct;
+ StaticAccess* staticAccess;
+ StaticAnonymous* staticAnonymous;
+ StringConcat* stringConcat;
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/staticaccess.cxx b/compilerplugins/clang/staticaccess.cxx
index 6b15bfb15349..9c1abbc5cba4 100644
--- a/compilerplugins/clang/staticaccess.cxx
+++ b/compilerplugins/clang/staticaccess.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <cassert>
#include "plugin.hxx"
@@ -89,8 +91,10 @@ bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) {
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: */
diff --git a/compilerplugins/clang/staticanonymous.cxx b/compilerplugins/clang/staticanonymous.cxx
index f31499af6f73..0fd00f2279e7 100644
--- a/compilerplugins/clang/staticanonymous.cxx
+++ b/compilerplugins/clang/staticanonymous.cxx
@@ -5,6 +5,8 @@
* Based on LLVM/Clang.
*
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include "plugin.hxx"
/*
@@ -22,7 +24,7 @@ class StaticAnonymous
public:
explicit StaticAnonymous( const InstantiationData& data );
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 ) )
@@ -59,8 +61,10 @@ bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
}
// Register the plugin action with the LO plugin handling.
-static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true);
+static Plugin::Registration< StaticAnonymous > staticanonymous("staticanonymous");
} // namespace
+#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 da4b212e9f73..8511f849d64f 100644
--- a/compilerplugins/clang/stringconcat.cxx
+++ b/compilerplugins/clang/stringconcat.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include "plugin.hxx"
#include "check.hxx"
@@ -151,8 +153,10 @@ bool StringConcat::isStringLiteral(Expr const * expr) {
!= "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: */
diff --git a/compilerplugins/clang/typedefparam.cxx b/compilerplugins/clang/typedefparam.cxx
index 0b7a74ba1696..2c7031ff7af0 100644
--- a/compilerplugins/clang/typedefparam.cxx
+++ b/compilerplugins/clang/typedefparam.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <cassert>
#include <string>
#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 VisitCXXMethodDecl(CXXMethodDecl const*);
@@ -321,7 +323,10 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
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: */
diff --git a/compilerplugins/clang/unicodetochar.cxx b/compilerplugins/clang/unicodetochar.cxx
index e1e381ad2c71..3599d3081a9f 100644
--- a/compilerplugins/clang/unicodetochar.cxx
+++ b/compilerplugins/clang/unicodetochar.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <stack>
#include "check.hxx"
@@ -24,24 +26,48 @@ public:
explicit UnicodeToChar(loplugin::InstantiationData const & data):
FilteringPlugin(data) {}
- bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+ bool PreTraverseCStyleCastExpr(CStyleCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCStyleCastExpr(CStyleCastExpr *, bool ) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+ PreTraverseCStyleCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+ PostTraverseCStyleCastExpr(expr, ret);
return ret;
}
- bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+ bool PreTraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCXXStaticCastExpr(CXXStaticCastExpr *, bool) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+ PreTraverseCXXStaticCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+ PostTraverseCXXStaticCastExpr(expr, ret);
return ret;
}
- bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+ bool PreTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr *, bool) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+ PreTraverseCXXFunctionalCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+ PostTraverseCXXFunctionalCastExpr(expr, ret);
return ret;
}
@@ -72,18 +98,24 @@ public:
return true;
}
-private:
+ bool preRun() override {
+ return compiler.getLangOpts().CPlusPlus;
+ }
+
void run() override {
- if (compiler.getLangOpts().CPlusPlus) {
+ if (preRun()) {
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
}
+private:
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: */
diff --git a/compilerplugins/clang/unnecessarycatchthrow.cxx b/compilerplugins/clang/unnecessarycatchthrow.cxx
index 73cb01456a40..903e903823ab 100644
--- a/compilerplugins/clang/unnecessarycatchthrow.cxx
+++ b/compilerplugins/clang/unnecessarycatchthrow.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <cassert>
#include <string>
#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: */
diff --git a/compilerplugins/clang/unoany.cxx b/compilerplugins/clang/unoany.cxx
index 7d10a2361878..38e216fed437 100644
--- a/compilerplugins/clang/unoany.cxx
+++ b/compilerplugins/clang/unoany.cxx
@@ -7,9 +7,12 @@
* 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>
@@ -17,9 +20,16 @@ class UnoAny:
public:
explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
+ bool preRun() override {
+ return compiler.getLangOpts().CPlusPlus;
+ }
+
void run() override {
- TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ if (preRun()) {
+ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ }
}
+
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
};
@@ -71,7 +81,10 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
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: */
diff --git a/compilerplugins/clang/unoquery.cxx b/compilerplugins/clang/unoquery.cxx
index d445aa250623..82427555fef9 100644
--- a/compilerplugins/clang/unoquery.cxx
+++ b/compilerplugins/clang/unoquery.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include "check.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*);
};
@@ -79,7 +90,10 @@ bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr)
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: */
diff --git a/compilerplugins/clang/weakbase.cxx b/compilerplugins/clang/weakbase.cxx
index fbd72955c0ba..a0040dd37c30 100644
--- a/compilerplugins/clang/weakbase.cxx
+++ b/compilerplugins/clang/weakbase.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <string>
#include <iostream>
#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*);
};
@@ -104,7 +114,10 @@ bool WeakBase::VisitCXXRecordDecl(CXXRecordDecl const* recordDecl)
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: */