to find stuff like OUString s = OUString("xxx") Change-Id: Ie7ed074c1ae012734c67a2a89c564c1900a4ab04 Reviewed-on: https://gerrit.libreoffice.org/70697 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
970 lines
32 KiB
C++
970 lines
32 KiB
C++
// This file is autogenerated. Do not modify.
|
|
// Generated by compilerplugins/clang/sharedvisitor/generator.cxx .
|
|
|
|
#ifdef LO_CLANG_SHARED_PLUGINS
|
|
|
|
#include <config_clang.h>
|
|
|
|
#include <clang/AST/ASTContext.h>
|
|
#include <clang/AST/RecursiveASTVisitor.h>
|
|
|
|
#include "../plugin.hxx"
|
|
|
|
#undef LO_CLANG_SHARED_PLUGINS // to get sources of individual plugins
|
|
#include "../badstatics.cxx"
|
|
#include "../blockblock.cxx"
|
|
#include "../charrightshift.cxx"
|
|
#include "../datamembershadow.cxx"
|
|
#include "../dbgunhandledexception.cxx"
|
|
#include "../derefnullptr.cxx"
|
|
#include "../doubleconvert.cxx"
|
|
#include "../empty.cxx"
|
|
#include "../emptyif.cxx"
|
|
#include "../externandnotdefined.cxx"
|
|
#include "../externvar.cxx"
|
|
#include "../inlinevisible.cxx"
|
|
#include "../loopvartoosmall.cxx"
|
|
#include "../privatebase.cxx"
|
|
#include "../reservedid.cxx"
|
|
#include "../simplifyconstruct.cxx"
|
|
#include "../stringstatic.cxx"
|
|
#include "../subtlezeroinit.cxx"
|
|
#include "../unnecessaryoverride.cxx"
|
|
#include "../unnecessaryparen.cxx"
|
|
#include "../unreffun.cxx"
|
|
#include "../unusedvariablecheck.cxx"
|
|
#include "../weakobject.cxx"
|
|
#include "../dyncastvisibility.cxx"
|
|
#include "../vclwidgets.cxx"
|
|
|
|
using namespace clang;
|
|
using namespace llvm;
|
|
|
|
namespace loplugin
|
|
{
|
|
|
|
class SharedRecursiveASTVisitorBasic
|
|
: public FilteringPlugin< SharedRecursiveASTVisitorBasic>
|
|
{
|
|
public:
|
|
explicit SharedRecursiveASTVisitorBasic(const InstantiationData& rData)
|
|
: FilteringPlugin(rData)
|
|
, badStatics( nullptr )
|
|
, blockBlock( nullptr )
|
|
, charRightShift( nullptr )
|
|
, dataMemberShadow( nullptr )
|
|
, dbgUnhandledException( nullptr )
|
|
, derefNullPtr( nullptr )
|
|
, doubleConvert( nullptr )
|
|
, empty( nullptr )
|
|
, emptyIf( nullptr )
|
|
, externAndNotDefined( nullptr )
|
|
, externVar( nullptr )
|
|
, inlineVisible( nullptr )
|
|
, loopVarTooSmall( nullptr )
|
|
, privateBase( nullptr )
|
|
, reservedId( nullptr )
|
|
, simplifyConstruct( nullptr )
|
|
, stringStatic( nullptr )
|
|
, subtleZeroInit( nullptr )
|
|
, unnecessaryOverride( nullptr )
|
|
, unnecessaryParen( nullptr )
|
|
, unrefFun( nullptr )
|
|
, unusedVariableCheck( nullptr )
|
|
, weakObject( nullptr )
|
|
{}
|
|
virtual bool preRun() override
|
|
{
|
|
if( badStatics && !badStatics->preRun())
|
|
badStatics = nullptr;
|
|
if( blockBlock && !blockBlock->preRun())
|
|
blockBlock = nullptr;
|
|
if( charRightShift && !charRightShift->preRun())
|
|
charRightShift = nullptr;
|
|
if( dataMemberShadow && !dataMemberShadow->preRun())
|
|
dataMemberShadow = nullptr;
|
|
if( dbgUnhandledException && !dbgUnhandledException->preRun())
|
|
dbgUnhandledException = nullptr;
|
|
if( derefNullPtr && !derefNullPtr->preRun())
|
|
derefNullPtr = nullptr;
|
|
if( doubleConvert && !doubleConvert->preRun())
|
|
doubleConvert = nullptr;
|
|
if( empty && !empty->preRun())
|
|
empty = nullptr;
|
|
if( emptyIf && !emptyIf->preRun())
|
|
emptyIf = nullptr;
|
|
if( externAndNotDefined && !externAndNotDefined->preRun())
|
|
externAndNotDefined = nullptr;
|
|
if( externVar && !externVar->preRun())
|
|
externVar = nullptr;
|
|
if( inlineVisible && !inlineVisible->preRun())
|
|
inlineVisible = nullptr;
|
|
if( loopVarTooSmall && !loopVarTooSmall->preRun())
|
|
loopVarTooSmall = nullptr;
|
|
if( privateBase && !privateBase->preRun())
|
|
privateBase = nullptr;
|
|
if( reservedId && !reservedId->preRun())
|
|
reservedId = nullptr;
|
|
if( simplifyConstruct && !simplifyConstruct->preRun())
|
|
simplifyConstruct = nullptr;
|
|
if( stringStatic && !stringStatic->preRun())
|
|
stringStatic = nullptr;
|
|
if( subtleZeroInit && !subtleZeroInit->preRun())
|
|
subtleZeroInit = nullptr;
|
|
if( unnecessaryOverride && !unnecessaryOverride->preRun())
|
|
unnecessaryOverride = nullptr;
|
|
if( unnecessaryParen && !unnecessaryParen->preRun())
|
|
unnecessaryParen = nullptr;
|
|
if( unrefFun && !unrefFun->preRun())
|
|
unrefFun = nullptr;
|
|
if( unusedVariableCheck && !unusedVariableCheck->preRun())
|
|
unusedVariableCheck = nullptr;
|
|
if( weakObject && !weakObject->preRun())
|
|
weakObject = nullptr;
|
|
return anyPluginActive();
|
|
}
|
|
virtual void postRun() override
|
|
{
|
|
if( badStatics )
|
|
badStatics->postRun();
|
|
if( blockBlock )
|
|
blockBlock->postRun();
|
|
if( charRightShift )
|
|
charRightShift->postRun();
|
|
if( dataMemberShadow )
|
|
dataMemberShadow->postRun();
|
|
if( dbgUnhandledException )
|
|
dbgUnhandledException->postRun();
|
|
if( derefNullPtr )
|
|
derefNullPtr->postRun();
|
|
if( doubleConvert )
|
|
doubleConvert->postRun();
|
|
if( empty )
|
|
empty->postRun();
|
|
if( emptyIf )
|
|
emptyIf->postRun();
|
|
if( externAndNotDefined )
|
|
externAndNotDefined->postRun();
|
|
if( externVar )
|
|
externVar->postRun();
|
|
if( inlineVisible )
|
|
inlineVisible->postRun();
|
|
if( loopVarTooSmall )
|
|
loopVarTooSmall->postRun();
|
|
if( privateBase )
|
|
privateBase->postRun();
|
|
if( reservedId )
|
|
reservedId->postRun();
|
|
if( simplifyConstruct )
|
|
simplifyConstruct->postRun();
|
|
if( stringStatic )
|
|
stringStatic->postRun();
|
|
if( subtleZeroInit )
|
|
subtleZeroInit->postRun();
|
|
if( unnecessaryOverride )
|
|
unnecessaryOverride->postRun();
|
|
if( unnecessaryParen )
|
|
unnecessaryParen->postRun();
|
|
if( unrefFun )
|
|
unrefFun->postRun();
|
|
if( unusedVariableCheck )
|
|
unusedVariableCheck->postRun();
|
|
if( weakObject )
|
|
weakObject->postRun();
|
|
}
|
|
virtual void run() override {
|
|
if (preRun()) {
|
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
|
postRun();
|
|
}
|
|
}
|
|
enum { isSharedPlugin = true };
|
|
virtual bool setSharedPlugin( Plugin* plugin, const char* name ) override
|
|
{
|
|
if( strcmp( name, "badstatics" ) == 0 )
|
|
badStatics = static_cast< BadStatics* >( plugin );
|
|
else if( strcmp( name, "blockblock" ) == 0 )
|
|
blockBlock = static_cast< BlockBlock* >( plugin );
|
|
else if( strcmp( name, "charrightshift" ) == 0 )
|
|
charRightShift = static_cast< CharRightShift* >( plugin );
|
|
else if( strcmp( name, "datamembershadow" ) == 0 )
|
|
dataMemberShadow = static_cast< DataMemberShadow* >( plugin );
|
|
else if( strcmp( name, "dbgunhandledexception" ) == 0 )
|
|
dbgUnhandledException = static_cast< DbgUnhandledException* >( plugin );
|
|
else if( strcmp( name, "derefnullptr" ) == 0 )
|
|
derefNullPtr = static_cast< DerefNullPtr* >( plugin );
|
|
else if( strcmp( name, "doubleconvert" ) == 0 )
|
|
doubleConvert = static_cast< DoubleConvert* >( plugin );
|
|
else if( strcmp( name, "empty" ) == 0 )
|
|
empty = static_cast< Empty* >( plugin );
|
|
else if( strcmp( name, "emptyif" ) == 0 )
|
|
emptyIf = static_cast< EmptyIf* >( plugin );
|
|
else if( strcmp( name, "externandnotdefined" ) == 0 )
|
|
externAndNotDefined = static_cast< ExternAndNotDefined* >( plugin );
|
|
else if( strcmp( name, "externvar" ) == 0 )
|
|
externVar = static_cast< ExternVar* >( plugin );
|
|
else if( strcmp( name, "inlinevisible" ) == 0 )
|
|
inlineVisible = static_cast< InlineVisible* >( plugin );
|
|
else if( strcmp( name, "loopvartoosmall" ) == 0 )
|
|
loopVarTooSmall = static_cast< LoopVarTooSmall* >( plugin );
|
|
else if( strcmp( name, "privatebase" ) == 0 )
|
|
privateBase = static_cast< PrivateBase* >( plugin );
|
|
else if( strcmp( name, "reservedid" ) == 0 )
|
|
reservedId = static_cast< ReservedId* >( plugin );
|
|
else if( strcmp( name, "simplifyconstruct" ) == 0 )
|
|
simplifyConstruct = static_cast< SimplifyConstruct* >( 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, "unnecessaryoverride" ) == 0 )
|
|
unnecessaryOverride = static_cast< UnnecessaryOverride* >( plugin );
|
|
else if( strcmp( name, "unnecessaryparen" ) == 0 )
|
|
unnecessaryParen = static_cast< UnnecessaryParen* >( 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, "weakobject" ) == 0 )
|
|
weakObject = static_cast< WeakObject* >( plugin );
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
bool VisitBinEQ(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinEQ( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinGE(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinGE( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinGT(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinGT( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinLE(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinLE( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinLT(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinLT( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinNE(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( empty != nullptr )
|
|
{
|
|
if( !empty->VisitBinNE( arg ))
|
|
empty = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinShr(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( charRightShift != nullptr )
|
|
{
|
|
if( !charRightShift->VisitBinShr( arg ))
|
|
charRightShift = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitBinaryConditionalOperator(const class clang::BinaryConditionalOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitBinaryConditionalOperator( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXConstructExpr(const class clang::CXXConstructExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( simplifyConstruct != nullptr )
|
|
{
|
|
if( !simplifyConstruct->VisitCXXConstructExpr( arg ))
|
|
simplifyConstruct = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitCXXDeleteExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXMethodDecl(const class clang::CXXMethodDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryOverride != nullptr )
|
|
{
|
|
if( !unnecessaryOverride->VisitCXXMethodDecl( arg ))
|
|
unnecessaryOverride = nullptr;
|
|
}
|
|
if( weakObject != nullptr )
|
|
{
|
|
if( !weakObject->VisitCXXMethodDecl( arg ))
|
|
weakObject = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXNewExpr(const class clang::CXXNewExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( subtleZeroInit != nullptr )
|
|
{
|
|
if( !subtleZeroInit->VisitCXXNewExpr( arg ))
|
|
subtleZeroInit = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXOperatorCallExpr(const class clang::CXXOperatorCallExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXRecordDecl(const class clang::CXXRecordDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( privateBase != nullptr )
|
|
{
|
|
if( !privateBase->VisitCXXRecordDecl( arg ))
|
|
privateBase = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCallExpr(const class clang::CallExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( dbgUnhandledException != nullptr )
|
|
{
|
|
if( !dbgUnhandledException->VisitCallExpr( arg ))
|
|
dbgUnhandledException = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitCallExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCaseStmt(const class clang::CaseStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitCaseStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCompoundStmt(const class clang::CompoundStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( blockBlock != nullptr )
|
|
{
|
|
if( !blockBlock->VisitCompoundStmt( arg ))
|
|
blockBlock = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitConditionalOperator(const class clang::ConditionalOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitConditionalOperator( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitDoStmt(const class clang::DoStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( loopVarTooSmall != nullptr )
|
|
{
|
|
if( !loopVarTooSmall->VisitDoStmt( arg ))
|
|
loopVarTooSmall = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitDoStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitFieldDecl(const class clang::FieldDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( dataMemberShadow != nullptr )
|
|
{
|
|
if( !dataMemberShadow->VisitFieldDecl( arg ))
|
|
dataMemberShadow = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitForStmt(const class clang::ForStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( loopVarTooSmall != nullptr )
|
|
{
|
|
if( !loopVarTooSmall->VisitForStmt( arg ))
|
|
loopVarTooSmall = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitForStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitFunctionDecl(const class clang::FunctionDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( externAndNotDefined != nullptr )
|
|
{
|
|
if( !externAndNotDefined->VisitFunctionDecl( arg ))
|
|
externAndNotDefined = nullptr;
|
|
}
|
|
if( inlineVisible != nullptr )
|
|
{
|
|
if( !inlineVisible->VisitFunctionDecl( arg ))
|
|
inlineVisible = nullptr;
|
|
}
|
|
if( unrefFun != nullptr )
|
|
{
|
|
if( !unrefFun->VisitFunctionDecl( arg ))
|
|
unrefFun = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitIfStmt(const class clang::IfStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( emptyIf != nullptr )
|
|
{
|
|
if( !emptyIf->VisitIfStmt( arg ))
|
|
emptyIf = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitIfStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitMaterializeTemporaryExpr(const class clang::MaterializeTemporaryExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( doubleConvert != nullptr )
|
|
{
|
|
if( !doubleConvert->VisitMaterializeTemporaryExpr( arg ))
|
|
doubleConvert = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitMemberExpr(const class clang::MemberExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitMemberExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitNamedDecl(const class clang::NamedDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( reservedId != nullptr )
|
|
{
|
|
if( !reservedId->VisitNamedDecl( arg ))
|
|
reservedId = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitParenExpr(const class clang::ParenExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitParenExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitReturnStmt(const class clang::ReturnStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( stringStatic != nullptr )
|
|
{
|
|
if( !stringStatic->VisitReturnStmt( arg ))
|
|
stringStatic = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitReturnStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitSwitchStmt(const class clang::SwitchStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitSwitchStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitUnaryDeref(const class clang::UnaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( derefNullPtr != nullptr )
|
|
{
|
|
if( !derefNullPtr->VisitUnaryDeref( arg ))
|
|
derefNullPtr = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitUnaryExprOrTypeTraitExpr(const class clang::UnaryExprOrTypeTraitExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitUnaryExprOrTypeTraitExpr( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitVarDecl(const class clang::VarDecl *const arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( badStatics != nullptr )
|
|
{
|
|
if( !badStatics->VisitVarDecl( arg ))
|
|
badStatics = nullptr;
|
|
}
|
|
if( externVar != nullptr )
|
|
{
|
|
if( !externVar->VisitVarDecl( arg ))
|
|
externVar = nullptr;
|
|
}
|
|
if( simplifyConstruct != nullptr )
|
|
{
|
|
if( !simplifyConstruct->VisitVarDecl( arg ))
|
|
simplifyConstruct = nullptr;
|
|
}
|
|
if( stringStatic != nullptr )
|
|
{
|
|
if( !stringStatic->VisitVarDecl( arg ))
|
|
stringStatic = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitVarDecl( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
if( unusedVariableCheck != nullptr )
|
|
{
|
|
if( !unusedVariableCheck->VisitVarDecl( arg ))
|
|
unusedVariableCheck = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitWhileStmt(const class clang::WhileStmt * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( loopVarTooSmall != nullptr )
|
|
{
|
|
if( !loopVarTooSmall->VisitWhileStmt( arg ))
|
|
loopVarTooSmall = nullptr;
|
|
}
|
|
if( unnecessaryParen != nullptr )
|
|
{
|
|
if( !unnecessaryParen->VisitWhileStmt( arg ))
|
|
unnecessaryParen = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr * arg)
|
|
{
|
|
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
|
if( simplifyConstruct != nullptr )
|
|
{
|
|
if( !simplifyConstruct->PreTraverseCXXBindTemporaryExpr( arg ))
|
|
simplifyConstruct = nullptr;
|
|
}
|
|
bool ret = RecursiveASTVisitor::TraverseCXXBindTemporaryExpr( arg );
|
|
simplifyConstruct = saveSimplifyConstruct;
|
|
return ret;
|
|
}
|
|
bool TraverseCXXCatchStmt(class clang::CXXCatchStmt * arg)
|
|
{
|
|
DbgUnhandledException* saveDbgUnhandledException = dbgUnhandledException;
|
|
if( dbgUnhandledException != nullptr )
|
|
{
|
|
if( !dbgUnhandledException->PreTraverseCXXCatchStmt( arg ))
|
|
dbgUnhandledException = nullptr;
|
|
}
|
|
bool ret = RecursiveASTVisitor::TraverseCXXCatchStmt( arg );
|
|
if( dbgUnhandledException != nullptr )
|
|
{
|
|
if( !dbgUnhandledException->PostTraverseCXXCatchStmt( arg, ret ))
|
|
saveDbgUnhandledException = nullptr;
|
|
}
|
|
dbgUnhandledException = saveDbgUnhandledException;
|
|
return ret;
|
|
}
|
|
bool TraverseFriendDecl(class clang::FriendDecl * arg)
|
|
{
|
|
UnrefFun* saveUnrefFun = unrefFun;
|
|
if( unrefFun != nullptr )
|
|
{
|
|
if( !unrefFun->PreTraverseFriendDecl( arg ))
|
|
unrefFun = nullptr;
|
|
}
|
|
bool ret = RecursiveASTVisitor::TraverseFriendDecl( arg );
|
|
if( unrefFun != nullptr )
|
|
{
|
|
if( !unrefFun->PostTraverseFriendDecl( arg, ret ))
|
|
saveUnrefFun = nullptr;
|
|
}
|
|
unrefFun = saveUnrefFun;
|
|
return ret;
|
|
}
|
|
bool TraverseInitListExpr(class clang::InitListExpr * arg)
|
|
{
|
|
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
|
if( simplifyConstruct != nullptr )
|
|
{
|
|
if( !simplifyConstruct->PreTraverseInitListExpr( arg ))
|
|
simplifyConstruct = nullptr;
|
|
}
|
|
bool ret = RecursiveASTVisitor::TraverseInitListExpr( arg );
|
|
simplifyConstruct = saveSimplifyConstruct;
|
|
return ret;
|
|
}
|
|
bool TraverseReturnStmt(class clang::ReturnStmt * arg)
|
|
{
|
|
SimplifyConstruct* saveSimplifyConstruct = simplifyConstruct;
|
|
if( simplifyConstruct != nullptr )
|
|
{
|
|
if( !simplifyConstruct->PreTraverseReturnStmt( arg ))
|
|
simplifyConstruct = nullptr;
|
|
}
|
|
bool ret = RecursiveASTVisitor::TraverseReturnStmt( arg );
|
|
simplifyConstruct = saveSimplifyConstruct;
|
|
return ret;
|
|
}
|
|
private:
|
|
bool anyPluginActive() const
|
|
{
|
|
return badStatics != nullptr
|
|
|| blockBlock != nullptr
|
|
|| charRightShift != nullptr
|
|
|| dataMemberShadow != nullptr
|
|
|| dbgUnhandledException != nullptr
|
|
|| derefNullPtr != nullptr
|
|
|| doubleConvert != nullptr
|
|
|| empty != nullptr
|
|
|| emptyIf != nullptr
|
|
|| externAndNotDefined != nullptr
|
|
|| externVar != nullptr
|
|
|| inlineVisible != nullptr
|
|
|| loopVarTooSmall != nullptr
|
|
|| privateBase != nullptr
|
|
|| reservedId != nullptr
|
|
|| simplifyConstruct != nullptr
|
|
|| stringStatic != nullptr
|
|
|| subtleZeroInit != nullptr
|
|
|| unnecessaryOverride != nullptr
|
|
|| unnecessaryParen != nullptr
|
|
|| unrefFun != nullptr
|
|
|| unusedVariableCheck != nullptr
|
|
|| weakObject != nullptr;
|
|
}
|
|
BadStatics* badStatics;
|
|
BlockBlock* blockBlock;
|
|
CharRightShift* charRightShift;
|
|
DataMemberShadow* dataMemberShadow;
|
|
DbgUnhandledException* dbgUnhandledException;
|
|
DerefNullPtr* derefNullPtr;
|
|
DoubleConvert* doubleConvert;
|
|
Empty* empty;
|
|
EmptyIf* emptyIf;
|
|
ExternAndNotDefined* externAndNotDefined;
|
|
ExternVar* externVar;
|
|
InlineVisible* inlineVisible;
|
|
LoopVarTooSmall* loopVarTooSmall;
|
|
PrivateBase* privateBase;
|
|
ReservedId* reservedId;
|
|
SimplifyConstruct* simplifyConstruct;
|
|
StringStatic* stringStatic;
|
|
SubtleZeroInit* subtleZeroInit;
|
|
UnnecessaryOverride* unnecessaryOverride;
|
|
UnnecessaryParen* unnecessaryParen;
|
|
UnrefFun* unrefFun;
|
|
UnusedVariableCheck* unusedVariableCheck;
|
|
WeakObject* weakObject;
|
|
};
|
|
|
|
loplugin::Plugin::Registration< SharedRecursiveASTVisitorBasic > registrationBasic("sharedvisitorBasic");
|
|
|
|
|
|
class SharedRecursiveASTVisitorVisitTemplates
|
|
: public FilteringPlugin< SharedRecursiveASTVisitorVisitTemplates>
|
|
{
|
|
public:
|
|
explicit SharedRecursiveASTVisitorVisitTemplates(const InstantiationData& rData)
|
|
: FilteringPlugin(rData)
|
|
, dynCastVisibility( nullptr )
|
|
, vCLWidgets( nullptr )
|
|
{}
|
|
virtual bool preRun() override
|
|
{
|
|
if( dynCastVisibility && !dynCastVisibility->preRun())
|
|
dynCastVisibility = nullptr;
|
|
if( vCLWidgets && !vCLWidgets->preRun())
|
|
vCLWidgets = nullptr;
|
|
return anyPluginActive();
|
|
}
|
|
virtual void postRun() override
|
|
{
|
|
if( dynCastVisibility )
|
|
dynCastVisibility->postRun();
|
|
if( vCLWidgets )
|
|
vCLWidgets->postRun();
|
|
}
|
|
virtual void run() override {
|
|
if (preRun()) {
|
|
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
|
|
postRun();
|
|
}
|
|
}
|
|
enum { isSharedPlugin = true };
|
|
virtual bool setSharedPlugin( Plugin* plugin, const char* name ) override
|
|
{
|
|
if( strcmp( name, "dyncastvisibility" ) == 0 )
|
|
dynCastVisibility = static_cast< DynCastVisibility* >( plugin );
|
|
else if( strcmp( name, "vclwidgets" ) == 0 )
|
|
vCLWidgets = static_cast< VCLWidgets* >( plugin );
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
bool shouldVisitTemplateInstantiations() const { return true; }
|
|
bool VisitBinaryOperator(const class clang::BinaryOperator * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitBinaryOperator( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXConstructExpr(const class clang::CXXConstructExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitCXXConstructExpr( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitCXXDeleteExpr( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXDestructorDecl(const class clang::CXXDestructorDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitCXXDestructorDecl( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCXXDynamicCastExpr(const class clang::CXXDynamicCastExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( dynCastVisibility != nullptr )
|
|
{
|
|
if( !dynCastVisibility->VisitCXXDynamicCastExpr( arg ))
|
|
dynCastVisibility = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitCallExpr(const class clang::CallExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitCallExpr( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitDeclRefExpr(const class clang::DeclRefExpr * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitDeclRefExpr( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitFieldDecl(const class clang::FieldDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitFieldDecl( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitFunctionDecl(const class clang::FunctionDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitFunctionDecl( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitParmVarDecl(const class clang::ParmVarDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitParmVarDecl( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
bool VisitVarDecl(const class clang::VarDecl * arg)
|
|
{
|
|
if( ignoreLocation( arg ))
|
|
return true;
|
|
if( vCLWidgets != nullptr )
|
|
{
|
|
if( !vCLWidgets->VisitVarDecl( arg ))
|
|
vCLWidgets = nullptr;
|
|
}
|
|
return anyPluginActive();
|
|
}
|
|
private:
|
|
bool anyPluginActive() const
|
|
{
|
|
return dynCastVisibility != nullptr
|
|
|| vCLWidgets != nullptr;
|
|
}
|
|
DynCastVisibility* dynCastVisibility;
|
|
VCLWidgets* vCLWidgets;
|
|
};
|
|
|
|
loplugin::Plugin::Registration< SharedRecursiveASTVisitorVisitTemplates > registrationVisitTemplates("sharedvisitorVisitTemplates");
|
|
|
|
} // namespace loplugin
|
|
|
|
#endif // LO_CLANG_SHARED_PLUGINS
|