summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/sharedvisitor
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 15:21:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-17 10:42:48 +0200
commit5f4ae86cfe05f6e4d42c9b106e2f6b0e348e890d (patch)
tree39c1723981dbacc71c4572521559a50c394a8f75 /compilerplugins/clang/sharedvisitor
parent8e3f4317823aa83e0ad9e7dc008a1550ef3c9798 (diff)
make passparamsbyref a shared plugin
Change-Id: I4119122f1bca77ee1424abdd90b0a0956b991704 Reviewed-on: https://gerrit.libreoffice.org/75743 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/sharedvisitor')
-rw-r--r--compilerplugins/clang/sharedvisitor/sharedvisitor.cxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index f3fe66c98fa2..f2b6906541fe 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -26,6 +26,7 @@
#include "../loopvartoosmall.cxx"
#include "../overrideparam.cxx"
#include "../overridevirtual.cxx"
+#include "../passparamsbyref.cxx"
#include "../pointerbool.cxx"
#include "../privatebase.cxx"
#include "../rangedforcopy.cxx"
@@ -84,6 +85,7 @@ public:
, loopVarTooSmall( nullptr )
, overrideParam( nullptr )
, overrideVirtual( nullptr )
+ , passParamsByRef( nullptr )
, pointerBool( nullptr )
, privateBase( nullptr )
, rangedForCopy( nullptr )
@@ -144,6 +146,8 @@ public:
overrideParam = nullptr;
if( overrideVirtual && !overrideVirtual->preRun())
overrideVirtual = nullptr;
+ if( passParamsByRef && !passParamsByRef->preRun())
+ passParamsByRef = nullptr;
if( pointerBool && !pointerBool->preRun())
pointerBool = nullptr;
if( privateBase && !privateBase->preRun())
@@ -232,6 +236,8 @@ public:
overrideParam->postRun();
if( overrideVirtual )
overrideVirtual->postRun();
+ if( passParamsByRef )
+ passParamsByRef->postRun();
if( pointerBool )
pointerBool->postRun();
if( privateBase )
@@ -326,6 +332,8 @@ public:
overrideParam = static_cast< OverrideParam* >( plugin );
else if( strcmp( name, "overridevirtual" ) == 0 )
overrideVirtual = static_cast< OverrideVirtual* >( plugin );
+ else if( strcmp( name, "passparamsbyref" ) == 0 )
+ passParamsByRef = static_cast< PassParamsByRef* >( plugin );
else if( strcmp( name, "pointerbool" ) == 0 )
pointerBool = static_cast< PointerBool* >( plugin );
else if( strcmp( name, "privatebase" ) == 0 )
@@ -384,6 +392,17 @@ public:
return false;
return true;
}
+ bool VisitBinAssign(const class clang::BinaryOperator * arg)
+ {
+ if( ignoreLocation( arg ))
+ return true;
+ if( passParamsByRef != nullptr )
+ {
+ if( !passParamsByRef->VisitBinAssign( arg ))
+ passParamsByRef = nullptr;
+ }
+ return anyPluginActive();
+ }
bool VisitBinEQ(const class clang::BinaryOperator * arg)
{
if( ignoreLocation( arg ))
@@ -594,6 +613,11 @@ public:
{
if( ignoreLocation( arg ))
return true;
+ if( passParamsByRef != nullptr )
+ {
+ if( !passParamsByRef->VisitCXXOperatorCallExpr( arg ))
+ passParamsByRef = nullptr;
+ }
if( unnecessaryParen != nullptr )
{
if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
@@ -1102,6 +1126,34 @@ public:
unrefFun = saveUnrefFun;
return ret;
}
+ bool TraverseFunctionDecl(class clang::FunctionDecl * arg)
+ {
+ PassParamsByRef* savePassParamsByRef = passParamsByRef;
+ if( passParamsByRef != nullptr )
+ {
+ if( !passParamsByRef->PreTraverseFunctionDecl( arg ))
+ passParamsByRef = nullptr;
+ }
+ bool ret = RecursiveASTVisitor::TraverseFunctionDecl( arg );
+ if( passParamsByRef != nullptr )
+ {
+ passParamsByRef->PostTraverseFunctionDecl( arg );
+ }
+ passParamsByRef = savePassParamsByRef;
+ return ret;
+ }
+ bool TraverseImplicitCastExpr(class clang::ImplicitCastExpr * arg)
+ {
+ PassParamsByRef* savePassParamsByRef = passParamsByRef;
+ if( passParamsByRef != nullptr )
+ {
+ if( !passParamsByRef->PreTraverseImplicitCastExpr( arg ))
+ passParamsByRef = nullptr;
+ }
+ bool ret = RecursiveASTVisitor::TraverseImplicitCastExpr( arg );
+ passParamsByRef = savePassParamsByRef;
+ return ret;
+ }
bool TraverseInitListExpr(class clang::InitListExpr * arg)
{
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
@@ -1144,6 +1196,7 @@ private:
|| loopVarTooSmall != nullptr
|| overrideParam != nullptr
|| overrideVirtual != nullptr
+ || passParamsByRef != nullptr
|| pointerBool != nullptr
|| privateBase != nullptr
|| rangedForCopy != nullptr
@@ -1187,6 +1240,7 @@ private:
LoopVarTooSmall* loopVarTooSmall;
OverrideParam* overrideParam;
OverrideVirtual* overrideVirtual;
+ PassParamsByRef* passParamsByRef;
PointerBool* pointerBool;
PrivateBase* privateBase;
RangedForCopy* rangedForCopy;