cURL: follow redirects
[LibreOffice.git] / compilerplugins / clang / pluginhandler.hxx
blobf0cece4deb8c425f2b5d1bf9a1de47bd5bab636c
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;
48 bool warningsAsErrors;
51 /**
52 The Clang plugin class, just forwards to PluginHandler.
54 class LibreOfficeAction
55 : public PluginASTAction
57 public:
58 #if CLANG_VERSION >= 30600
59 virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
60 #else
61 virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
62 #endif
64 virtual bool ParseArgs( const CompilerInstance& CI, const vector< string >& args );
65 private:
66 vector< string > _args;
69 } // namespace
71 #endif // COMPILEPLUGIN_H
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */