1 // This file is autogenerated. Do not modify.
2 // Generated by compilerplugins/clang/sharedvisitor/generator.cxx .
4 #ifdef LO_CLANG_SHARED_PLUGINS
6 #include <config_clang.h>
8 #include <clang/AST/ASTContext.h>
9 #include <clang/AST/RecursiveASTVisitor.h>
11 #include "../plugin.hxx"
13 #undef LO_CLANG_SHARED_PLUGINS // to get sources of individual plugins
14 #include "../badstatics.cxx"
15 #include "../blockblock.cxx"
16 #include "../charrightshift.cxx"
17 #include "../datamembershadow.cxx"
18 #include "../dbgunhandledexception.cxx"
19 #include "../derefnullptr.cxx"
20 #include "../doubleconvert.cxx"
21 #include "../empty.cxx"
22 #include "../emptyif.cxx"
23 #include "../externandnotdefined.cxx"
24 #include "../externvar.cxx"
25 #include "../inlinevisible.cxx"
26 #include "../loopvartoosmall.cxx"
27 #include "../privatebase.cxx"
28 #include "../reservedid.cxx"
29 #include "../simplifyconstruct.cxx"
30 #include "../stringstatic.cxx"
31 #include "../subtlezeroinit.cxx"
32 #include "../unnecessaryoverride.cxx"
33 #include "../unnecessaryparen.cxx"
34 #include "../unreffun.cxx"
35 #include "../unusedvariablecheck.cxx"
36 #include "../weakobject.cxx"
37 #include "../dyncastvisibility.cxx"
38 #include "../vclwidgets.cxx"
40 using namespace clang
;
46 class SharedRecursiveASTVisitorBasic
47 : public FilteringPlugin
< SharedRecursiveASTVisitorBasic
>
50 explicit SharedRecursiveASTVisitorBasic(const InstantiationData
& rData
)
51 : FilteringPlugin(rData
)
52 , badStatics( nullptr )
53 , blockBlock( nullptr )
54 , charRightShift( nullptr )
55 , dataMemberShadow( nullptr )
56 , dbgUnhandledException( nullptr )
57 , derefNullPtr( nullptr )
58 , doubleConvert( nullptr )
61 , externAndNotDefined( nullptr )
62 , externVar( nullptr )
63 , inlineVisible( nullptr )
64 , loopVarTooSmall( nullptr )
65 , privateBase( nullptr )
66 , reservedId( nullptr )
67 , simplifyConstruct( nullptr )
68 , stringStatic( nullptr )
69 , subtleZeroInit( nullptr )
70 , unnecessaryOverride( nullptr )
71 , unnecessaryParen( nullptr )
73 , unusedVariableCheck( nullptr )
74 , weakObject( nullptr )
76 virtual bool preRun() override
78 if( badStatics
&& !badStatics
->preRun())
80 if( blockBlock
&& !blockBlock
->preRun())
82 if( charRightShift
&& !charRightShift
->preRun())
83 charRightShift
= nullptr;
84 if( dataMemberShadow
&& !dataMemberShadow
->preRun())
85 dataMemberShadow
= nullptr;
86 if( dbgUnhandledException
&& !dbgUnhandledException
->preRun())
87 dbgUnhandledException
= nullptr;
88 if( derefNullPtr
&& !derefNullPtr
->preRun())
89 derefNullPtr
= nullptr;
90 if( doubleConvert
&& !doubleConvert
->preRun())
91 doubleConvert
= nullptr;
92 if( empty
&& !empty
->preRun())
94 if( emptyIf
&& !emptyIf
->preRun())
96 if( externAndNotDefined
&& !externAndNotDefined
->preRun())
97 externAndNotDefined
= nullptr;
98 if( externVar
&& !externVar
->preRun())
100 if( inlineVisible
&& !inlineVisible
->preRun())
101 inlineVisible
= nullptr;
102 if( loopVarTooSmall
&& !loopVarTooSmall
->preRun())
103 loopVarTooSmall
= nullptr;
104 if( privateBase
&& !privateBase
->preRun())
105 privateBase
= nullptr;
106 if( reservedId
&& !reservedId
->preRun())
107 reservedId
= nullptr;
108 if( simplifyConstruct
&& !simplifyConstruct
->preRun())
109 simplifyConstruct
= nullptr;
110 if( stringStatic
&& !stringStatic
->preRun())
111 stringStatic
= nullptr;
112 if( subtleZeroInit
&& !subtleZeroInit
->preRun())
113 subtleZeroInit
= nullptr;
114 if( unnecessaryOverride
&& !unnecessaryOverride
->preRun())
115 unnecessaryOverride
= nullptr;
116 if( unnecessaryParen
&& !unnecessaryParen
->preRun())
117 unnecessaryParen
= nullptr;
118 if( unrefFun
&& !unrefFun
->preRun())
120 if( unusedVariableCheck
&& !unusedVariableCheck
->preRun())
121 unusedVariableCheck
= nullptr;
122 if( weakObject
&& !weakObject
->preRun())
123 weakObject
= nullptr;
124 return anyPluginActive();
126 virtual void postRun() override
129 badStatics
->postRun();
131 blockBlock
->postRun();
133 charRightShift
->postRun();
134 if( dataMemberShadow
)
135 dataMemberShadow
->postRun();
136 if( dbgUnhandledException
)
137 dbgUnhandledException
->postRun();
139 derefNullPtr
->postRun();
141 doubleConvert
->postRun();
146 if( externAndNotDefined
)
147 externAndNotDefined
->postRun();
149 externVar
->postRun();
151 inlineVisible
->postRun();
152 if( loopVarTooSmall
)
153 loopVarTooSmall
->postRun();
155 privateBase
->postRun();
157 reservedId
->postRun();
158 if( simplifyConstruct
)
159 simplifyConstruct
->postRun();
161 stringStatic
->postRun();
163 subtleZeroInit
->postRun();
164 if( unnecessaryOverride
)
165 unnecessaryOverride
->postRun();
166 if( unnecessaryParen
)
167 unnecessaryParen
->postRun();
170 if( unusedVariableCheck
)
171 unusedVariableCheck
->postRun();
173 weakObject
->postRun();
175 virtual void run() override
{
177 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
181 enum { isSharedPlugin
= true };
182 virtual bool setSharedPlugin( Plugin
* plugin
, const char* name
) override
184 if( strcmp( name
, "badstatics" ) == 0 )
185 badStatics
= static_cast< BadStatics
* >( plugin
);
186 else if( strcmp( name
, "blockblock" ) == 0 )
187 blockBlock
= static_cast< BlockBlock
* >( plugin
);
188 else if( strcmp( name
, "charrightshift" ) == 0 )
189 charRightShift
= static_cast< CharRightShift
* >( plugin
);
190 else if( strcmp( name
, "datamembershadow" ) == 0 )
191 dataMemberShadow
= static_cast< DataMemberShadow
* >( plugin
);
192 else if( strcmp( name
, "dbgunhandledexception" ) == 0 )
193 dbgUnhandledException
= static_cast< DbgUnhandledException
* >( plugin
);
194 else if( strcmp( name
, "derefnullptr" ) == 0 )
195 derefNullPtr
= static_cast< DerefNullPtr
* >( plugin
);
196 else if( strcmp( name
, "doubleconvert" ) == 0 )
197 doubleConvert
= static_cast< DoubleConvert
* >( plugin
);
198 else if( strcmp( name
, "empty" ) == 0 )
199 empty
= static_cast< Empty
* >( plugin
);
200 else if( strcmp( name
, "emptyif" ) == 0 )
201 emptyIf
= static_cast< EmptyIf
* >( plugin
);
202 else if( strcmp( name
, "externandnotdefined" ) == 0 )
203 externAndNotDefined
= static_cast< ExternAndNotDefined
* >( plugin
);
204 else if( strcmp( name
, "externvar" ) == 0 )
205 externVar
= static_cast< ExternVar
* >( plugin
);
206 else if( strcmp( name
, "inlinevisible" ) == 0 )
207 inlineVisible
= static_cast< InlineVisible
* >( plugin
);
208 else if( strcmp( name
, "loopvartoosmall" ) == 0 )
209 loopVarTooSmall
= static_cast< LoopVarTooSmall
* >( plugin
);
210 else if( strcmp( name
, "privatebase" ) == 0 )
211 privateBase
= static_cast< PrivateBase
* >( plugin
);
212 else if( strcmp( name
, "reservedid" ) == 0 )
213 reservedId
= static_cast< ReservedId
* >( plugin
);
214 else if( strcmp( name
, "simplifyconstruct" ) == 0 )
215 simplifyConstruct
= static_cast< SimplifyConstruct
* >( plugin
);
216 else if( strcmp( name
, "stringstatic" ) == 0 )
217 stringStatic
= static_cast< StringStatic
* >( plugin
);
218 else if( strcmp( name
, "subtlezeroinit" ) == 0 )
219 subtleZeroInit
= static_cast< SubtleZeroInit
* >( plugin
);
220 else if( strcmp( name
, "unnecessaryoverride" ) == 0 )
221 unnecessaryOverride
= static_cast< UnnecessaryOverride
* >( plugin
);
222 else if( strcmp( name
, "unnecessaryparen" ) == 0 )
223 unnecessaryParen
= static_cast< UnnecessaryParen
* >( plugin
);
224 else if( strcmp( name
, "unreffun" ) == 0 )
225 unrefFun
= static_cast< UnrefFun
* >( plugin
);
226 else if( strcmp( name
, "unusedvariablecheck" ) == 0 )
227 unusedVariableCheck
= static_cast< UnusedVariableCheck
* >( plugin
);
228 else if( strcmp( name
, "weakobject" ) == 0 )
229 weakObject
= static_cast< WeakObject
* >( plugin
);
234 bool VisitBinEQ(const class clang::BinaryOperator
* arg
)
236 if( ignoreLocation( arg
))
238 if( empty
!= nullptr )
240 if( !empty
->VisitBinEQ( arg
))
243 return anyPluginActive();
245 bool VisitBinGE(const class clang::BinaryOperator
* arg
)
247 if( ignoreLocation( arg
))
249 if( empty
!= nullptr )
251 if( !empty
->VisitBinGE( arg
))
254 return anyPluginActive();
256 bool VisitBinGT(const class clang::BinaryOperator
* arg
)
258 if( ignoreLocation( arg
))
260 if( empty
!= nullptr )
262 if( !empty
->VisitBinGT( arg
))
265 return anyPluginActive();
267 bool VisitBinLE(const class clang::BinaryOperator
* arg
)
269 if( ignoreLocation( arg
))
271 if( empty
!= nullptr )
273 if( !empty
->VisitBinLE( arg
))
276 return anyPluginActive();
278 bool VisitBinLT(const class clang::BinaryOperator
* arg
)
280 if( ignoreLocation( arg
))
282 if( empty
!= nullptr )
284 if( !empty
->VisitBinLT( arg
))
287 return anyPluginActive();
289 bool VisitBinNE(const class clang::BinaryOperator
* arg
)
291 if( ignoreLocation( arg
))
293 if( empty
!= nullptr )
295 if( !empty
->VisitBinNE( arg
))
298 return anyPluginActive();
300 bool VisitBinShr(const class clang::BinaryOperator
* arg
)
302 if( ignoreLocation( arg
))
304 if( charRightShift
!= nullptr )
306 if( !charRightShift
->VisitBinShr( arg
))
307 charRightShift
= nullptr;
309 return anyPluginActive();
311 bool VisitBinaryConditionalOperator(const class clang::BinaryConditionalOperator
* arg
)
313 if( ignoreLocation( arg
))
315 if( unnecessaryParen
!= nullptr )
317 if( !unnecessaryParen
->VisitBinaryConditionalOperator( arg
))
318 unnecessaryParen
= nullptr;
320 return anyPluginActive();
322 bool VisitCXXConstructExpr(const class clang::CXXConstructExpr
* arg
)
324 if( ignoreLocation( arg
))
326 if( simplifyConstruct
!= nullptr )
328 if( !simplifyConstruct
->VisitCXXConstructExpr( arg
))
329 simplifyConstruct
= nullptr;
331 return anyPluginActive();
333 bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr
* arg
)
335 if( ignoreLocation( arg
))
337 if( unnecessaryParen
!= nullptr )
339 if( !unnecessaryParen
->VisitCXXDeleteExpr( arg
))
340 unnecessaryParen
= nullptr;
342 return anyPluginActive();
344 bool VisitCXXMethodDecl(const class clang::CXXMethodDecl
* arg
)
346 if( ignoreLocation( arg
))
348 if( unnecessaryOverride
!= nullptr )
350 if( !unnecessaryOverride
->VisitCXXMethodDecl( arg
))
351 unnecessaryOverride
= nullptr;
353 if( weakObject
!= nullptr )
355 if( !weakObject
->VisitCXXMethodDecl( arg
))
356 weakObject
= nullptr;
358 return anyPluginActive();
360 bool VisitCXXNewExpr(const class clang::CXXNewExpr
* arg
)
362 if( ignoreLocation( arg
))
364 if( subtleZeroInit
!= nullptr )
366 if( !subtleZeroInit
->VisitCXXNewExpr( arg
))
367 subtleZeroInit
= nullptr;
369 return anyPluginActive();
371 bool VisitCXXOperatorCallExpr(const class clang::CXXOperatorCallExpr
* arg
)
373 if( ignoreLocation( arg
))
375 if( unnecessaryParen
!= nullptr )
377 if( !unnecessaryParen
->VisitCXXOperatorCallExpr( arg
))
378 unnecessaryParen
= nullptr;
380 return anyPluginActive();
382 bool VisitCXXRecordDecl(const class clang::CXXRecordDecl
* arg
)
384 if( ignoreLocation( arg
))
386 if( privateBase
!= nullptr )
388 if( !privateBase
->VisitCXXRecordDecl( arg
))
389 privateBase
= nullptr;
391 return anyPluginActive();
393 bool VisitCallExpr(const class clang::CallExpr
* arg
)
395 if( ignoreLocation( arg
))
397 if( dbgUnhandledException
!= nullptr )
399 if( !dbgUnhandledException
->VisitCallExpr( arg
))
400 dbgUnhandledException
= nullptr;
402 if( unnecessaryParen
!= nullptr )
404 if( !unnecessaryParen
->VisitCallExpr( arg
))
405 unnecessaryParen
= nullptr;
407 return anyPluginActive();
409 bool VisitCaseStmt(const class clang::CaseStmt
* arg
)
411 if( ignoreLocation( arg
))
413 if( unnecessaryParen
!= nullptr )
415 if( !unnecessaryParen
->VisitCaseStmt( arg
))
416 unnecessaryParen
= nullptr;
418 return anyPluginActive();
420 bool VisitCompoundStmt(const class clang::CompoundStmt
* arg
)
422 if( ignoreLocation( arg
))
424 if( blockBlock
!= nullptr )
426 if( !blockBlock
->VisitCompoundStmt( arg
))
427 blockBlock
= nullptr;
429 return anyPluginActive();
431 bool VisitConditionalOperator(const class clang::ConditionalOperator
* arg
)
433 if( ignoreLocation( arg
))
435 if( unnecessaryParen
!= nullptr )
437 if( !unnecessaryParen
->VisitConditionalOperator( arg
))
438 unnecessaryParen
= nullptr;
440 return anyPluginActive();
442 bool VisitDoStmt(const class clang::DoStmt
* arg
)
444 if( ignoreLocation( arg
))
446 if( loopVarTooSmall
!= nullptr )
448 if( !loopVarTooSmall
->VisitDoStmt( arg
))
449 loopVarTooSmall
= nullptr;
451 if( unnecessaryParen
!= nullptr )
453 if( !unnecessaryParen
->VisitDoStmt( arg
))
454 unnecessaryParen
= nullptr;
456 return anyPluginActive();
458 bool VisitFieldDecl(const class clang::FieldDecl
* arg
)
460 if( ignoreLocation( arg
))
462 if( dataMemberShadow
!= nullptr )
464 if( !dataMemberShadow
->VisitFieldDecl( arg
))
465 dataMemberShadow
= nullptr;
467 return anyPluginActive();
469 bool VisitForStmt(const class clang::ForStmt
* arg
)
471 if( ignoreLocation( arg
))
473 if( loopVarTooSmall
!= nullptr )
475 if( !loopVarTooSmall
->VisitForStmt( arg
))
476 loopVarTooSmall
= nullptr;
478 if( unnecessaryParen
!= nullptr )
480 if( !unnecessaryParen
->VisitForStmt( arg
))
481 unnecessaryParen
= nullptr;
483 return anyPluginActive();
485 bool VisitFunctionDecl(const class clang::FunctionDecl
* arg
)
487 if( ignoreLocation( arg
))
489 if( externAndNotDefined
!= nullptr )
491 if( !externAndNotDefined
->VisitFunctionDecl( arg
))
492 externAndNotDefined
= nullptr;
494 if( inlineVisible
!= nullptr )
496 if( !inlineVisible
->VisitFunctionDecl( arg
))
497 inlineVisible
= nullptr;
499 if( unrefFun
!= nullptr )
501 if( !unrefFun
->VisitFunctionDecl( arg
))
504 return anyPluginActive();
506 bool VisitIfStmt(const class clang::IfStmt
* arg
)
508 if( ignoreLocation( arg
))
510 if( emptyIf
!= nullptr )
512 if( !emptyIf
->VisitIfStmt( arg
))
515 if( unnecessaryParen
!= nullptr )
517 if( !unnecessaryParen
->VisitIfStmt( arg
))
518 unnecessaryParen
= nullptr;
520 return anyPluginActive();
522 bool VisitMaterializeTemporaryExpr(const class clang::MaterializeTemporaryExpr
* arg
)
524 if( ignoreLocation( arg
))
526 if( doubleConvert
!= nullptr )
528 if( !doubleConvert
->VisitMaterializeTemporaryExpr( arg
))
529 doubleConvert
= nullptr;
531 return anyPluginActive();
533 bool VisitMemberExpr(const class clang::MemberExpr
* arg
)
535 if( ignoreLocation( arg
))
537 if( unnecessaryParen
!= nullptr )
539 if( !unnecessaryParen
->VisitMemberExpr( arg
))
540 unnecessaryParen
= nullptr;
542 return anyPluginActive();
544 bool VisitNamedDecl(const class clang::NamedDecl
* arg
)
546 if( ignoreLocation( arg
))
548 if( reservedId
!= nullptr )
550 if( !reservedId
->VisitNamedDecl( arg
))
551 reservedId
= nullptr;
553 return anyPluginActive();
555 bool VisitParenExpr(const class clang::ParenExpr
* arg
)
557 if( ignoreLocation( arg
))
559 if( unnecessaryParen
!= nullptr )
561 if( !unnecessaryParen
->VisitParenExpr( arg
))
562 unnecessaryParen
= nullptr;
564 return anyPluginActive();
566 bool VisitReturnStmt(const class clang::ReturnStmt
* arg
)
568 if( ignoreLocation( arg
))
570 if( stringStatic
!= nullptr )
572 if( !stringStatic
->VisitReturnStmt( arg
))
573 stringStatic
= nullptr;
575 if( unnecessaryParen
!= nullptr )
577 if( !unnecessaryParen
->VisitReturnStmt( arg
))
578 unnecessaryParen
= nullptr;
580 return anyPluginActive();
582 bool VisitSwitchStmt(const class clang::SwitchStmt
* arg
)
584 if( ignoreLocation( arg
))
586 if( unnecessaryParen
!= nullptr )
588 if( !unnecessaryParen
->VisitSwitchStmt( arg
))
589 unnecessaryParen
= nullptr;
591 return anyPluginActive();
593 bool VisitUnaryDeref(const class clang::UnaryOperator
* arg
)
595 if( ignoreLocation( arg
))
597 if( derefNullPtr
!= nullptr )
599 if( !derefNullPtr
->VisitUnaryDeref( arg
))
600 derefNullPtr
= nullptr;
602 return anyPluginActive();
604 bool VisitUnaryExprOrTypeTraitExpr(const class clang::UnaryExprOrTypeTraitExpr
* arg
)
606 if( ignoreLocation( arg
))
608 if( unnecessaryParen
!= nullptr )
610 if( !unnecessaryParen
->VisitUnaryExprOrTypeTraitExpr( arg
))
611 unnecessaryParen
= nullptr;
613 return anyPluginActive();
615 bool VisitVarDecl(const class clang::VarDecl
*const arg
)
617 if( ignoreLocation( arg
))
619 if( badStatics
!= nullptr )
621 if( !badStatics
->VisitVarDecl( arg
))
622 badStatics
= nullptr;
624 if( externVar
!= nullptr )
626 if( !externVar
->VisitVarDecl( arg
))
629 if( simplifyConstruct
!= nullptr )
631 if( !simplifyConstruct
->VisitVarDecl( arg
))
632 simplifyConstruct
= nullptr;
634 if( stringStatic
!= nullptr )
636 if( !stringStatic
->VisitVarDecl( arg
))
637 stringStatic
= nullptr;
639 if( unnecessaryParen
!= nullptr )
641 if( !unnecessaryParen
->VisitVarDecl( arg
))
642 unnecessaryParen
= nullptr;
644 if( unusedVariableCheck
!= nullptr )
646 if( !unusedVariableCheck
->VisitVarDecl( arg
))
647 unusedVariableCheck
= nullptr;
649 return anyPluginActive();
651 bool VisitWhileStmt(const class clang::WhileStmt
* arg
)
653 if( ignoreLocation( arg
))
655 if( loopVarTooSmall
!= nullptr )
657 if( !loopVarTooSmall
->VisitWhileStmt( arg
))
658 loopVarTooSmall
= nullptr;
660 if( unnecessaryParen
!= nullptr )
662 if( !unnecessaryParen
->VisitWhileStmt( arg
))
663 unnecessaryParen
= nullptr;
665 return anyPluginActive();
667 bool TraverseCXXBindTemporaryExpr(class clang::CXXBindTemporaryExpr
* arg
)
669 SimplifyConstruct
* saveSimplifyConstruct
= simplifyConstruct
;
670 if( simplifyConstruct
!= nullptr )
672 if( !simplifyConstruct
->PreTraverseCXXBindTemporaryExpr( arg
))
673 simplifyConstruct
= nullptr;
675 bool ret
= RecursiveASTVisitor::TraverseCXXBindTemporaryExpr( arg
);
676 simplifyConstruct
= saveSimplifyConstruct
;
679 bool TraverseCXXCatchStmt(class clang::CXXCatchStmt
* arg
)
681 DbgUnhandledException
* saveDbgUnhandledException
= dbgUnhandledException
;
682 if( dbgUnhandledException
!= nullptr )
684 if( !dbgUnhandledException
->PreTraverseCXXCatchStmt( arg
))
685 dbgUnhandledException
= nullptr;
687 bool ret
= RecursiveASTVisitor::TraverseCXXCatchStmt( arg
);
688 if( dbgUnhandledException
!= nullptr )
690 if( !dbgUnhandledException
->PostTraverseCXXCatchStmt( arg
, ret
))
691 saveDbgUnhandledException
= nullptr;
693 dbgUnhandledException
= saveDbgUnhandledException
;
696 bool TraverseFriendDecl(class clang::FriendDecl
* arg
)
698 UnrefFun
* saveUnrefFun
= unrefFun
;
699 if( unrefFun
!= nullptr )
701 if( !unrefFun
->PreTraverseFriendDecl( arg
))
704 bool ret
= RecursiveASTVisitor::TraverseFriendDecl( arg
);
705 if( unrefFun
!= nullptr )
707 if( !unrefFun
->PostTraverseFriendDecl( arg
, ret
))
708 saveUnrefFun
= nullptr;
710 unrefFun
= saveUnrefFun
;
713 bool TraverseInitListExpr(class clang::InitListExpr
* arg
)
715 SimplifyConstruct
* saveSimplifyConstruct
= simplifyConstruct
;
716 if( simplifyConstruct
!= nullptr )
718 if( !simplifyConstruct
->PreTraverseInitListExpr( arg
))
719 simplifyConstruct
= nullptr;
721 bool ret
= RecursiveASTVisitor::TraverseInitListExpr( arg
);
722 simplifyConstruct
= saveSimplifyConstruct
;
725 bool TraverseReturnStmt(class clang::ReturnStmt
* arg
)
727 SimplifyConstruct
* saveSimplifyConstruct
= simplifyConstruct
;
728 if( simplifyConstruct
!= nullptr )
730 if( !simplifyConstruct
->PreTraverseReturnStmt( arg
))
731 simplifyConstruct
= nullptr;
733 bool ret
= RecursiveASTVisitor::TraverseReturnStmt( arg
);
734 simplifyConstruct
= saveSimplifyConstruct
;
738 bool anyPluginActive() const
740 return badStatics
!= nullptr
741 || blockBlock
!= nullptr
742 || charRightShift
!= nullptr
743 || dataMemberShadow
!= nullptr
744 || dbgUnhandledException
!= nullptr
745 || derefNullPtr
!= nullptr
746 || doubleConvert
!= nullptr
748 || emptyIf
!= nullptr
749 || externAndNotDefined
!= nullptr
750 || externVar
!= nullptr
751 || inlineVisible
!= nullptr
752 || loopVarTooSmall
!= nullptr
753 || privateBase
!= nullptr
754 || reservedId
!= nullptr
755 || simplifyConstruct
!= nullptr
756 || stringStatic
!= nullptr
757 || subtleZeroInit
!= nullptr
758 || unnecessaryOverride
!= nullptr
759 || unnecessaryParen
!= nullptr
760 || unrefFun
!= nullptr
761 || unusedVariableCheck
!= nullptr
762 || weakObject
!= nullptr;
764 BadStatics
* badStatics
;
765 BlockBlock
* blockBlock
;
766 CharRightShift
* charRightShift
;
767 DataMemberShadow
* dataMemberShadow
;
768 DbgUnhandledException
* dbgUnhandledException
;
769 DerefNullPtr
* derefNullPtr
;
770 DoubleConvert
* doubleConvert
;
773 ExternAndNotDefined
* externAndNotDefined
;
774 ExternVar
* externVar
;
775 InlineVisible
* inlineVisible
;
776 LoopVarTooSmall
* loopVarTooSmall
;
777 PrivateBase
* privateBase
;
778 ReservedId
* reservedId
;
779 SimplifyConstruct
* simplifyConstruct
;
780 StringStatic
* stringStatic
;
781 SubtleZeroInit
* subtleZeroInit
;
782 UnnecessaryOverride
* unnecessaryOverride
;
783 UnnecessaryParen
* unnecessaryParen
;
785 UnusedVariableCheck
* unusedVariableCheck
;
786 WeakObject
* weakObject
;
789 loplugin::Plugin::Registration
< SharedRecursiveASTVisitorBasic
> registrationBasic("sharedvisitorBasic");
792 class SharedRecursiveASTVisitorVisitTemplates
793 : public FilteringPlugin
< SharedRecursiveASTVisitorVisitTemplates
>
796 explicit SharedRecursiveASTVisitorVisitTemplates(const InstantiationData
& rData
)
797 : FilteringPlugin(rData
)
798 , dynCastVisibility( nullptr )
799 , vCLWidgets( nullptr )
801 virtual bool preRun() override
803 if( dynCastVisibility
&& !dynCastVisibility
->preRun())
804 dynCastVisibility
= nullptr;
805 if( vCLWidgets
&& !vCLWidgets
->preRun())
806 vCLWidgets
= nullptr;
807 return anyPluginActive();
809 virtual void postRun() override
811 if( dynCastVisibility
)
812 dynCastVisibility
->postRun();
814 vCLWidgets
->postRun();
816 virtual void run() override
{
818 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
822 enum { isSharedPlugin
= true };
823 virtual bool setSharedPlugin( Plugin
* plugin
, const char* name
) override
825 if( strcmp( name
, "dyncastvisibility" ) == 0 )
826 dynCastVisibility
= static_cast< DynCastVisibility
* >( plugin
);
827 else if( strcmp( name
, "vclwidgets" ) == 0 )
828 vCLWidgets
= static_cast< VCLWidgets
* >( plugin
);
833 bool shouldVisitTemplateInstantiations() const { return true; }
834 bool VisitBinaryOperator(const class clang::BinaryOperator
* arg
)
836 if( ignoreLocation( arg
))
838 if( vCLWidgets
!= nullptr )
840 if( !vCLWidgets
->VisitBinaryOperator( arg
))
841 vCLWidgets
= nullptr;
843 return anyPluginActive();
845 bool VisitCXXConstructExpr(const class clang::CXXConstructExpr
* arg
)
847 if( ignoreLocation( arg
))
849 if( vCLWidgets
!= nullptr )
851 if( !vCLWidgets
->VisitCXXConstructExpr( arg
))
852 vCLWidgets
= nullptr;
854 return anyPluginActive();
856 bool VisitCXXDeleteExpr(const class clang::CXXDeleteExpr
* arg
)
858 if( ignoreLocation( arg
))
860 if( vCLWidgets
!= nullptr )
862 if( !vCLWidgets
->VisitCXXDeleteExpr( arg
))
863 vCLWidgets
= nullptr;
865 return anyPluginActive();
867 bool VisitCXXDestructorDecl(const class clang::CXXDestructorDecl
* arg
)
869 if( ignoreLocation( arg
))
871 if( vCLWidgets
!= nullptr )
873 if( !vCLWidgets
->VisitCXXDestructorDecl( arg
))
874 vCLWidgets
= nullptr;
876 return anyPluginActive();
878 bool VisitCXXDynamicCastExpr(const class clang::CXXDynamicCastExpr
* arg
)
880 if( ignoreLocation( arg
))
882 if( dynCastVisibility
!= nullptr )
884 if( !dynCastVisibility
->VisitCXXDynamicCastExpr( arg
))
885 dynCastVisibility
= nullptr;
887 return anyPluginActive();
889 bool VisitCallExpr(const class clang::CallExpr
* arg
)
891 if( ignoreLocation( arg
))
893 if( vCLWidgets
!= nullptr )
895 if( !vCLWidgets
->VisitCallExpr( arg
))
896 vCLWidgets
= nullptr;
898 return anyPluginActive();
900 bool VisitDeclRefExpr(const class clang::DeclRefExpr
* arg
)
902 if( ignoreLocation( arg
))
904 if( vCLWidgets
!= nullptr )
906 if( !vCLWidgets
->VisitDeclRefExpr( arg
))
907 vCLWidgets
= nullptr;
909 return anyPluginActive();
911 bool VisitFieldDecl(const class clang::FieldDecl
* arg
)
913 if( ignoreLocation( arg
))
915 if( vCLWidgets
!= nullptr )
917 if( !vCLWidgets
->VisitFieldDecl( arg
))
918 vCLWidgets
= nullptr;
920 return anyPluginActive();
922 bool VisitFunctionDecl(const class clang::FunctionDecl
* arg
)
924 if( ignoreLocation( arg
))
926 if( vCLWidgets
!= nullptr )
928 if( !vCLWidgets
->VisitFunctionDecl( arg
))
929 vCLWidgets
= nullptr;
931 return anyPluginActive();
933 bool VisitParmVarDecl(const class clang::ParmVarDecl
* arg
)
935 if( ignoreLocation( arg
))
937 if( vCLWidgets
!= nullptr )
939 if( !vCLWidgets
->VisitParmVarDecl( arg
))
940 vCLWidgets
= nullptr;
942 return anyPluginActive();
944 bool VisitVarDecl(const class clang::VarDecl
* arg
)
946 if( ignoreLocation( arg
))
948 if( vCLWidgets
!= nullptr )
950 if( !vCLWidgets
->VisitVarDecl( arg
))
951 vCLWidgets
= nullptr;
953 return anyPluginActive();
956 bool anyPluginActive() const
958 return dynCastVisibility
!= nullptr
959 || vCLWidgets
!= nullptr;
961 DynCastVisibility
* dynCastVisibility
;
962 VCLWidgets
* vCLWidgets
;
965 loplugin::Plugin::Registration
< SharedRecursiveASTVisitorVisitTemplates
> registrationVisitTemplates("sharedvisitorVisitTemplates");
967 } // namespace loplugin
969 #endif // LO_CLANG_SHARED_PLUGINS