bump product version to 5.0.4.1
[LibreOffice.git] / compilerplugins / clang / pluginhandler.hxx
blobb4fc0c36ae7a50e1236e3d173dd82fa86cf26a7f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * Based on LLVM/Clang.
7 * This file is distributed under the University of Illinois Open Source
8 * License. See LICENSE.TXT for details.
12 #ifndef PLUGINHANDLER_H
13 #define PLUGINHANDLER_H
15 #include "plugin.hxx"
17 #include <set>
19 #include <clang/AST/ASTConsumer.h>
20 #include <clang/Frontend/FrontendAction.h>
22 namespace loplugin
25 /**
26 Class that manages all LO modules.
28 class PluginHandler
29 : public ASTConsumer
31 public:
32 PluginHandler( CompilerInstance& compiler, const vector< string >& args );
33 virtual ~PluginHandler();
34 virtual void HandleTranslationUnit( ASTContext& context ) override;
35 static void registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault );
36 DiagnosticBuilder report( DiagnosticsEngine::Level level, const char * plugin, StringRef message,
37 CompilerInstance& compiler, SourceLocation loc = SourceLocation());
38 bool addRemoval( SourceLocation loc );
39 private:
40 void handleOption( const string& option );
41 void createPlugins( set< string > rewriters );
42 DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
43 CompilerInstance& compiler;
44 Rewriter rewriter;
45 set< SourceLocation > removals;
46 string scope;
47 string warningsOnly;
50 /**
51 The Clang plugin class, just forwards to PluginHandler.
53 class LibreOfficeAction
54 : public PluginASTAction
56 public:
57 #if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
58 virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
59 #else
60 virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
61 #endif
63 virtual bool ParseArgs( const CompilerInstance& CI, const vector< string >& args );
64 private:
65 vector< string > _args;
68 } // namespace
70 #endif // COMPILEPLUGIN_H
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */