summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-09-03 15:24:29 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-09-06 12:06:54 +0200
commitceb26770b3d1c5c2ffaf73f8f589c5e169e6db06 (patch)
tree5ef0ba058c095a2dd2b547026d120faac735e7bf
parentf599c31fe68882f510cf3d101102e71f9bf795c8 (diff)
split clangplugins sharedvisitor generator into two steps
Analysing all the plugin sources using just one process takes a lot of time, so split out a separate analyzer tool that'll analyse one source and print out the data to a .plugininfo file. The generator then will read all of these and generate sharedvisitor.cxx . This allows parallelising the expensive analysis. With this commit sharedvisitor.cxx is no longer included in the repository, as this and the next commit should make the generation fast enough. Change-Id: Idfc33c4ea6ccfd84f829b51001c8ddeb0be09961 Reviewed-on: https://gerrit.libreoffice.org/78568 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--compilerplugins/Makefile-clang.mk87
-rw-r--r--compilerplugins/clang/sharedvisitor/README45
-rw-r--r--compilerplugins/clang/sharedvisitor/analyzer.cxx278
-rw-r--r--compilerplugins/clang/sharedvisitor/generator.cxx329
-rw-r--r--compilerplugins/clang/sharedvisitor/sharedvisitor.cxx1848
-rw-r--r--solenv/clang-format/blacklist1
6 files changed, 474 insertions, 2114 deletions
diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk
index 370a58ef5e14..4fd3f7724032 100644
--- a/compilerplugins/Makefile-clang.mk
+++ b/compilerplugins/Makefile-clang.mk
@@ -79,7 +79,8 @@ LLVMCONFIG=$(CLANGDIR)/bin/llvm-config
CLANGINDIR=$(SRCDIR)/compilerplugins/clang
# Cannot use $(WORKDIR), the plugin should survive even 'make clean', otherwise the rebuilt
# plugin will cause cache misses with ccache.
-CLANGOUTDIR=$(BUILDDIR)/compilerplugins/obj
+CLANGOUTDIR=$(BUILDDIR)/compilerplugins/clang
+CLANGOBJDIR=$(CLANGOUTDIR)/obj
ifdef LO_CLANG_SHARED_PLUGINS
CLANGCXXFLAGS+=-DLO_CLANG_SHARED_PLUGINS
@@ -106,10 +107,12 @@ compilerplugins: compilerplugins-build
ifdef LO_CLANG_SHARED_PLUGINS
# The shared source, intentionally put first in the list because it takes the longest to build.
-CLANGSRC=sharedvisitor/sharedvisitor.cxx
+CLANGSRCOUTDIR=$(CLANGOUTDIR)/sharedvisitor/sharedvisitor.cxx
+CLANGSRC+=$(CLANGSRCOUTDIR)
endif
# The list of source files, generated automatically (all files in clang/, but not subdirs).
-CLANGSRC+=$(foreach src,$(wildcard $(CLANGINDIR)/*.cxx), $(notdir $(src)))
+CLANGSRCINDIR=$(foreach src,$(wildcard $(CLANGINDIR)/*.cxx), $(notdir $(src)))
+CLANGSRC+=$(CLANGSRCINDIR)
# Remember the sources and if they have changed, force plugin relinking.
CLANGSRCCHANGED= \
@@ -132,7 +135,7 @@ $(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(CLANGOUTDIR)/sources.txt
$(CLANGOUTDIR)/sources.txt:
touch $@
-compilerplugins-build: $(CLANGOUTDIR) $(CLANGOUTDIR)/plugin$(CLANG_DL_EXT)
+compilerplugins-build: $(CLANGOUTDIR) $(CLANGOBJDIR) $(CLANGOUTDIR)/plugin$(CLANG_DL_EXT)
compilerplugins-clean:
rm -rf $(CLANGOUTDIR)
@@ -140,39 +143,47 @@ compilerplugins-clean:
$(CLANGOUTDIR):
mkdir -p $(CLANGOUTDIR)
+$(CLANGOBJDIR):
+ mkdir -p $(CLANGOBJDIR)
+
CLANGOBJS=
ifeq ($(OS),WNT)
+# clangbuildsrc cxxfile objfile dfile
define clangbuildsrc
-$(3): $(2) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
- $$(call gb_Output_announce,$(subst $(SRCDIR)/,,$(2)),$(true),CXX,3)
+$(2): $(1) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
+ $$(call gb_Output_announce,$(subst $(SRCDIR)/,,$(subst $(BUILDDIR)/,,$(1))),$(true),CXX,3)
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) \
- $(CLANGINCLUDES) /I$(BUILDDIR)/config_host $(2) /MD \
- /c /Fo: $(3)
+ $(CLANGINCLUDES) /I$(BUILDDIR)/config_host /I$(CLANGINDIR) $(1) /MD \
+ /c /Fo: $(2)
--include $(CLANGOUTDIR)/$(1).d #TODO
+-include $(3) #TODO
-$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(3)
-$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): CLANGOBJS += $(3)
+$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(2)
+$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): CLANGOBJS += $(2)
endef
else
+# clangbuildsrc cxxfile ofile dfile
define clangbuildsrc
-$(3): $(2) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
- $$(call gb_Output_announce,$(subst $(SRCDIR)/,,$(2)),$(true),CXX,3)
- $(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) $(CLANGINCLUDES) -I$(BUILDDIR)/config_host $(2) -fPIC -c -o $(3) -MMD -MT $(3) -MP -MF $(CLANGOUTDIR)/$(1).d
+$(2): $(1) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
+ $$(call gb_Output_announce,$(subst $(SRCDIR)/,,$(subst $(BUILDDIR)/,,$(1))),$(true),CXX,3)
+ $(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) \
+ $(CLANGINCLUDES) -I$(BUILDDIR)/config_host -I$(CLANGINDIR) $(1) \
+ -fPIC -c -o $(2) -MMD -MT $(2) -MP -MF $(3)
--include $(CLANGOUTDIR)/$(1).d
+-include $(3)
-$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(3)
-$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): CLANGOBJS += $(3)
+$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(2)
+$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): CLANGOBJS += $(2)
endef
endif
-$(foreach src, $(CLANGSRC), $(eval $(call clangbuildsrc,$(src),$(CLANGINDIR)/$(src),$(CLANGOUTDIR)/$(src:.cxx=.o))))
+$(foreach src, $(CLANGSRCOUTDIR), $(eval $(call clangbuildsrc,$(src),$(src:.cxx=.o),$(src:.cxx=.d))))
+$(foreach src, $(CLANGSRCINDIR), $(eval $(call clangbuildsrc,$(CLANGINDIR)/$(src),$(CLANGOBJDIR)/$(src:.cxx=.o),$(CLANGOBJDIR)/$(src:.cxx=.d))))
$(CLANGOUTDIR)/plugin$(CLANG_DL_EXT): $(CLANGOBJS)
$(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),LNK,4)
@@ -193,16 +204,18 @@ $(CLANGOUTDIR)/clang-timestamp: $(CLANGDIR)/bin/clang$(CLANG_EXE_EXT) $(BUILDDIR
ifdef LO_CLANG_SHARED_PLUGINS
-# Update the shared visitor source if needed. It is intentionally included in the sources and generated only when
-# needed, because the generating takes a while.
-# If you want to remake the source with LO_CLANG_SHARED_PLUGINS disabled, run 'make LO_CLANG_SHARED_PLUGINS=1'.
-$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx)
-$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT)
- $(call gb_Output_announce,$(subst $(SRCDIR)/,,$@),$(true),GEN,1)
- $(QUIET)$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT) \
- $(COMPILER_PLUGINS_TOOLING_ARGS:%=-arg=%) \
- $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx) \
- > $(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx
+SHARED_SOURCES := $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx)
+SHARED_SOURCE_INFOS := $(foreach source,$(SHARED_SOURCES),$(patsubst $(CLANGINDIR)/%.cxx,$(CLANGOUTDIR)/sharedvisitor/%.plugininfo,$(source)))
+
+$(CLANGOUTDIR)/sharedvisitor/%.plugininfo: $(CLANGINDIR)/%.cxx $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT)
+ $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
+ $(QUIET)$(ICECREAM_RUN) $(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT) \
+ $(COMPILER_PLUGINS_TOOLING_ARGS:%=-arg=%) $< > $@
+
+$(CLANGOUTDIR)/sharedvisitor/sharedvisitor.cxx: $(SHARED_SOURCE_INFOS) $(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT)
+ $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
+ $(QUIET)$(ICECREAM_RUN) $(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT) \
+ $(COMPILER_PLUGINS_TOOLING_ARGS:%=-arg=%) $(SHARED_SOURCE_INFOS) > $@
CLANGTOOLLIBS = -lclangTooling -lclangDriver -lclangFrontend -lclangParse -lclangSema -lclangEdit -lclangAnalysis \
-lclangAST -lclangLex -lclangSerialization -lclangBasic $(shell $(LLVMCONFIG) --ldflags --libs --system-libs)
@@ -217,21 +230,33 @@ CLANGTOOLLIBS += -Wl,--rpath,$(shell $(LLVMCONFIG) --libdir)
endif
endif
-$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT): $(CLANGINDIR)/sharedvisitor/generator.cxx \
+$(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT): $(CLANGINDIR)/sharedvisitor/analyzer.cxx \
| $(CLANGOUTDIR)/sharedvisitor
$(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) $(CLANGTOOLDEFS) $(CLANGINCLUDES) \
-DCLANGDIR=$(CLANGDIR) -I$(BUILDDIR)/config_host \
+ -c $< -o $(CLANGOUTDIR)/sharedvisitor/analyzer.o -MMD -MT $@ -MP \
+ -MF $(CLANGOUTDIR)/sharedvisitor/analyzer.d
+ $(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGOUTDIR)/sharedvisitor/analyzer.o \
+ -o $@ $(CLANGTOOLLIBS)
+
+$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT): $(CLANGINDIR)/sharedvisitor/generator.cxx \
+ | $(CLANGOUTDIR)/sharedvisitor
+ $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,1)
+ $(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) \
-c $< -o $(CLANGOUTDIR)/sharedvisitor/generator.o -MMD -MT $@ -MP \
-MF $(CLANGOUTDIR)/sharedvisitor/generator.d
$(QUIET)$(COMPILER_PLUGINS_CXX) $(CLANGCXXFLAGS) $(CLANGOUTDIR)/sharedvisitor/generator.o \
- -o $@ $(CLANGTOOLLIBS)
+ -o $@
+
+$(CLANGOUTDIR)/sharedvisitor/analyzer$(CLANG_EXE_EXT): $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
-$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT): $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp
+$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT): $(SRCDIR)/compilerplugins/Makefile-clang.mk
$(CLANGOUTDIR)/sharedvisitor:
mkdir -p $(CLANGOUTDIR)/sharedvisitor
+-include $(CLANGOUTDIR)/sharedvisitor/analyzer.d
-include $(CLANGOUTDIR)/sharedvisitor/generator.d
# TODO WNT version
endif
diff --git a/compilerplugins/clang/sharedvisitor/README b/compilerplugins/clang/sharedvisitor/README
new file mode 100644
index 000000000000..7b4a8b3c7392
--- /dev/null
+++ b/compilerplugins/clang/sharedvisitor/README
@@ -0,0 +1,45 @@
+These tools generate another "plugin" which in fact only dispatches Visit* and Traverse*
+calls to all other plugins registered with it. This means that there is just one
+RecursiveASTVisitor pass for all those plugins instead of one per each, which
+with the current number of plugins actually makes a performance difference.
+
+If you work on a plugin, comment out LO_CLANG_SHARED_PLUGINS in Makefile-clang.mk in order
+to disable the feature (re-generating takes time).
+
+There are two tools:
+- analyzer, which analyses one .cxx file (one plugins) and writes info about it to a .plugininfo
+ file, this allows parallelising this part, since it can take some time
+- generator, which reads all the .plugininfo files and generates sharedvisitor.cxx
+
+Requirements for plugins:
+- Can use Visit* and Traverse* functions, but not WalkUp*.
+- Visit* functions can generally remain unmodified.
+- run() function must be split into preRun() and postRun() if there's any additional functionality
+ besides calling TraverseDecl(). The shared visitor will call the preRun() and postRun() functions
+ as necessary while calling its own run(). The run() function of the plugin must stay
+ (in case of a non-shared build) but should generally look like this:
+ if( preRun())
+ if( TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()))
+ postRun();
+- Traverse* functions must be split into PreTraverse* and PostTraverse*, similarly to how run()
+ is handled, the Traverse* function should generally look like this:
+ bool ret = true;
+ if( PreTraverse*(decl))
+ {
+ ret = RecursiveASTVisitor::Traverse*(decl);
+ PostTraverse*(decl, ret);
+ }
+ return ret;
+
+
+TODO:
+- Create macros for the standardized layout of run(), Traverse*, etc.?
+- Possibly check plugin sources more thoroughly (e.g. that run() doesn't actually do more).
+- Have one tool that extracts info from plugin .cxx files into some .txt file and another tool
+ that generates sharedvisitor.cxx based on those files? That would generally make the generation
+ faster when doing incremental changes. The .txt file could also contain some checksum of the .cxx
+ to avoid the analysing pass completely if just the timestamp has changed.
+- Do not re-compile sharedvisitor.cxx if its contents have not actually changed.
+- Is it possible to make the clang code analyze just the .cxx without also parsing all the headers?
+- Instead of having to comment out LO_CLANG_SHARED_PLUGINS, implement --enable-compiler-plugins=debug .
+- Try make analyzer use a precompiled header of Clang headers, for better performance.
diff --git a/compilerplugins/clang/sharedvisitor/analyzer.cxx b/compilerplugins/clang/sharedvisitor/analyzer.cxx
new file mode 100644
index 000000000000..171fc8528a28
--- /dev/null
+++ b/compilerplugins/clang/sharedvisitor/analyzer.cxx
@@ -0,0 +1,278 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/.
+ */
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+
+#include <cstddef>
+#include <cstring>
+#include <iostream>
+#include <memory>
+#include <fstream>
+#include <set>
+
+#include "config_clang.h"
+#include "../check.hxx"
+#include "../check.cxx"
+
+using namespace std;
+
+using namespace clang;
+
+using namespace loplugin;
+
+// Info about a Traverse* function in a plugin.
+struct TraverseFunctionInfo
+{
+ string name;
+ string argument;
+ bool hasPre = false;
+ bool hasPost = false;
+};
+
+struct TraverseFunctionInfoLess
+{
+ bool operator()( const TraverseFunctionInfo& l, const TraverseFunctionInfo& r ) const
+ {
+ return l.name < r.name;
+ }
+};
+
+static set< TraverseFunctionInfo, TraverseFunctionInfoLess > traverseFunctions;
+
+class CheckFileVisitor
+ : public RecursiveASTVisitor< CheckFileVisitor >
+{
+public:
+ bool VisitCXXRecordDecl(CXXRecordDecl *Declaration);
+
+ bool TraverseNamespaceDecl(NamespaceDecl * decl)
+ {
+ // Skip non-LO namespaces the same way FilteringPlugin does.
+ if( !ContextCheck( decl ).Namespace( "loplugin" ).GlobalNamespace()
+ && !ContextCheck( decl ).AnonymousNamespace())
+ {
+ return true;
+ }
+ return RecursiveASTVisitor<CheckFileVisitor>::TraverseNamespaceDecl(decl);
+ }
+};
+
+static bool inheritsPluginClassCheck( const Decl* decl )
+{
+ return bool( DeclCheck( decl ).Class( "FilteringPlugin" ).Namespace( "loplugin" ).GlobalNamespace())
+ || bool( DeclCheck( decl ).Class( "FilteringRewritePlugin" ).Namespace( "loplugin" ).GlobalNamespace());
+}
+
+static TraverseFunctionInfo findOrCreateTraverseFunctionInfo( StringRef name )
+{
+ TraverseFunctionInfo info;
+ info.name = name;
+ auto foundInfo = traverseFunctions.find( info );
+ if( foundInfo != traverseFunctions.end())
+ {
+ info = move( *foundInfo );
+ traverseFunctions.erase( foundInfo );
+ }
+ return info;
+}
+
+static bool foundSomething;
+
+bool CheckFileVisitor::VisitCXXRecordDecl( CXXRecordDecl* decl )
+{
+ if( !isDerivedFrom( decl, inheritsPluginClassCheck ))
+ return true;
+
+ if( decl->getName() == "FilteringPlugin" || decl->getName() == "FilteringRewritePlugin" )
+ return true;
+
+ cout << "# This file is autogenerated. Do not modify." << endl;
+ cout << "# Generated by compilerplugins/clang/sharedvisitor/analyzer.cxx ." << endl;
+ cout << "InfoVersion:1" << endl;
+ cout << "ClassName:" << decl->getName().str() << endl;
+ traverseFunctions.clear();
+ for( const CXXMethodDecl* method : decl->methods())
+ {
+ if( !method->getDeclName().isIdentifier())
+ continue;
+ if( method->isStatic() || method->getAccess() != AS_public )
+ continue;
+ if( method->getName().startswith( "Visit" ))
+ {
+ if( method->getNumParams() == 1 )
+ {
+ cout << "VisitFunctionStart" << endl;
+ cout << "VisitFunctionName:" << method->getName().str() << endl;
+ cout << "VisitFunctionArgument:"
+ << method->getParamDecl( 0 )->getTypeSourceInfo()->getType().getAsString()
+ << endl;
+ cout << "VisitFunctionEnd" << endl;
+ }
+ else
+ {
+ cerr << "Unhandled Visit* function: " << decl->getName().str()
+ << "::" << method->getName().str() << endl;
+ abort();
+ }
+ }
+ else if( method->getName().startswith( "Traverse" ))
+ {
+ if( method->getNumParams() == 1 )
+ {
+ TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( method->getName());
+ traverseInfo.argument = method->getParamDecl( 0 )->getTypeSourceInfo()->getType().getAsString();
+ traverseFunctions.insert( move( traverseInfo ));
+ }
+ else
+ {
+ cerr << "Unhandled Traverse* function: " << decl->getName().str()
+ << "::" << method->getName().str() << endl;
+ abort();
+ }
+ }
+ else if( method->getName().startswith( "PreTraverse" ))
+ {
+ TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( method->getName().substr( 3 ));
+ traverseInfo.hasPre = true;
+ traverseFunctions.insert( move( traverseInfo ));
+ }
+ else if( method->getName().startswith( "PostTraverse" ))
+ {
+ TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( method->getName().substr( 4 ));
+ traverseInfo.hasPost = true;
+ traverseFunctions.insert( move( traverseInfo ));
+ }
+ else if( method->getName() == "shouldVisitTemplateInstantiations" )
+ cout << "ShouldVisitTemplateInstantiations:1" << endl;
+ else if (method->getName() == "shouldVisitImplicitCode")
+ cout << "ShouldVisitImplicitCode:1" << endl;
+ else if( method->getName().startswith( "WalkUp" ))
+ {
+ cerr << "WalkUp function not supported for shared visitor: " << decl->getName().str()
+ << "::" << method->getName().str() << endl;
+ abort();
+ }
+ }
+
+ for( const auto& traverseFunction : traverseFunctions )
+ {
+ cout << "TraverseFunctionStart" << endl;
+ cout << "TraverseFunctionName:" << traverseFunction.name << endl;
+ cout << "TraverseFunctionArgument:" << traverseFunction.argument << endl;
+ cout << "TraverseFunctionHasPre:" << traverseFunction.hasPre << endl;
+ cout << "TraverseFunctionHasPost:" << traverseFunction.hasPost << endl;
+ cout << "TraverseFunctionEnd" << endl;
+ }
+
+ cout << "InfoEnd" << endl;
+ foundSomething = true;
+ return true;
+}
+
+class FindNamedClassConsumer
+ : public ASTConsumer
+{
+public:
+ virtual void HandleTranslationUnit(ASTContext& context) override
+ {
+ visitor.TraverseDecl( context.getTranslationUnitDecl());
+ }
+private:
+ CheckFileVisitor visitor;
+};
+
+class FindNamedClassAction
+ : public ASTFrontendAction
+ {
+public:
+ virtual unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance&, StringRef ) override
+ {
+ return unique_ptr<ASTConsumer>( new FindNamedClassConsumer );
+ }
+};
+
+
+string readSourceFile( const char* filename )
+{
+ string contents;
+ ifstream stream( filename );
+ if( !stream )
+ {
+ cerr << "Failed to open: " << filename << endl;
+ exit( 1 );
+ }
+ string line;
+ bool hasIfdef = false;
+ while( getline( stream, line ))
+ {
+ // TODO add checks that it's e.g. not "#ifdef" ?
+ if( line.find( "#ifndef LO_CLANG_SHARED_PLUGINS" ) == 0 )
+ hasIfdef = true;
+ contents += line;
+ contents += '\n';
+ }
+ if( stream.eof() && hasIfdef )
+ return contents;
+ return "";
+}
+
+int main(int argc, char** argv)
+{
+ vector< string > args;
+ int i = 1;
+ for( ; i < argc; ++ i )
+ {
+ constexpr std::size_t prefixlen = 5; // strlen("-arg=");
+ if (std::strncmp(argv[i], "-arg=", prefixlen) != 0)
+ {
+ break;
+ }
+ args.push_back(argv[i] + prefixlen);
+ }
+#define STRINGIFY2(a) #a
+#define STRINGIFY(a) STRINGIFY2(a)
+ args.insert(
+ args.end(),
+ {
+ "-I" BUILDDIR "/config_host", // plugin sources use e.g. config_global.h
+ "-I" STRINGIFY(CLANGDIR) "/include", // clang's headers
+ "-I" STRINGIFY(CLANGSYSINCLUDE), // clang system headers
+ STDOPTION,
+ "-D__STDC_CONSTANT_MACROS", // Clang headers require these.
+ "-D__STDC_FORMAT_MACROS",
+ "-D__STDC_LIMIT_MACROS",
+ });
+ for( ; i < argc; ++ i )
+ {
+ string contents = readSourceFile(argv[i]);
+ if( contents.empty())
+ continue;
+ foundSomething = false;
+#if CLANG_VERSION >= 100000
+ if( !clang::tooling::runToolOnCodeWithArgs( std::unique_ptr<FindNamedClassAction>(new FindNamedClassAction), contents, args, argv[ i ] ))
+#else
+ if( !clang::tooling::runToolOnCodeWithArgs( new FindNamedClassAction, contents, args, argv[ i ] ))
+#endif
+ {
+ cerr << "Failed to analyze: " << argv[ i ] << endl;
+ return 2;
+ }
+ if( !foundSomething )
+ {
+ // there's #ifndef LO_CLANG_SHARED_PLUGINS in the source, but no class matched
+ cerr << "Failed to find code: " << argv[ i ] << endl;
+ return 2;
+ }
+ }
+ return 0;
+}
diff --git a/compilerplugins/clang/sharedvisitor/generator.cxx b/compilerplugins/clang/sharedvisitor/generator.cxx
index 286d57e6d4e1..467f141b2cb5 100644
--- a/compilerplugins/clang/sharedvisitor/generator.cxx
+++ b/compilerplugins/clang/sharedvisitor/generator.cxx
@@ -7,72 +7,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-/*
-This tool generates another "plugin" which in fact only dispatches Visit* and Traverse*
-calls to all other plugins registered with it. This means that there is just one
-RecursiveASTVisitor pass for all those plugins instead of one per each, which
-with the current number of plugins actually makes a performance difference.
-
-If you work on a plugin, comment out LO_CLANG_SHARED_PLUGINS in Makefile-clang.mk in order
-to disable the feature (re-generating takes time).
-
-Requirements for plugins:
-- Can use Visit* and Traverse* functions, but not WalkUp*.
-- Visit* functions can generally remain unmodified.
-- run() function must be split into preRun() and postRun() if there's any additional functionality
- besides calling TraverseDecl(). The shared visitor will call the preRun() and postRun() functions
- as necessary while calling its own run(). The run() function of the plugin must stay
- (in case of a non-shared build) but should generally look like this:
- if( preRun())
- if( TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()))
- postRun();
-- Traverse* functions must be split into PreTraverse* and PostTraverse*, similarly to how run()
- is handled, the Traverse* function should generally look like this:
- bool ret = true;
- if( PreTraverse*(decl))
- {
- ret = RecursiveASTVisitor::Traverse*(decl);
- PostTraverse*(decl, ret);
- }
- return ret;
-
-
-TODO:
-- Create macros for the standardized layout of run(), Traverse*, etc.?
-- Possibly check plugin sources more thoroughly (e.g. that run() doesn't actually do more).
-- Have one tool that extracts info from plugin .cxx files into some .txt file and another tool
- that generates sharedvisitor.cxx based on those files? That would generally make the generation
- faster when doing incremental changes. The .txt file could also contain some checksum of the .cxx
- to avoid the analysing pass completely if just the timestamp has changed.
-- Do not re-compile sharedvisitor.cxx if its contents have not actually changed.
-- Is it possible to make the clang code analyze just the .cxx without also parsing all the headers?
-- Instead of having to comment out LO_CLANG_SHARED_PLUGINS, implement --enable-compiler-plugins=debug .
-
-*/
-
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
-#include "clang/Tooling/Tooling.h"
-
+#include <algorithm>
+#include <cassert>
#include <cstddef>
#include <cstring>
#include <iostream>
#include <fstream>
#include <memory>
#include <set>
-
-#include "config_clang.h"
-#include "../check.hxx"
-#include "../check.cxx"
+#include <vector>
using namespace std;
-using namespace clang;
-
-using namespace loplugin;
-
// Info about a Visit* function in a plugin.
struct VisitFunctionInfo
{
@@ -155,13 +101,13 @@ void generate()
"#include <clang/AST/ASTContext.h>\n"
"#include <clang/AST/RecursiveASTVisitor.h>\n"
"\n"
-"#include \"../plugin.hxx\"\n"
+"#include \"plugin.hxx\"\n"
"\n";
output << "#undef LO_CLANG_SHARED_PLUGINS // to get sources of individual plugins\n";
for( const auto& pluginGroup : plugins )
for( const PluginInfo& plugin : pluginGroup )
- output << "#include \"../" << plugin.lowercaseName << ".cxx\"" << endl;
+ output << "#include \"" << plugin.lowercaseName << ".cxx\"" << endl;
output <<
"\n"
@@ -360,55 +306,40 @@ void generateVisitor( PluginType type )
"\n";
}
-class CheckFileVisitor
- : public RecursiveASTVisitor< CheckFileVisitor >
-{
-public:
- bool VisitCXXRecordDecl(CXXRecordDecl *Declaration);
-
- bool TraverseNamespaceDecl(NamespaceDecl * decl)
- {
- // Skip non-LO namespaces the same way FilteringPlugin does.
- if( !ContextCheck( decl ).Namespace( "loplugin" ).GlobalNamespace()
- && !ContextCheck( decl ).AnonymousNamespace())
- {
- return true;
- }
- return RecursiveASTVisitor<CheckFileVisitor>::TraverseNamespaceDecl(decl);
- }
-};
-
-static bool inheritsPluginClassCheck( const Decl* decl )
+static string getValue( const string& line, const char* tag )
{
- return bool( DeclCheck( decl ).Class( "FilteringPlugin" ).Namespace( "loplugin" ).GlobalNamespace())
- || bool( DeclCheck( decl ).Class( "FilteringRewritePlugin" ).Namespace( "loplugin" ).GlobalNamespace());
+ size_t taglen = strlen( tag );
+ if( line.size() < taglen + 2 )
+ return string();
+ if( line.compare( 0, taglen, tag ) != 0 )
+ return string();
+ if( line[ taglen ] != ':' )
+ return string();
+ return line.substr( taglen + 1 );
}
-static TraverseFunctionInfo findOrCreateTraverseFunctionInfo( PluginInfo& pluginInfo, StringRef name )
+static bool readFile( const string& fileName )
{
- TraverseFunctionInfo info;
- info.name = name;
- auto foundInfo = pluginInfo.traverseFunctions.find( info );
- if( foundInfo != pluginInfo.traverseFunctions.end())
+ ifstream file( fileName );
+ if( !file )
{
- info = move( *foundInfo );
- pluginInfo.traverseFunctions.erase( foundInfo );
+ cerr << "Cannot open file " << fileName << endl;
+ return false;
}
- return info;
-}
-
-static bool foundSomething;
-
-bool CheckFileVisitor::VisitCXXRecordDecl( CXXRecordDecl* decl )
-{
- if( !isDerivedFrom( decl, inheritsPluginClassCheck ))
- return true;
-
- if( decl->getName() == "FilteringPlugin" || decl->getName() == "FilteringRewritePlugin" )
- return true;
-
PluginInfo pluginInfo;
- pluginInfo.className = decl->getName().str();
+ string line;
+ do
+ {
+ getline( file, line );
+ } while( !line.empty() && line[ 0 ] == '#' );
+ string version = getValue( line, "InfoVersion" );
+ if( version != "1" )
+ {
+ cerr << "Incorrect version '" << version << "'" << endl;
+ return false;
+ }
+ getline( file, line );
+ pluginInfo.className = getValue( line, "ClassName" );
pluginInfo.variableName = pluginInfo.className;
assert( pluginInfo.variableName.size() > 0 );
pluginInfo.variableName[ 0 ] = tolower( pluginInfo.variableName[ 0 ] );
@@ -417,64 +348,79 @@ bool CheckFileVisitor::VisitCXXRecordDecl( CXXRecordDecl* decl )
c = tolower( c );
pluginInfo.shouldVisitTemplateInstantiations = false;
pluginInfo.shouldVisitImplicitCode = false;
- for( const CXXMethodDecl* method : decl->methods())
+ bool endOk = false;
+ for(;;)
{
- if( !method->getDeclName().isIdentifier())
- continue;
- if( method->isStatic() || method->getAccess() != AS_public )
+ string line;
+ getline( file, line );
+ if( file.eof() || !file )
+ {
+ cerr << "Unexpected end of file" << endl;
+ return false;
+ }
+ if( line.empty())
continue;
- if( method->getName().startswith( "Visit" ))
+ if( line == "InfoEnd" )
{
- if( method->getNumParams() == 1 )
- {
- VisitFunctionInfo visitInfo;
- visitInfo.name = method->getName().str();
- visitInfo.argument = method->getParamDecl( 0 )->getTypeSourceInfo()->getType().getAsString();
- pluginInfo.visitFunctions.insert( move( visitInfo ));
- }
- else
+ endOk = true;
+ break;
+ }
+ else if( line == "VisitFunctionStart" )
+ {
+ VisitFunctionInfo visitInfo;
+ getline( file, line );
+ visitInfo.name = getValue( line, "VisitFunctionName" );
+ getline( file, line );
+ visitInfo.argument = getValue( line, "VisitFunctionArgument" );
+ getline( file, line );
+ if( line != "VisitFunctionEnd" )
{
- cerr << "Unhandled Visit* function: " << pluginInfo.className << "::" << method->getName().str() << endl;
- abort();
+ cerr << "Missing VisitFunctionEnd" << endl;
+ return false;
}
+ pluginInfo.visitFunctions.insert( move( visitInfo ));
}
- else if( method->getName().startswith( "Traverse" ))
+ else if( line == "TraverseFunctionStart" )
{
- if( method->getNumParams() == 1 )
+ TraverseFunctionInfo traverseInfo;
+ getline( file, line );
+ traverseInfo.name = getValue( line, "TraverseFunctionName" );
+ getline( file, line );
+ traverseInfo.argument = getValue( line, "TraverseFunctionArgument" );
+ getline( file, line );
+ traverseInfo.hasPre = getValue( line, "TraverseFunctionHasPre" ) == "1";
+ getline( file, line );
+ traverseInfo.hasPost = getValue( line, "TraverseFunctionHasPost" ) == "1";
+ getline( file, line );
+ if( line != "TraverseFunctionEnd" )
{
- TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( pluginInfo, method->getName());
- traverseInfo.argument = method->getParamDecl( 0 )->getTypeSourceInfo()->getType().getAsString();
- pluginInfo.traverseFunctions.insert( move( traverseInfo ));
+ cerr << "Missing TraverseFunctionEnd" << endl;
+ return false;
}
+ pluginInfo.traverseFunctions.insert( move( traverseInfo ));
+ }
+ else
+ {
+ string value;
+ value = getValue( line, "ShouldVisitTemplateInstantiations" );
+ if( value == "1" )
+ pluginInfo.shouldVisitTemplateInstantiations = true;
else
{
- cerr << "Unhandled Traverse* function: " << pluginInfo.className << "::" << method->getName().str() << endl;
- abort();
+ value = getValue( line, "ShouldVisitImplicitCode" );
+ if( value == "1" )
+ pluginInfo.shouldVisitImplicitCode = true;
+ else
+ {
+ cerr << "Unknown line " << line << endl;
+ return false;
+ }
}
}
- else if( method->getName().startswith( "PreTraverse" ))
- {
- TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( pluginInfo, method->getName(). substr( 3 ));
- traverseInfo.hasPre = true;
- pluginInfo.traverseFunctions.insert( move( traverseInfo ));
- }
- else if( method->getName().startswith( "PostTraverse" ))
- {
- TraverseFunctionInfo traverseInfo = findOrCreateTraverseFunctionInfo( pluginInfo, method->getName().substr( 4 ));
- traverseInfo.hasPost = true;
- pluginInfo.traverseFunctions.insert( move( traverseInfo ));
- }
- else if( method->getName() == "shouldVisitTemplateInstantiations" )
- pluginInfo.shouldVisitTemplateInstantiations = true;
- else if( method->getName() == "shouldVisitImplicitCode" )
- pluginInfo.shouldVisitImplicitCode = true;
- else if( method->getName().startswith( "WalkUp" ))
- {
- cerr << "WalkUp function not supported for shared visitor: " << pluginInfo.className << "::" << method->getName().str() << endl;
- abort();
- }
}
+ assert( endOk );
+
if( pluginInfo.shouldVisitTemplateInstantiations && pluginInfo.shouldVisitImplicitCode )
plugins[ PluginVisitTemplatesImplicit ].push_back( move( pluginInfo ));
else if( pluginInfo.shouldVisitTemplateInstantiations )
@@ -484,104 +430,17 @@ bool CheckFileVisitor::VisitCXXRecordDecl( CXXRecordDecl* decl )
else
plugins[ PluginBasic ].push_back( move( pluginInfo ));
- foundSomething = true;
return true;
}
-
-class FindNamedClassConsumer
- : public ASTConsumer
-{
-public:
- virtual void HandleTranslationUnit(ASTContext& context) override
- {
- visitor.TraverseDecl( context.getTranslationUnitDecl());
- }
-private:
- CheckFileVisitor visitor;
-};
-
-class FindNamedClassAction
- : public ASTFrontendAction
- {
-public:
- virtual unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance&, StringRef ) override
- {
- return unique_ptr<ASTConsumer>( new FindNamedClassConsumer );
- }
-};
-
-
-string readSourceFile( const char* filename )
-{
- string contents;
- ifstream stream( filename );
- if( !stream )
- {
- cerr << "Failed to open: " << filename << endl;
- exit( 1 );
- }
- string line;
- bool hasIfdef = false;
- while( getline( stream, line ))
- {
- // TODO add checks that it's e.g. not "#ifdef" ?
- if( line.find( "#ifndef LO_CLANG_SHARED_PLUGINS" ) == 0 )
- hasIfdef = true;
- contents += line;
- contents += '\n';
- }
- if( stream.eof() && hasIfdef )
- return contents;
- return "";
-}
-
int main(int argc, char** argv)
{
- vector< string > args;
- int i = 1;
- for( ; i < argc; ++ i )
+ for( int i = 1 ; i < argc; ++i )
{
- constexpr std::size_t prefixlen = 5; // strlen("-arg=");
- if (std::strncmp(argv[i], "-arg=", prefixlen) != 0)
- {
- break;
- }
- args.push_back(argv[i] + prefixlen);
- }
-#define STRINGIFY2(a) #a
-#define STRINGIFY(a) STRINGIFY2(a)
- args.insert(
- args.end(),
- {
- "-I" BUILDDIR "/config_host", // plugin sources use e.g. config_global.h
- "-I" STRINGIFY(CLANGDIR) "/include", // clang's headers
- "-I" STRINGIFY(CLANGSYSINCLUDE), // clang system headers
- STDOPTION,
- "-D__STDC_CONSTANT_MACROS", // Clang headers require these.
- "-D__STDC_FORMAT_MACROS",
- "-D__STDC_LIMIT_MACROS",
- });
- for( ; i < argc; ++ i )
- {
- string contents = readSourceFile(argv[i]);
- if( contents.empty())
- continue;
- foundSomething = false;
-#if CLANG_VERSION >= 100000
- if( !clang::tooling::runToolOnCodeWithArgs( std::unique_ptr<FindNamedClassAction>(new FindNamedClassAction), contents, args, argv[ i ] ))
-#else
- if( !clang::tooling::runToolOnCodeWithArgs( new FindNamedClassAction, contents, args, argv[ i ] ))
-#endif
- {
- cerr << "Failed to analyze: " << argv[ i ] << endl;
- return 2;
- }
- if( !foundSomething )
+ if( !readFile( argv[ i ] ))
{
- // there's #ifndef LO_CLANG_SHARED_PLUGINS in the source, but no class matched
- cerr << "Failed to find code: " << argv[ i ] << endl;
- return 2;
+ cerr << "Error reading " << argv[ i ] << endl;
+ return 1;
}
}
for( int type = Plugin_Begin; type < Plugin_End; ++type )
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
deleted file mode 100644
index f38156ca4d19..000000000000
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ /dev/null
@@ -1,1848 +0,0 @@
-// 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 "../cppunitassertequals.cxx"
-#include "../data.cxx"
-#include "../datamembershadow.cxx"
-#include "../dbgunhandledexception.cxx"
-#include "../derefnullptr.cxx"
-#include "../dllprivate.cxx"
-#include "../doubleconvert.cxx"
-#include "../dynexcspec.cxx"
-#include "../empty.cxx"
-#include "../emptyif.cxx"
-#include "../externandnotdefined.cxx"
-#include "../externvar.cxx"
-#include "../external.cxx"
-#include "../finalprotected.cxx"
-#include "../indentation.cxx"
-#include "../inlinevisible.cxx"
-#include "../intvsfloat.cxx"
-#include "../literaltoboolconversion.cxx"
-#include "../logexceptionnicely.cxx"
-#include "../loopvartoosmall.cxx"
-#include "../mapindex.cxx"
-#include "../nestedunnamed.cxx"
-#include "../overrideparam.cxx"
-#include "../overridevirtual.cxx"
-#include "../passparamsbyref.cxx"
-#include "../pointerbool.cxx"
-#include "../privatebase.cxx"
-#include "../rangedforcopy.cxx"
-#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"
-#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 "../faileddyncast.cxx"
-#include "../ptrvector.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 )
- , cppunitAssertEquals( nullptr )
- , data( nullptr )
- , dataMemberShadow( nullptr )
- , dbgUnhandledException( nullptr )
- , derefNullPtr( nullptr )
- , dllPrivate( nullptr )
- , doubleConvert( nullptr )
- , dynExcSpec( nullptr )
- , empty( nullptr )
- , emptyIf( nullptr )
- , externAndNotDefined( nullptr )
- , externVar( nullptr )
- , external( nullptr )
- , finalProtected( nullptr )
- , indentation( nullptr )
- , inlineVisible( nullptr )
- , intVsFloat( nullptr )
- , literalToBoolConversion( nullptr )
- , logExceptionNicely( nullptr )
- , loopVarTooSmall( nullptr )
- , mapIndex( nullptr )
- , nestedUnnamed( nullptr )
- , overrideParam( nullptr )
- , overrideVirtual( nullptr )
- , passParamsByRef( nullptr )
- , pointerBool( nullptr )
- , privateBase( nullptr )
- , rangedForCopy( nullptr )
- , 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 )
- , 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
- {
- if( badStatics && !badStatics->preRun())
- badStatics = nullptr;
- if( blockBlock && !blockBlock->preRun())
- blockBlock = nullptr;
- if( charRightShift && !charRightShift->preRun())
- charRightShift = nullptr;
- if( cppunitAssertEquals && !cppunitAssertEquals->preRun())
- cppunitAssertEquals = nullptr;
- if( data && !data->preRun())
- data = nullptr;
- if( dataMemberShadow && !dataMemberShadow->preRun())
- dataMemberShadow = nullptr;
- if( dbgUnhandledException && !dbgUnhandledException->preRun())
- dbgUnhandledException = nullptr;
- if( derefNullPtr && !derefNullPtr->preRun())
- derefNullPtr = nullptr;
- if( dllPrivate && !dllPrivate->preRun())
- dllPrivate = nullptr;
- if( doubleConvert && !doubleConvert->preRun())
- doubleConvert = nullptr;
- if( dynExcSpec && !dynExcSpec->preRun())
- dynExcSpec = 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( external && !external->preRun())
- external = nullptr;
- if( finalProtected && !finalProtected->preRun())
- finalProtected = nullptr;
- if( indentation && !indentation->preRun())
- indentation = nullptr;
- if( inlineVisible && !inlineVisible->preRun())
- inlineVisible = nullptr;
- if( intVsFloat && !intVsFloat->preRun())
- intVsFloat = nullptr;
- if( literalToBoolConversion && !literalToBoolConversion->preRun())
- literalToBoolConversion = nullptr;
- if( logExceptionNicely && !logExceptionNicely->preRun())
- logExceptionNicely = nullptr;
- if( loopVarTooSmall && !loopVarTooSmall->preRun())
- loopVarTooSmall = nullptr;
- if( mapIndex && !mapIndex->preRun())
- mapIndex = nullptr;
- if( nestedUnnamed && !nestedUnnamed->preRun())
- nestedUnnamed = nullptr;
- if( overrideParam && !overrideParam->preRun())
- overrideParam = nullptr;
- if( overrideVirtual && !overrideVirtual->preRun())
- overrideVirtual = nullptr;
- if( passParamsByRef && !passParamsByRef->preRun())
- passParamsByRef = nullptr;
- if( pointerBool && !pointerBool->preRun())
- pointerBool = nullptr;
- if( privateBase && !privateBase->preRun())
- privateBase = nullptr;
- if( rangedForCopy && !rangedForCopy->preRun())
- rangedForCopy = nullptr;
- if( redundantFCast && !redundantFCast->preRun())
- redundantFCast = nullptr;
- if( redundantInline && !redundantInline->preRun())
- 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())
- simplifyConstruct = nullptr;
- if( staticAccess && !staticAccess->preRun())
- staticAccess = nullptr;
- if( staticAnonymous && !staticAnonymous->preRun())
- staticAnonymous = nullptr;
- if( stringBuffer && !stringBuffer->preRun())
- stringBuffer = 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();
- }
- virtual void postRun() override
- {
- if( badStatics )
- badStatics->postRun();
- if( blockBlock )
- blockBlock->postRun();
- if( charRightShift )
- charRightShift->postRun();
- if( cppunitAssertEquals )
- cppunitAssertEquals->postRun();
- if( data )
- data->postRun();
- if( dataMemberShadow )
- dataMemberShadow->postRun();
- if( dbgUnhandledException )
- dbgUnhandledException->postRun();
- if( derefNullPtr )
- derefNullPtr->postRun();
- if( dllPrivate )
- dllPrivate->postRun();
- if( doubleConvert )
- doubleConvert->postRun();
- if( dynExcSpec )
- dynExcSpec->postRun();
- if( empty )
- empty->postRun();
- if( emptyIf )
- emptyIf->postRun();
- if( externAndNotDefined )
- externAndNotDefined->postRun();
- if( externVar )
- externVar->postRun();
- if( external )
- external->postRun();
- if( finalProtected )
- finalProtected->postRun();
- if( indentation )
- indentation->postRun();
- if( inlineVisible )
- inlineVisible->postRun();
- if( intVsFloat )
- intVsFloat->postRun();
- if( literalToBoolConversion )
- literalToBoolConversion->postRun();
- if( logExceptionNicely )
- logExceptionNicely->postRun();
- if( loopVarTooSmall )
- loopVarTooSmall->postRun();
- if( mapIndex )
- mapIndex->postRun();
- if( nestedUnnamed )
- nestedUnnamed->postRun();
- if( overrideParam )
- overrideParam->postRun();
- if( overrideVirtual )
- overrideVirtual->postRun();
- if( passParamsByRef )
- passParamsByRef->postRun();
- if( pointerBool )
- pointerBool->postRun();
- if( privateBase )
- privateBase->postRun();
- if( rangedForCopy )
- rangedForCopy->postRun();
- if( redundantFCast )
- redundantFCast->postRun();
- if( redundantInline )
- 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 )
- simplifyConstruct->postRun();
- if( staticAccess )
- staticAccess->postRun();
- if( staticAnonymous )
- staticAnonymous->postRun();
- if( stringBuffer )
- stringBuffer->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();
- }
- 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, "cppunitassertequals" ) == 0 )
- cppunitAssertEquals = static_cast< CppunitAssertEquals* >( plugin );
- else if( strcmp( name, "data" ) == 0 )
- data = static_cast< Data* >( 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, "dllprivate" ) == 0 )
- dllPrivate = static_cast< DllPrivate* >( plugin );
- else if( strcmp( name, "doubleconvert" ) == 0 )
- doubleConvert = static_cast< DoubleConvert* >( plugin );
- else if( strcmp( name, "dynexcspec" ) == 0 )
- dynExcSpec = static_cast< DynExcSpec* >( 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, "external" ) == 0 )
- external = static_cast< External* >( plugin );
- else if( strcmp( name, "finalprotected" ) == 0 )
- finalProtected = static_cast< FinalProtected* >( plugin );
- else if( strcmp( name, "indentation" ) == 0 )
- indentation = static_cast< Indentation* >( plugin );
- else if( strcmp( name, "inlinevisible" ) == 0 )
- inlineVisible = static_cast< InlineVisible* >( plugin );
- else if( strcmp( name, "intvsfloat" ) == 0 )
- intVsFloat = static_cast< IntVsFloat* >( plugin );
- else if( strcmp( name, "literaltoboolconversion" ) == 0 )
- literalToBoolConversion = static_cast< LiteralToBoolConversion* >( plugin );
- else if( strcmp( name, "logexceptionnicely" ) == 0 )
- 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 )
- 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 )
- privateBase = static_cast< PrivateBase* >( plugin );
- else if( strcmp( name, "rangedforcopy" ) == 0 )
- rangedForCopy = static_cast< RangedForCopy* >( plugin );
- else if( strcmp( name, "redundantfcast" ) == 0 )
- redundantFCast = static_cast< RedundantFCast* >( plugin );
- else if( strcmp( name, "redundantinline" ) == 0 )
- 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 )
- 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, "stringbuffer" ) == 0 )
- stringBuffer = static_cast< StringBuffer* >( 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
- 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 ))
- return true;
- if( empty != nullptr )
- {
- if( !empty->VisitBinEQ( arg ))
- empty = nullptr;
- }
- if( intVsFloat != nullptr )
- {
- if( !intVsFloat->VisitBinEQ( arg ))
- intVsFloat = 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 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 ))
- return true;
- if( redundantFCast != nullptr )
- {
- if( !redundantFCast->VisitCXXConstructExpr( arg ))
- redundantFCast = nullptr;
- }
- if( referenceCasting != nullptr )
- {
- if( !referenceCasting->VisitCXXConstructExpr( arg ))
- referenceCasting = nullptr;
- }
- 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 VisitCXXForRangeStmt(const class clang::CXXForRangeStmt * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( rangedForCopy != nullptr )
- {
- if( !rangedForCopy->VisitCXXForRangeStmt( arg ))
- rangedForCopy = nullptr;
- }
- if( sequenceLoop != nullptr )
- {
- if( !sequenceLoop->VisitCXXForRangeStmt( arg ))
- sequenceLoop = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCXXFunctionalCastExpr(const class clang::CXXFunctionalCastExpr * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( redundantFCast != nullptr )
- {
- if( !redundantFCast->VisitCXXFunctionalCastExpr( arg ))
- redundantFCast = nullptr;
- }
- if( salUnicodeLiteral != nullptr )
- {
- if( !salUnicodeLiteral->VisitCXXFunctionalCastExpr( arg ))
- salUnicodeLiteral = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCXXMemberCallExpr(const class clang::CXXMemberCallExpr * arg)
- {
- 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 ))
- unoQuery = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCXXMethodDecl(const class clang::CXXMethodDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( finalProtected != nullptr )
- {
- if( !finalProtected->VisitCXXMethodDecl( arg ))
- finalProtected = nullptr;
- }
- if( overrideParam != nullptr )
- {
- if( !overrideParam->VisitCXXMethodDecl( arg ))
- overrideParam = nullptr;
- }
- if( overrideVirtual != nullptr )
- {
- if( !overrideVirtual->VisitCXXMethodDecl( arg ))
- overrideVirtual = nullptr;
- }
- if( typedefParam != nullptr )
- {
- if( !typedefParam->VisitCXXMethodDecl( arg ))
- typedefParam = nullptr;
- }
- 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( logExceptionNicely != nullptr )
- {
- if( !logExceptionNicely->VisitCXXOperatorCallExpr( arg ))
- logExceptionNicely = nullptr;
- }
- if( passParamsByRef != nullptr )
- {
- if( !passParamsByRef->VisitCXXOperatorCallExpr( arg ))
- passParamsByRef = nullptr;
- }
- if( unnecessaryParen != nullptr )
- {
- if( !unnecessaryParen->VisitCXXOperatorCallExpr( arg ))
- unnecessaryParen = nullptr;
- }
- if( unoAny != nullptr )
- {
- if( !unoAny->VisitCXXOperatorCallExpr( arg ))
- unoAny = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCXXRecordDecl(const class clang::CXXRecordDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( privateBase != nullptr )
- {
- 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)
- {
- if( ignoreLocation( arg ))
- return true;
- if( cppunitAssertEquals != nullptr )
- {
- if( !cppunitAssertEquals->VisitCallExpr( arg ))
- cppunitAssertEquals = nullptr;
- }
- if( dbgUnhandledException != nullptr )
- {
- if( !dbgUnhandledException->VisitCallExpr( arg ))
- dbgUnhandledException = nullptr;
- }
- if( pointerBool != nullptr )
- {
- if( !pointerBool->VisitCallExpr( arg ))
- pointerBool = nullptr;
- }
- if( redundantFCast != nullptr )
- {
- if( !redundantFCast->VisitCallExpr( arg ))
- redundantFCast = nullptr;
- }
- if( salLogAreas != nullptr )
- {
- if( !salLogAreas->VisitCallExpr( arg ))
- salLogAreas = nullptr;
- }
- if( stringConcat != nullptr )
- {
- if( !stringConcat->VisitCallExpr( arg ))
- stringConcat = 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( blockBlock != nullptr )
- {
- if( !blockBlock->VisitCaseStmt( arg ))
- blockBlock = nullptr;
- }
- if( unnecessaryParen != nullptr )
- {
- if( !unnecessaryParen->VisitCaseStmt( arg ))
- unnecessaryParen = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitClassTemplateDecl(const class clang::ClassTemplateDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( external != nullptr )
- {
- if( !external->VisitClassTemplateDecl( arg ))
- external = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCompoundStmt(const class clang::CompoundStmt * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( blockBlock != nullptr )
- {
- if( !blockBlock->VisitCompoundStmt( arg ))
- blockBlock = nullptr;
- }
- if( indentation != nullptr )
- {
- if( !indentation->VisitCompoundStmt( arg ))
- indentation = 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;
- }
- if( finalProtected != nullptr )
- {
- if( !finalProtected->VisitFieldDecl( arg ))
- finalProtected = 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( dynExcSpec != nullptr )
- {
- if( !dynExcSpec->VisitFunctionDecl( arg ))
- dynExcSpec = nullptr;
- }
- if( externAndNotDefined != nullptr )
- {
- if( !externAndNotDefined->VisitFunctionDecl( arg ))
- externAndNotDefined = nullptr;
- }
- if( external != nullptr )
- {
- if( !external->VisitFunctionDecl( arg ))
- external = nullptr;
- }
- if( inlineVisible != nullptr )
- {
- if( !inlineVisible->VisitFunctionDecl( arg ))
- inlineVisible = nullptr;
- }
- if( redundantInline != nullptr )
- {
- if( !redundantInline->VisitFunctionDecl( arg ))
- redundantInline = nullptr;
- }
- if( redundantPointerOps != nullptr )
- {
- if( !redundantPointerOps->VisitFunctionDecl( arg ))
- redundantPointerOps = nullptr;
- }
- if( returnConstVal != nullptr )
- {
- if( !returnConstVal->VisitFunctionDecl( arg ))
- returnConstVal = nullptr;
- }
- if( salLogAreas != nullptr )
- {
- if( !salLogAreas->VisitFunctionDecl( arg ))
- salLogAreas = 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 ))
- unrefFun = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitFunctionTemplateDecl(const class clang::FunctionTemplateDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( external != nullptr )
- {
- if( !external->VisitFunctionTemplateDecl( arg ))
- external = 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 VisitImplicitCastExpr(const class clang::ImplicitCastExpr * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( literalToBoolConversion != nullptr )
- {
- if( !literalToBoolConversion->VisitImplicitCastExpr( arg ))
- literalToBoolConversion = nullptr;
- }
- if( mapIndex != nullptr )
- {
- if( !mapIndex->VisitImplicitCastExpr( arg ))
- mapIndex = nullptr;
- }
- if( unicodeToChar != nullptr )
- {
- if( !unicodeToChar->VisitImplicitCastExpr( arg ))
- unicodeToChar = 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( mapIndex != nullptr )
- {
- if( !mapIndex->VisitMemberExpr( arg ))
- mapIndex = nullptr;
- }
- if( redundantPointerOps != nullptr )
- {
- if( !redundantPointerOps->VisitMemberExpr( arg ))
- redundantPointerOps = nullptr;
- }
- if( staticAccess != nullptr )
- {
- if( !staticAccess->VisitMemberExpr( arg ))
- staticAccess = nullptr;
- }
- if( unnecessaryParen != nullptr )
- {
- if( !unnecessaryParen->VisitMemberExpr( arg ))
- unnecessaryParen = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitNamedDecl(const class clang::NamedDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( dllPrivate != nullptr )
- {
- if( !dllPrivate->VisitNamedDecl( arg ))
- dllPrivate = nullptr;
- }
- if( reservedId != nullptr )
- {
- if( !reservedId->VisitNamedDecl( arg ))
- reservedId = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitNamespaceDecl(const class clang::NamespaceDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( nestedUnnamed != nullptr )
- {
- if( !nestedUnnamed->VisitNamespaceDecl( arg ))
- nestedUnnamed = 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( redundantFCast != nullptr )
- {
- if( !redundantFCast->VisitReturnStmt( arg ))
- redundantFCast = nullptr;
- }
- 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( indentation != nullptr )
- {
- if( !indentation->VisitSwitchStmt( arg ))
- indentation = nullptr;
- }
- if( unnecessaryParen != nullptr )
- {
- if( !unnecessaryParen->VisitSwitchStmt( arg ))
- unnecessaryParen = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitTagDecl(const class clang::TagDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( external != nullptr )
- {
- if( !external->VisitTagDecl( arg ))
- external = 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 VisitUnaryOperator(const class clang::UnaryOperator * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( data != nullptr )
- {
- if( !data->VisitUnaryOperator( arg ))
- data = nullptr;
- }
- if( redundantPointerOps != nullptr )
- {
- if( !redundantPointerOps->VisitUnaryOperator( arg ))
- redundantPointerOps = 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( external != nullptr )
- {
- if( !external->VisitVarDecl( arg ))
- external = nullptr;
- }
- if( intVsFloat != nullptr )
- {
- if( !intVsFloat->VisitVarDecl( arg ))
- intVsFloat = 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 VisitVarTemplateDecl(const class clang::VarTemplateDecl * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( external != nullptr )
- {
- if( !external->VisitVarTemplateDecl( arg ))
- external = 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 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;
- 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 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;
- 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 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 )
- {
- if( !passParamsByRef->PostTraverseFunctionDecl( arg, ret ))
- savePassParamsByRef = nullptr;
- }
- 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;
- if( simplifyConstruct != nullptr )
- {
- if( !simplifyConstruct->PreTraverseInitListExpr( arg ))
- simplifyConstruct = nullptr;
- }
- bool ret = RecursiveASTVisitor::TraverseInitListExpr( arg );
- simplifyConstruct = saveSimplifyConstruct;
- return ret;
- }
- bool TraverseLinkageSpecDecl(class clang::LinkageSpecDecl * arg)
- {
- LiteralToBoolConversion* saveLiteralToBoolConversion = literalToBoolConversion;
- if( literalToBoolConversion != nullptr )
- {
- if( !literalToBoolConversion->PreTraverseLinkageSpecDecl( arg ))
- literalToBoolConversion = nullptr;
- }
- bool ret = RecursiveASTVisitor::TraverseLinkageSpecDecl( arg );
- if( literalToBoolConversion != nullptr )
- {
- if( !literalToBoolConversion->PostTraverseLinkageSpecDecl( arg, ret ))
- saveLiteralToBoolConversion = nullptr;
- }
- literalToBoolConversion = saveLiteralToBoolConversion;
- 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;
- }
- bool TraverseSwitchStmt(class clang::SwitchStmt * arg)
- {
- Indentation* saveIndentation = indentation;
- if( indentation != nullptr )
- {
- if( !indentation->PreTraverseSwitchStmt( arg ))
- indentation = nullptr;
- }
- bool ret = RecursiveASTVisitor::TraverseSwitchStmt( arg );
- if( indentation != nullptr )
- {
- if( !indentation->PostTraverseSwitchStmt( arg, ret ))
- saveIndentation = nullptr;
- }
- indentation = saveIndentation;
- return ret;
- }
-private:
- bool anyPluginActive() const
- {
- return badStatics != nullptr
- || blockBlock != nullptr
- || charRightShift != nullptr
- || cppunitAssertEquals != nullptr
- || data != nullptr
- || dataMemberShadow != nullptr
- || dbgUnhandledException != nullptr
- || derefNullPtr != nullptr
- || dllPrivate != nullptr
- || doubleConvert != nullptr
- || dynExcSpec != nullptr
- || empty != nullptr
- || emptyIf != nullptr
- || externAndNotDefined != nullptr
- || externVar != nullptr
- || external != nullptr
- || finalProtected != nullptr
- || indentation != nullptr
- || inlineVisible != nullptr
- || intVsFloat != nullptr
- || literalToBoolConversion != nullptr
- || logExceptionNicely != nullptr
- || loopVarTooSmall != nullptr
- || mapIndex != nullptr
- || nestedUnnamed != nullptr
- || overrideParam != nullptr
- || overrideVirtual != nullptr
- || passParamsByRef != nullptr
- || pointerBool != nullptr
- || privateBase != nullptr
- || rangedForCopy != nullptr
- || 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
- || typedefParam != nullptr
- || unicodeToChar != nullptr
- || unnecessaryCatchThrow != nullptr
- || unnecessaryOverride != nullptr
- || unnecessaryParen != nullptr
- || unoAny != nullptr
- || unoQuery != nullptr
- || unrefFun != nullptr
- || unusedVariableCheck != nullptr
- || weakBase != nullptr
- || weakObject != nullptr;
- }
- BadStatics* badStatics;
- BlockBlock* blockBlock;
- CharRightShift* charRightShift;
- CppunitAssertEquals* cppunitAssertEquals;
- Data* data;
- DataMemberShadow* dataMemberShadow;
- DbgUnhandledException* dbgUnhandledException;
- DerefNullPtr* derefNullPtr;
- DllPrivate* dllPrivate;
- DoubleConvert* doubleConvert;
- DynExcSpec* dynExcSpec;
- Empty* empty;
- EmptyIf* emptyIf;
- ExternAndNotDefined* externAndNotDefined;
- ExternVar* externVar;
- External* external;
- FinalProtected* finalProtected;
- Indentation* indentation;
- InlineVisible* inlineVisible;
- IntVsFloat* intVsFloat;
- LiteralToBoolConversion* literalToBoolConversion;
- LogExceptionNicely* logExceptionNicely;
- LoopVarTooSmall* loopVarTooSmall;
- MapIndex* mapIndex;
- NestedUnnamed* nestedUnnamed;
- OverrideParam* overrideParam;
- OverrideVirtual* overrideVirtual;
- PassParamsByRef* passParamsByRef;
- PointerBool* pointerBool;
- PrivateBase* privateBase;
- RangedForCopy* rangedForCopy;
- 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;
- TypedefParam* typedefParam;
- UnicodeToChar* unicodeToChar;
- UnnecessaryCatchThrow* unnecessaryCatchThrow;
- UnnecessaryOverride* unnecessaryOverride;
- UnnecessaryParen* unnecessaryParen;
- UnoAny* unoAny;
- UnoQuery* unoQuery;
- UnrefFun* unrefFun;
- UnusedVariableCheck* unusedVariableCheck;
- WeakBase* weakBase;
- WeakObject* weakObject;
-};
-
-loplugin::Plugin::Registration< SharedRecursiveASTVisitorBasic > registrationBasic("sharedvisitorBasic");
-
-
-class SharedRecursiveASTVisitorVisitTemplates
- : public FilteringPlugin< SharedRecursiveASTVisitorVisitTemplates>
-{
-public:
- explicit SharedRecursiveASTVisitorVisitTemplates(const InstantiationData& rData)
- : FilteringPlugin(rData)
- , dynCastVisibility( nullptr )
- , failedDynCast( nullptr )
- , ptrVector( nullptr )
- , vCLWidgets( nullptr )
- {}
- virtual bool preRun() override
- {
- if( dynCastVisibility && !dynCastVisibility->preRun())
- dynCastVisibility = nullptr;
- if( failedDynCast && !failedDynCast->preRun())
- failedDynCast = nullptr;
- if( ptrVector && !ptrVector->preRun())
- ptrVector = nullptr;
- if( vCLWidgets && !vCLWidgets->preRun())
- vCLWidgets = nullptr;
- return anyPluginActive();
- }
- virtual void postRun() override
- {
- if( dynCastVisibility )
- dynCastVisibility->postRun();
- if( failedDynCast )
- failedDynCast->postRun();
- if( ptrVector )
- ptrVector->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, "faileddyncast" ) == 0 )
- failedDynCast = static_cast< FailedDynCast* >( plugin );
- else if( strcmp( name, "ptrvector" ) == 0 )
- ptrVector = static_cast< PtrVector* >( 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;
- }
- if( failedDynCast != nullptr )
- {
- if( !failedDynCast->VisitCXXDynamicCastExpr( arg ))
- failedDynCast = nullptr;
- }
- return anyPluginActive();
- }
- bool VisitCXXOperatorCallExpr(const class clang::CXXOperatorCallExpr * arg)
- {
- if( ignoreLocation( arg ))
- return true;
- if( ptrVector != nullptr )
- {
- if( !ptrVector->VisitCXXOperatorCallExpr( arg ))
- ptrVector = 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
- || failedDynCast != nullptr
- || ptrVector != nullptr
- || vCLWidgets != nullptr;
- }
- DynCastVisibility* dynCastVisibility;
- FailedDynCast* failedDynCast;
- PtrVector* ptrVector;
- VCLWidgets* vCLWidgets;
-};
-
-loplugin::Plugin::Registration< SharedRecursiveASTVisitorVisitTemplates > registrationVisitTemplates("sharedvisitorVisitTemplates");
-
-} // namespace loplugin
-
-#endif // LO_CLANG_SHARED_PLUGINS
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 97aa283ef771..258d31436ff6 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -1724,6 +1724,7 @@ compilerplugins/clang/sallogareas.cxx
compilerplugins/clang/sallogareas.hxx
compilerplugins/clang/salunicodeliteral.cxx
compilerplugins/clang/sfxpoolitem.cxx
+compilerplugins/clang/sharedvisitor/analyzer.cxx
compilerplugins/clang/sharedvisitor/generator.cxx
compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
compilerplugins/clang/simplifybool.cxx