summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-26 11:19:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-26 13:48:13 +0200
commite87761688dd831ff3d8ba1a2a38220053f900f62 (patch)
treee9cc9eed1c684188043c3c45f5671874e896fae2 /compilerplugins
parent761e6dd25782420bf06e4a2ff3205a79b6cbb136 (diff)
use shared-plugin infra for some recent plugins
Change-Id: Ia9cba59718de91fed2045ffd7e0ec06d28bf37dc Reviewed-on: https://gerrit.libreoffice.org/78118 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/mapindex.cxx5
-rw-r--r--compilerplugins/clang/referencecasting.cxx25
-rw-r--r--compilerplugins/clang/returnconstval.cxx5
-rw-r--r--compilerplugins/clang/sequenceloop.cxx5
-rw-r--r--compilerplugins/clang/sharedvisitor/sharedvisitor.cxx85
-rw-r--r--compilerplugins/clang/stringbuffer.cxx28
6 files changed, 136 insertions, 17 deletions
diff --git a/compilerplugins/clang/mapindex.cxx b/compilerplugins/clang/mapindex.cxx
index bf8e38919552..50b1c65921f1 100644
--- a/compilerplugins/clang/mapindex.cxx
+++ b/compilerplugins/clang/mapindex.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 <memory>
#include <cassert>
@@ -98,8 +99,10 @@ bool MapIndex::VisitImplicitCastExpr(const ImplicitCastExpr* implicitCastExpr)
return true;
}
-loplugin::Plugin::Registration<MapIndex> X("mapindex");
+loplugin::Plugin::Registration<MapIndex> mapindex("mapindex");
} // namespace
+#endif // LO_CLANG_SHARED_PLUGINS
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/referencecasting.cxx b/compilerplugins/clang/referencecasting.cxx
index ef11b0b5b942..e5e64f1d133e 100644
--- a/compilerplugins/clang/referencecasting.cxx
+++ b/compilerplugins/clang/referencecasting.cxx
@@ -8,6 +8,7 @@
* License. See LICENSE.TXT for details.
*
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
#include "plugin.hxx"
#include "check.hxx"
@@ -25,6 +26,8 @@ This makes the code simpler and cheaper, because UNO_QUERY can be surprisingly e
*/
+namespace
+{
class ReferenceCasting : public loplugin::FilteringPlugin<ReferenceCasting>
{
public:
@@ -32,15 +35,25 @@ public:
: FilteringPlugin(data)
{
}
- void run() override
+
+ bool preRun() override
{
std::string fn(handler.getMainFileName());
loplugin::normalizeDotDotInFilePath(fn);
// macros
if (fn == SRCDIR "/dbaccess/source/ui/browser/formadapter.cxx")
- return;
- TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ return false;
+ return true;
}
+
+ void run() override
+ {
+ if (preRun())
+ {
+ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ }
+ }
+
bool VisitCXXConstructExpr(const CXXConstructExpr* cce);
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr* mce);
@@ -380,6 +393,10 @@ static bool isDerivedFrom(const CXXRecordDecl* subtypeRecord, const CXXRecordDec
return derivedFromCount(subtypeRecord, baseRecord) == 1;
}
-loplugin::Plugin::Registration<ReferenceCasting> X2("referencecasting");
+loplugin::Plugin::Registration<ReferenceCasting> referencecasting("referencecasting");
+
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/returnconstval.cxx b/compilerplugins/clang/returnconstval.cxx
index 3683149c0ee8..4f8b0ac34348 100644
--- a/compilerplugins/clang/returnconstval.cxx
+++ b/compilerplugins/clang/returnconstval.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 <set>
@@ -70,7 +71,9 @@ bool ReturnConstVal::VisitFunctionDecl(const FunctionDecl* functionDecl)
return true;
}
-loplugin::Plugin::Registration<ReturnConstVal> X("returnconstval");
+loplugin::Plugin::Registration<ReturnConstVal> returnconstval("returnconstval");
}
+#endif // LO_CLANG_SHARED_PLUGINS
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/sequenceloop.cxx b/compilerplugins/clang/sequenceloop.cxx
index 735c57d21b8e..0e6b23893298 100644
--- a/compilerplugins/clang/sequenceloop.cxx
+++ b/compilerplugins/clang/sequenceloop.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 <cassert>
#include <string>
@@ -69,8 +70,10 @@ bool SequenceLoop::VisitCXXForRangeStmt(CXXForRangeStmt const* forStmt)
return true;
}
-loplugin::Plugin::Registration<SequenceLoop> X("sequenceloop");
+loplugin::Plugin::Registration<SequenceLoop> sequenceloop("sequenceloop");
} // 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 0b95aeb711f0..f38156ca4d19 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -34,6 +34,7 @@
#include "../literaltoboolconversion.cxx"
#include "../logexceptionnicely.cxx"
#include "../loopvartoosmall.cxx"
+#include "../mapindex.cxx"
#include "../nestedunnamed.cxx"
#include "../overrideparam.cxx"
#include "../overridevirtual.cxx"
@@ -44,13 +45,17 @@
#include "../redundantfcast.cxx"
#include "../redundantinline.cxx"
#include "../redundantpointerops.cxx"
+#include "../referencecasting.cxx"
#include "../reservedid.cxx"
+#include "../returnconstval.cxx"
#include "../sallogareas.cxx"
#include "../salunicodeliteral.cxx"
+#include "../sequenceloop.cxx"
#include "../sfxpoolitem.cxx"
#include "../simplifyconstruct.cxx"
#include "../staticaccess.cxx"
#include "../staticanonymous.cxx"
+#include "../stringbuffer.cxx"
#include "../stringconcat.cxx"
#include "../stringstatic.cxx"
#include "../subtlezeroinit.cxx"
@@ -105,6 +110,7 @@ public:
, literalToBoolConversion( nullptr )
, logExceptionNicely( nullptr )
, loopVarTooSmall( nullptr )
+ , mapIndex( nullptr )
, nestedUnnamed( nullptr )
, overrideParam( nullptr )
, overrideVirtual( nullptr )
@@ -115,13 +121,17 @@ public:
, redundantFCast( nullptr )
, redundantInline( nullptr )
, redundantPointerOps( nullptr )
+ , referenceCasting( nullptr )
, reservedId( nullptr )
+ , returnConstVal( nullptr )
, salLogAreas( nullptr )
, salUnicodeLiteral( nullptr )
+ , sequenceLoop( nullptr )
, sfxPoolItem( nullptr )
, simplifyConstruct( nullptr )
, staticAccess( nullptr )
, staticAnonymous( nullptr )
+ , stringBuffer( nullptr )
, stringConcat( nullptr )
, stringStatic( nullptr )
, subtleZeroInit( nullptr )
@@ -185,6 +195,8 @@ public:
logExceptionNicely = nullptr;
if( loopVarTooSmall && !loopVarTooSmall->preRun())
loopVarTooSmall = nullptr;
+ if( mapIndex && !mapIndex->preRun())
+ mapIndex = nullptr;
if( nestedUnnamed && !nestedUnnamed->preRun())
nestedUnnamed = nullptr;
if( overrideParam && !overrideParam->preRun())
@@ -205,12 +217,18 @@ public:
redundantInline = nullptr;
if( redundantPointerOps && !redundantPointerOps->preRun())
redundantPointerOps = nullptr;
+ if( referenceCasting && !referenceCasting->preRun())
+ referenceCasting = nullptr;
if( reservedId && !reservedId->preRun())
reservedId = nullptr;
+ if( returnConstVal && !returnConstVal->preRun())
+ returnConstVal = nullptr;
if( salLogAreas && !salLogAreas->preRun())
salLogAreas = nullptr;
if( salUnicodeLiteral && !salUnicodeLiteral->preRun())
salUnicodeLiteral = nullptr;
+ if( sequenceLoop && !sequenceLoop->preRun())
+ sequenceLoop = nullptr;
if( sfxPoolItem && !sfxPoolItem->preRun())
sfxPoolItem = nullptr;
if( simplifyConstruct && !simplifyConstruct->preRun())
@@ -219,6 +237,8 @@ public:
staticAccess = nullptr;
if( staticAnonymous && !staticAnonymous->preRun())
staticAnonymous = nullptr;
+ if( stringBuffer && !stringBuffer->preRun())
+ stringBuffer = nullptr;
if( stringConcat && !stringConcat->preRun())
stringConcat = nullptr;
if( stringStatic && !stringStatic->preRun())
@@ -297,6 +317,8 @@ public:
logExceptionNicely->postRun();
if( loopVarTooSmall )
loopVarTooSmall->postRun();
+ if( mapIndex )
+ mapIndex->postRun();
if( nestedUnnamed )
nestedUnnamed->postRun();
if( overrideParam )
@@ -317,12 +339,18 @@ public:
redundantInline->postRun();
if( redundantPointerOps )
redundantPointerOps->postRun();
+ if( referenceCasting )
+ referenceCasting->postRun();
if( reservedId )
reservedId->postRun();
+ if( returnConstVal )
+ returnConstVal->postRun();
if( salLogAreas )
salLogAreas->postRun();
if( salUnicodeLiteral )
salUnicodeLiteral->postRun();
+ if( sequenceLoop )
+ sequenceLoop->postRun();
if( sfxPoolItem )
sfxPoolItem->postRun();
if( simplifyConstruct )
@@ -331,6 +359,8 @@ public:
staticAccess->postRun();
if( staticAnonymous )
staticAnonymous->postRun();
+ if( stringBuffer )
+ stringBuffer->postRun();
if( stringConcat )
stringConcat->postRun();
if( stringStatic )
@@ -415,6 +445,8 @@ public:
logExceptionNicely = static_cast< LogExceptionNicely* >( plugin );
else if( strcmp( name, "loopvartoosmall" ) == 0 )
loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin );
+ else if( strcmp( name, "mapindex" ) == 0 )
+ mapIndex = static_cast< MapIndex* >( plugin );
else if( strcmp( name, "nestedunnamed" ) == 0 )
nestedUnnamed = static_cast< NestedUnnamed* >( plugin );
else if( strcmp( name, "overrideparam" ) == 0 )
@@ -435,12 +467,18 @@ public:
redundantInline = static_cast< RedundantInline* >( plugin );
else if( strcmp( name, "redundantpointerops" ) == 0 )
redundantPointerOps = static_cast< RedundantPointerOps* >( plugin );
+ else if( strcmp( name, "referencecasting" ) == 0 )
+ referenceCasting = static_cast< ReferenceCasting* >( plugin );
else if( strcmp( name, "reservedid" ) == 0 )
reservedId = static_cast< ReservedId* >( plugin );
+ else if( strcmp( name, "returnconstval" ) == 0 )
+ returnConstVal = static_cast< ReturnConstVal* >( plugin );
else if( strcmp( name, "sallogareas" ) == 0 )
salLogAreas = static_cast< SalLogAreas* >( plugin );
else if( strcmp( name, "salunicodeliteral" ) == 0 )
salUnicodeLiteral = static_cast< SalUnicodeLiteral* >( plugin );
+ else if( strcmp( name, "sequenceloop" ) == 0 )
+ sequenceLoop = static_cast< SequenceLoop* >( plugin );
else if( strcmp( name, "sfxpoolitem" ) == 0 )
sfxPoolItem = static_cast< SfxPoolItem* >( plugin );
else if( strcmp( name, "simplifyconstruct" ) == 0 )
@@ -449,6 +487,8 @@ public:
staticAccess = static_cast< StaticAccess* >( plugin );
else if( strcmp( name, "staticanonymous" ) == 0 )
staticAnonymous = static_cast< StaticAnonymous* >( plugin );
+ else if( strcmp( name, "stringbuffer" ) == 0 )
+ stringBuffer = static_cast< StringBuffer* >( plugin );
else if( strcmp( name, "stringconcat" ) == 0 )
stringConcat = static_cast< StringConcat* >( plugin );
else if( strcmp( name, "stringstatic" ) == 0 )
@@ -605,6 +645,11 @@ public:
if( !redundantFCast->VisitCXXConstructExpr( arg ))
redundantFCast = nullptr;
}
+ if( referenceCasting != nullptr )
+ {
+ if( !referenceCasting->VisitCXXConstructExpr( arg ))
+ referenceCasting = nullptr;
+ }
if( simplifyConstruct != nullptr )
{
if( !simplifyConstruct->VisitCXXConstructExpr( arg ))
@@ -632,6 +677,11 @@ public:
if( !rangedForCopy->VisitCXXForRangeStmt( arg ))
rangedForCopy = nullptr;
}
+ if( sequenceLoop != nullptr )
+ {
+ if( !sequenceLoop->VisitCXXForRangeStmt( arg ))
+ sequenceLoop = nullptr;
+ }
return anyPluginActive();
}
bool VisitCXXFunctionalCastExpr(const class clang::CXXFunctionalCastExpr * arg)
@@ -654,6 +704,16 @@ public:
{
if( ignoreLocation( arg ))
return true;
+ if( referenceCasting != nullptr )
+ {
+ if( !referenceCasting->VisitCXXMemberCallExpr( arg ))
+ referenceCasting = nullptr;
+ }
+ if( stringBuffer != nullptr )
+ {
+ if( !stringBuffer->VisitCXXMemberCallExpr( arg ))
+ stringBuffer = nullptr;
+ }
if( unoQuery != nullptr )
{
if( !unoQuery->VisitCXXMemberCallExpr( arg ))
@@ -954,6 +1014,11 @@ public:
if( !redundantPointerOps->VisitFunctionDecl( arg ))
redundantPointerOps = nullptr;
}
+ if( returnConstVal != nullptr )
+ {
+ if( !returnConstVal->VisitFunctionDecl( arg ))
+ returnConstVal = nullptr;
+ }
if( salLogAreas != nullptr )
{
if( !salLogAreas->VisitFunctionDecl( arg ))
@@ -1012,6 +1077,11 @@ public:
if( !literalToBoolConversion->VisitImplicitCastExpr( arg ))
literalToBoolConversion = nullptr;
}
+ if( mapIndex != nullptr )
+ {
+ if( !mapIndex->VisitImplicitCastExpr( arg ))
+ mapIndex = nullptr;
+ }
if( unicodeToChar != nullptr )
{
if( !unicodeToChar->VisitImplicitCastExpr( arg ))
@@ -1034,6 +1104,11 @@ public:
{
if( ignoreLocation( arg ))
return true;
+ if( mapIndex != nullptr )
+ {
+ if( !mapIndex->VisitMemberExpr( arg ))
+ mapIndex = nullptr;
+ }
if( redundantPointerOps != nullptr )
{
if( !redundantPointerOps->VisitMemberExpr( arg ))
@@ -1458,6 +1533,7 @@ private:
|| literalToBoolConversion != nullptr
|| logExceptionNicely != nullptr
|| loopVarTooSmall != nullptr
+ || mapIndex != nullptr
|| nestedUnnamed != nullptr
|| overrideParam != nullptr
|| overrideVirtual != nullptr
@@ -1468,13 +1544,17 @@ private:
|| redundantFCast != nullptr
|| redundantInline != nullptr
|| redundantPointerOps != nullptr
+ || referenceCasting != nullptr
|| reservedId != nullptr
+ || returnConstVal != nullptr
|| salLogAreas != nullptr
|| salUnicodeLiteral != nullptr
+ || sequenceLoop != nullptr
|| sfxPoolItem != nullptr
|| simplifyConstruct != nullptr
|| staticAccess != nullptr
|| staticAnonymous != nullptr
+ || stringBuffer != nullptr
|| stringConcat != nullptr
|| stringStatic != nullptr
|| subtleZeroInit != nullptr
@@ -1513,6 +1593,7 @@ private:
LiteralToBoolConversion* literalToBoolConversion;
LogExceptionNicely* logExceptionNicely;
LoopVarTooSmall* loopVarTooSmall;
+ MapIndex* mapIndex;
NestedUnnamed* nestedUnnamed;
OverrideParam* overrideParam;
OverrideVirtual* overrideVirtual;
@@ -1523,13 +1604,17 @@ private:
RedundantFCast* redundantFCast;
RedundantInline* redundantInline;
RedundantPointerOps* redundantPointerOps;
+ ReferenceCasting* referenceCasting;
ReservedId* reservedId;
+ ReturnConstVal* returnConstVal;
SalLogAreas* salLogAreas;
SalUnicodeLiteral* salUnicodeLiteral;
+ SequenceLoop* sequenceLoop;
SfxPoolItem* sfxPoolItem;
SimplifyConstruct* simplifyConstruct;
StaticAccess* staticAccess;
StaticAnonymous* staticAnonymous;
+ StringBuffer* stringBuffer;
StringConcat* stringConcat;
StringStatic* stringStatic;
SubtleZeroInit* subtleZeroInit;
diff --git a/compilerplugins/clang/stringbuffer.cxx b/compilerplugins/clang/stringbuffer.cxx
index 154a460a0007..ad8b2eb792a0 100644
--- a/compilerplugins/clang/stringbuffer.cxx
+++ b/compilerplugins/clang/stringbuffer.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"
@@ -23,18 +24,23 @@ public:
{
}
- void run() override;
+ bool preRun() override
+ {
+ StringRef fn(handler.getMainFileName());
+ return !loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/");
+ }
+
+ void run() override
+ {
+ if (preRun())
+ {
+ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+ }
+ }
+
bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*);
};
-void StringBuffer::run()
-{
- StringRef fn(handler.getMainFileName());
- if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/"))
- return;
- TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
-}
-
bool StringBuffer::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr)
{
if (ignoreLocation(memberCallExpr))
@@ -60,8 +66,10 @@ bool StringBuffer::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExp
return true;
}
-loplugin::Plugin::Registration<StringBuffer> X("stringbuffer");
+loplugin::Plugin::Registration<StringBuffer> stringbuffer("stringbuffer");
} // namespace
+#endif // LO_CLANG_SHARED_PLUGINS
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */