diff options
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/bodynotinblock.cxx | 10 | ||||
-rw-r--r-- | compilerplugins/clang/bodynotinblock.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/literalalternative.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 22 | ||||
-rw-r--r-- | compilerplugins/clang/plugin.hxx | 25 | ||||
-rw-r--r-- | compilerplugins/clang/pluginhandler.cxx | 18 | ||||
-rw-r--r-- | compilerplugins/clang/pluginhandler.hxx | 6 | ||||
-rw-r--r-- | compilerplugins/clang/postfixincrementfix.cxx | 6 | ||||
-rw-r--r-- | compilerplugins/clang/postfixincrementfix.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/removeforwardstringdecl.cxx | 6 | ||||
-rw-r--r-- | compilerplugins/clang/removeforwardstringdecl.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/sallogareas.cxx | 15 | ||||
-rw-r--r-- | compilerplugins/clang/sallogareas.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/unusedvariablecheck.cxx | 6 | ||||
-rw-r--r-- | compilerplugins/clang/unusedvariablecheck.hxx | 2 |
15 files changed, 67 insertions, 65 deletions
diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx index cd3e1a08eafe..afd486d2bdd0 100644 --- a/compilerplugins/clang/bodynotinblock.cxx +++ b/compilerplugins/clang/bodynotinblock.cxx @@ -28,14 +28,14 @@ For example: Here either both statements should be inside {} or the second statement in indented wrong. */ -BodyNotInBlock::BodyNotInBlock( ASTContext& context ) - : Plugin( context ) +BodyNotInBlock::BodyNotInBlock( CompilerInstance& compiler ) + : Plugin( compiler ) { } void BodyNotInBlock::run() { - TraverseDecl( context.getTranslationUnitDecl()); + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); } bool BodyNotInBlock::VisitFunctionDecl( FunctionDecl* declaration ) @@ -110,9 +110,9 @@ void BodyNotInBlock::checkBody( const Stmt* body, SourceLocation stmtLocation, c if( it != parents[ parent_pos ]->child_end()) { bool invalid1, invalid2; - unsigned bodyColumn = context.getSourceManager() + unsigned bodyColumn = compiler.getSourceManager() .getPresumedColumnNumber( body->getLocStart(), &invalid1 ); - unsigned nextStatementColumn = context.getSourceManager() + unsigned nextStatementColumn = compiler.getSourceManager() .getPresumedColumnNumber( (*it)->getLocStart(), &invalid2 ); if( invalid1 || invalid2 ) return; diff --git a/compilerplugins/clang/bodynotinblock.hxx b/compilerplugins/clang/bodynotinblock.hxx index e8d35dd58480..23f76090e0e2 100644 --- a/compilerplugins/clang/bodynotinblock.hxx +++ b/compilerplugins/clang/bodynotinblock.hxx @@ -21,7 +21,7 @@ class BodyNotInBlock , public Plugin { public: - explicit BodyNotInBlock( ASTContext& context ); + explicit BodyNotInBlock( CompilerInstance& compiler ); virtual void run(); bool VisitFunctionDecl( FunctionDecl* declaration ); private: diff --git a/compilerplugins/clang/literalalternative.cxx b/compilerplugins/clang/literalalternative.cxx index e90b688ae259..06ba80304979 100644 --- a/compilerplugins/clang/literalalternative.cxx +++ b/compilerplugins/clang/literalalternative.cxx @@ -21,9 +21,9 @@ class LiteralAlternative: public RecursiveASTVisitor<LiteralAlternative>, public loplugin::Plugin { public: - explicit LiteralAlternative(ASTContext & context): Plugin(context) {} + explicit LiteralAlternative(CompilerInstance & compiler): Plugin(compiler) {} - virtual void run() { TraverseDecl(context.getTranslationUnitDecl()); } + virtual void run() { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitCallExpr(CallExpr * expr); }; @@ -65,7 +65,7 @@ bool LiteralAlternative::VisitCallExpr(CallExpr * expr) { // better to handle that at the level of non-expanded macros instead, // but I have not found out how to do that yet anyway): APSInt res; - if (expr->getArg(1)->isIntegerConstantExpr(res, context)) { + if (expr->getArg(1)->isIntegerConstantExpr(res, compiler.getASTContext())) { Expr const * arg0 = expr->getArg(0)->IgnoreParenImpCasts(); StringLiteral const * lit = dyn_cast<StringLiteral>(arg0); bool match = false; @@ -82,7 +82,7 @@ bool LiteralAlternative::VisitCallExpr(CallExpr * expr) { subs->getBase()->IgnoreParenImpCasts()); match = lit != nullptr && subs->getIdx()->isIntegerConstantExpr( - res, context) + res, compiler.getASTContext()) && res == 0; } } diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index f6c81f566ed1..75d55782009c 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -20,20 +20,20 @@ Base classes for plugin actions. namespace loplugin { -Plugin::Plugin( ASTContext& context ) - : context( context ) +Plugin::Plugin( CompilerInstance& compiler ) + : compiler( compiler ) { } DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc ) { - return report( level, message, context, loc ); + return report( level, message, compiler, loc ); } -DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, ASTContext& context, +DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, CompilerInstance& compiler, SourceLocation loc ) { - DiagnosticsEngine& diag = context.getDiagnostics(); + DiagnosticsEngine& diag = compiler.getDiagnostics(); #if 0 // Do some mappings (e.g. for -Werror) that clang does not do for custom messages for some reason. if( level == DiagnosticsEngine::Warning && diag.getWarningsAsErrors()) @@ -50,10 +50,10 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess bool Plugin::ignoreLocation( SourceLocation loc ) { - SourceLocation expansionLoc = context.getSourceManager().getExpansionLoc( loc ); - if( context.getSourceManager().isInSystemHeader( expansionLoc )) + SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc ); + if( compiler.getSourceManager().isInSystemHeader( expansionLoc )) return true; - const char* bufferName = context.getSourceManager().getPresumedLoc( expansionLoc ).getFilename(); + const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename(); if( bufferName == NULL ) return true; if( strncmp( bufferName, OUTDIR, strlen( OUTDIR )) == 0 @@ -64,15 +64,15 @@ bool Plugin::ignoreLocation( SourceLocation loc ) return true; } -void Plugin::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter ) +void Plugin::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ) { PluginHandler::registerPlugin( create, optionName, isRewriter ); } ///// -RewritePlugin::RewritePlugin( ASTContext& context, Rewriter& rewriter ) - : Plugin( context ) +RewritePlugin::RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter ) + : Plugin( compiler ) , rewriter( rewriter ) { } diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx index d30c37a21848..f564ca4700b3 100644 --- a/compilerplugins/clang/plugin.hxx +++ b/compilerplugins/clang/plugin.hxx @@ -17,6 +17,7 @@ #include <clang/AST/RecursiveASTVisitor.h> #include <clang/Basic/FileManager.h> #include <clang/Basic/SourceManager.h> +#include <clang/Frontend/CompilerInstance.h> #if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2 #include <clang/Rewrite/Rewriter.h> @@ -40,21 +41,21 @@ namespace loplugin class Plugin { public: - explicit Plugin( ASTContext& context ); + explicit Plugin( CompilerInstance& compiler ); virtual ~Plugin(); virtual void run() = 0; template< typename T > class Registration; DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, - ASTContext& context, SourceLocation loc = SourceLocation()); + CompilerInstance& compiler, SourceLocation loc = SourceLocation()); protected: bool ignoreLocation( SourceLocation loc ); bool ignoreLocation( const Decl* decl ); bool ignoreLocation( const Stmt* stmt ); - ASTContext& context; + CompilerInstance& compiler; private: - static void registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter ); - template< typename T > static Plugin* createHelper( ASTContext& context, Rewriter& rewriter ); + static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ); + template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter ); enum { isRewriter = false }; }; @@ -67,7 +68,7 @@ class RewritePlugin : public Plugin { public: - explicit RewritePlugin( ASTContext& context, Rewriter& rewriter ); + explicit RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter ); protected: // This enum allows passing just 'RemoveLineIfEmpty' to functions below. enum RemoveLineIfEmpty_t { RemoveLineIfEmpty }; @@ -109,7 +110,7 @@ class RewritePlugin Rewriter& rewriter; private: template< typename T > friend class Plugin::Registration; - template< typename T > static Plugin* createHelper( ASTContext& context, Rewriter& rewriter ); + template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter ); enum { isRewriter = true }; bool reportEditFailure( SourceLocation loc ); bool adjustForWholeStatement( SourceRange* range ); @@ -136,7 +137,7 @@ class Plugin::Registration class RegistrationCreate { public: - template< typename T, bool > static T* create( ASTContext& context, Rewriter& rewriter ); + template< typename T, bool > static T* create( CompilerInstance& compiler, Rewriter& rewriter ); }; ///// @@ -159,15 +160,15 @@ bool Plugin::ignoreLocation( const Stmt* stmt ) } template< typename T > -Plugin* Plugin::createHelper( ASTContext& context, Rewriter& ) +Plugin* Plugin::createHelper( CompilerInstance& compiler, Rewriter& ) { - return new T( context ); + return new T( compiler ); } template< typename T > -Plugin* RewritePlugin::createHelper( ASTContext& context, Rewriter& rewriter ) +Plugin* RewritePlugin::createHelper( CompilerInstance& compiler, Rewriter& rewriter ) { - return new T( context, rewriter ); + return new T( compiler, rewriter ); } template< typename T > diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index 7fa382c9d0ea..69b8c04466a4 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -25,7 +25,7 @@ namespace loplugin struct PluginData { - Plugin* (*create)( ASTContext&, Rewriter& ); + Plugin* (*create)( CompilerInstance&, Rewriter& ); Plugin* object; const char* optionName; bool isRewriter; @@ -36,9 +36,9 @@ static PluginData plugins[ MAX_PLUGINS ]; static int pluginCount = 0; static bool pluginObjectsCreated = false; -PluginHandler::PluginHandler( ASTContext& context, const vector< string >& args ) - : context( context ) - , rewriter( context.getSourceManager(), context.getLangOpts()) +PluginHandler::PluginHandler( CompilerInstance& compiler, const vector< string >& args ) + : compiler( compiler ) + , rewriter( compiler.getSourceManager(), compiler.getLangOpts()) , scope( "mainfile" ) { bool wasPlugin = false; @@ -95,11 +95,11 @@ void PluginHandler::createPlugin( const string& name ) if( name.empty()) // no plugin given -> create non-writer plugins { if( !plugins[ i ].isRewriter ) - plugins[ i ].object = plugins[ i ].create( context, rewriter ); + plugins[ i ].object = plugins[ i ].create( compiler, rewriter ); } else if( plugins[ i ].optionName == name ) { - plugins[ i ].object = plugins[ i ].create( context, rewriter ); + plugins[ i ].object = plugins[ i ].create( compiler, rewriter ); return; } } @@ -107,7 +107,7 @@ void PluginHandler::createPlugin( const string& name ) report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name; } -void PluginHandler::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter ) +void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ) { assert( !pluginObjectsCreated ); assert( pluginCount < MAX_PLUGINS ); @@ -120,7 +120,7 @@ void PluginHandler::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc ) { - return Plugin::report( level, message, context, loc ); + return Plugin::report( level, message, compiler, loc ); } void PluginHandler::HandleTranslationUnit( ASTContext& context ) @@ -218,7 +218,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) ASTConsumer* LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef ) { - return new PluginHandler( Compiler.getASTContext(), _args ); + return new PluginHandler( Compiler, _args ); } bool LibreOfficeAction::ParseArgs( const CompilerInstance&, const vector< string >& args ) diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx index 0a3251eeeb4f..fcba5820b56a 100644 --- a/compilerplugins/clang/pluginhandler.hxx +++ b/compilerplugins/clang/pluginhandler.hxx @@ -26,15 +26,15 @@ class PluginHandler : public ASTConsumer { public: - PluginHandler( ASTContext& context, const vector< string >& args ); + PluginHandler( CompilerInstance& compiler, const vector< string >& args ); virtual ~PluginHandler(); virtual void HandleTranslationUnit( ASTContext& context ); - static void registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter ); + static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ); private: void handleOption( const string& option ); void createPlugin( const string& name ); DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); - ASTContext& context; + CompilerInstance& compiler; Rewriter rewriter; string scope; }; diff --git a/compilerplugins/clang/postfixincrementfix.cxx b/compilerplugins/clang/postfixincrementfix.cxx index 6520ee8b1726..0402dec2bcfb 100644 --- a/compilerplugins/clang/postfixincrementfix.cxx +++ b/compilerplugins/clang/postfixincrementfix.cxx @@ -19,14 +19,14 @@ Change all postfix ++ operators of non-trivial types to prefix if possible. namespace loplugin { -PostfixIncrementFix::PostfixIncrementFix( ASTContext& context, Rewriter& rewriter ) - : RewritePlugin( context, rewriter ) +PostfixIncrementFix::PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter ) + : RewritePlugin( compiler, rewriter ) { } void PostfixIncrementFix::run() { - TraverseDecl( context.getTranslationUnitDecl()); + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); } bool PostfixIncrementFix::VisitFunctionDecl( FunctionDecl* declaration ) diff --git a/compilerplugins/clang/postfixincrementfix.hxx b/compilerplugins/clang/postfixincrementfix.hxx index 7edb352c484d..f3afbd7f223d 100644 --- a/compilerplugins/clang/postfixincrementfix.hxx +++ b/compilerplugins/clang/postfixincrementfix.hxx @@ -21,7 +21,7 @@ class PostfixIncrementFix , public RewritePlugin { public: - explicit PostfixIncrementFix( ASTContext& context, Rewriter& rewriter ); + explicit PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter ); virtual void run(); bool VisitFunctionDecl( FunctionDecl* declaration ); private: diff --git a/compilerplugins/clang/removeforwardstringdecl.cxx b/compilerplugins/clang/removeforwardstringdecl.cxx index 736cbe3e0ab2..8350c777abd1 100644 --- a/compilerplugins/clang/removeforwardstringdecl.cxx +++ b/compilerplugins/clang/removeforwardstringdecl.cxx @@ -19,14 +19,14 @@ Remove all forward declarations of rtl strings. I.e. 'namespace rtl { class OUSt namespace loplugin { -RemoveForwardStringDecl::RemoveForwardStringDecl( ASTContext& context, Rewriter& rewriter ) - : RewritePlugin( context, rewriter ) +RemoveForwardStringDecl::RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ) + : RewritePlugin( compiler, rewriter ) { } void RemoveForwardStringDecl::run() { - TraverseDecl( context.getTranslationUnitDecl()); + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); } bool RemoveForwardStringDecl::VisitNamespaceDecl( NamespaceDecl* declaration ) diff --git a/compilerplugins/clang/removeforwardstringdecl.hxx b/compilerplugins/clang/removeforwardstringdecl.hxx index 2b66a522fc4d..b57afebe2db3 100644 --- a/compilerplugins/clang/removeforwardstringdecl.hxx +++ b/compilerplugins/clang/removeforwardstringdecl.hxx @@ -21,7 +21,7 @@ class RemoveForwardStringDecl , public RewritePlugin { public: - explicit RemoveForwardStringDecl( ASTContext& context, Rewriter& rewriter ); + explicit RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ); virtual void run(); bool VisitNamespaceDecl( NamespaceDecl* declaration ); private: diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index 2f88905296df..7ce64bc76b34 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -25,8 +25,8 @@ report if the area is not listed there. The fix is either use a proper area or a if appropriate. */ -SalLogAreas::SalLogAreas( ASTContext& context ) - : Plugin( context ) +SalLogAreas::SalLogAreas( CompilerInstance& compiler ) + : Plugin( compiler ) { } @@ -34,7 +34,7 @@ void SalLogAreas::run() { inFunction = NULL; lastSalDetailLogStreamMacro = SourceLocation(); - TraverseDecl( context.getTranslationUnitDecl()); + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); } bool SalLogAreas::VisitFunctionDecl( FunctionDecl* function ) @@ -59,7 +59,7 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call ) // The SAL_DETAIL_LOG_STREAM macro expands to two calls to sal::detail::log(), // so do not warn repeatedly about the same macro (the area->getLocStart() of all the calls // from the same macro should be the same). - SourceLocation expansionLocation = context.getSourceManager().getExpansionLoc( call->getLocStart()); + SourceLocation expansionLocation = compiler.getSourceManager().getExpansionLoc( call->getLocStart()); if( expansionLocation == lastSalDetailLogStreamMacro ) return true; lastSalDetailLogStreamMacro = expansionLocation; @@ -74,14 +74,15 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call ) } if( inFunction->getQualifiedNameAsString() == "sal::detail::log" ) return true; // This function only forwards to sal_detail_log, so ok. - if( call->getArg( 1 )->isNullPointerConstant( context, Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull ) + if( call->getArg( 1 )->isNullPointerConstant( compiler.getASTContext(), + Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull ) { // If the area argument is a null pointer, that is allowed only for SAL_DEBUG. - const SourceManager& source = context.getSourceManager(); + const SourceManager& source = compiler.getSourceManager(); for( SourceLocation loc = call->getLocStart(); loc.isMacroID(); loc = source.getImmediateExpansionRange( loc ).first ) { - StringRef inMacro = Lexer::getImmediateMacroName( loc, source, context.getLangOpts()); + StringRef inMacro = Lexer::getImmediateMacroName( loc, source, compiler.getLangOpts()); if( inMacro == "SAL_DEBUG" ) return true; // ok } diff --git a/compilerplugins/clang/sallogareas.hxx b/compilerplugins/clang/sallogareas.hxx index d572591c62ee..4b3e3664ea0a 100644 --- a/compilerplugins/clang/sallogareas.hxx +++ b/compilerplugins/clang/sallogareas.hxx @@ -23,7 +23,7 @@ class SalLogAreas , public Plugin { public: - explicit SalLogAreas( ASTContext& context ); + explicit SalLogAreas( CompilerInstance& compiler ); virtual void run(); bool VisitFunctionDecl( FunctionDecl* function ); bool VisitCallExpr( CallExpr* call ); diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index 989269f59e7f..c0bf8be522c3 100644 --- a/compilerplugins/clang/unusedvariablecheck.cxx +++ b/compilerplugins/clang/unusedvariablecheck.cxx @@ -30,14 +30,14 @@ SAL_WARN_UNUSED (see e.g. OUString). For external classes such as std::vector that cannot be edited there is a manual list below. */ -UnusedVariableCheck::UnusedVariableCheck( ASTContext& context ) - : Plugin( context ) +UnusedVariableCheck::UnusedVariableCheck( CompilerInstance& compiler ) + : Plugin( compiler ) { } void UnusedVariableCheck::run() { - TraverseDecl( context.getTranslationUnitDecl()); + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); } bool UnusedVariableCheck::VisitVarDecl( VarDecl* var ) diff --git a/compilerplugins/clang/unusedvariablecheck.hxx b/compilerplugins/clang/unusedvariablecheck.hxx index 6ccdee3e193e..98df658026c5 100644 --- a/compilerplugins/clang/unusedvariablecheck.hxx +++ b/compilerplugins/clang/unusedvariablecheck.hxx @@ -21,7 +21,7 @@ class UnusedVariableCheck , public Plugin { public: - explicit UnusedVariableCheck( ASTContext& context ); + explicit UnusedVariableCheck( CompilerInstance& compiler ); virtual void run(); bool VisitVarDecl( VarDecl* var ); }; |