2013-09-21 08:42:35 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2013-02-02 09:35:47 -06:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* Based on LLVM/Clang.
|
|
|
|
*
|
|
|
|
* This file is distributed under the University of Illinois Open Source
|
|
|
|
* License. See LICENSE.TXT for details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLUGINHANDLER_H
|
|
|
|
#define PLUGINHANDLER_H
|
|
|
|
|
|
|
|
#include "plugin.hxx"
|
|
|
|
|
2014-02-20 12:47:01 -06:00
|
|
|
#include <set>
|
|
|
|
|
2013-02-02 09:35:47 -06:00
|
|
|
#include <clang/AST/ASTConsumer.h>
|
|
|
|
#include <clang/Frontend/FrontendAction.h>
|
|
|
|
|
|
|
|
namespace loplugin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Class that manages all LO modules.
|
|
|
|
*/
|
|
|
|
class PluginHandler
|
|
|
|
: public ASTConsumer
|
|
|
|
{
|
|
|
|
public:
|
2013-03-21 10:42:10 -05:00
|
|
|
PluginHandler( CompilerInstance& compiler, const vector< string >& args );
|
2013-02-02 10:45:18 -06:00
|
|
|
virtual ~PluginHandler();
|
2013-05-31 11:34:11 -05:00
|
|
|
virtual void HandleTranslationUnit( ASTContext& context ) override;
|
2014-01-27 06:09:20 -06:00
|
|
|
static void registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault );
|
|
|
|
DiagnosticBuilder report( DiagnosticsEngine::Level level, const char * plugin, StringRef message,
|
|
|
|
CompilerInstance& compiler, SourceLocation loc = SourceLocation());
|
2014-02-20 12:47:01 -06:00
|
|
|
bool addRemoval( SourceLocation loc );
|
2013-02-02 09:35:47 -06:00
|
|
|
private:
|
2013-02-09 11:47:55 -06:00
|
|
|
void handleOption( const string& option );
|
2014-02-15 08:25:03 -06:00
|
|
|
void createPlugins( set< string > rewriters );
|
2013-02-02 12:31:24 -06:00
|
|
|
DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
|
2013-03-21 10:42:10 -05:00
|
|
|
CompilerInstance& compiler;
|
2013-02-02 09:35:47 -06:00
|
|
|
Rewriter rewriter;
|
2014-02-20 12:47:01 -06:00
|
|
|
set< SourceLocation > removals;
|
2013-02-09 11:47:55 -06:00
|
|
|
string scope;
|
2014-01-27 06:09:20 -06:00
|
|
|
string warningsOnly;
|
2013-02-02 09:35:47 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
The Clang plugin class, just forwards to PluginHandler.
|
|
|
|
*/
|
|
|
|
class LibreOfficeAction
|
|
|
|
: public PluginASTAction
|
|
|
|
{
|
|
|
|
public:
|
2014-08-11 08:16:08 -05:00
|
|
|
#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
|
|
|
|
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
|
|
|
|
#else
|
2013-02-02 09:35:47 -06:00
|
|
|
virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
|
2014-08-11 08:16:08 -05:00
|
|
|
#endif
|
|
|
|
|
2013-02-02 09:35:47 -06:00
|
|
|
virtual bool ParseArgs( const CompilerInstance& CI, const vector< string >& args );
|
|
|
|
private:
|
|
|
|
vector< string > _args;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif // COMPILEPLUGIN_H
|
2013-09-21 08:42:35 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|