From 1f078fcaddd45bb074e4d0a4933db01f6e8b623e Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 27 Jan 2014 13:09:20 +0100 Subject: Prepare dual-mode compiler plugin feature ...which can act as either a rewriter or a non-rewriter that emits warnings. Also added COMPILER_PLUGIN_WARNINGS_ONLY=X to demote warnings from plugin X from errors to warnings, even under --enable-werror. Change-Id: I05361936240a890515c6bba2459565417c1746b7 --- compilerplugins/README | 16 ++++++ compilerplugins/clang/bodynotinblock.cxx | 4 +- compilerplugins/clang/bodynotinblock.hxx | 2 +- compilerplugins/clang/checkconfigmacros.cxx | 6 +- compilerplugins/clang/implicitboolconversion.cxx | 4 +- compilerplugins/clang/literalalternative.cxx | 2 +- compilerplugins/clang/plugin.cxx | 67 +++++++++++------------ compilerplugins/clang/plugin.hxx | 45 ++++++++------- compilerplugins/clang/pluginhandler.cxx | 47 +++++++++++++--- compilerplugins/clang/pluginhandler.hxx | 5 +- compilerplugins/clang/pointertobool.cxx | 6 +- compilerplugins/clang/postfixincrementfix.cxx | 4 +- compilerplugins/clang/postfixincrementfix.hxx | 2 +- compilerplugins/clang/rtlconstasciimacro.cxx | 6 +- compilerplugins/clang/sallogareas.cxx | 4 +- compilerplugins/clang/sallogareas.hxx | 2 +- compilerplugins/clang/svstreamoutputoperators.cxx | 6 +- compilerplugins/clang/unusedvariablecheck.cxx | 4 +- compilerplugins/clang/unusedvariablecheck.hxx | 2 +- 19 files changed, 140 insertions(+), 94 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/README b/compilerplugins/README index 78bc28b3db6b..c48341e0f0d2 100644 --- a/compilerplugins/README +++ b/compilerplugins/README @@ -46,6 +46,22 @@ Additional optional make arguments: Modifications will be written directly to the source files. +Some rewriter plugins are dual-mode and can also be used in a non-rewriting mode +in which they emit warnings for problematic code that they would otherwise +automatically rewrite. When any rewriter is enabled explicitly via "make +COMPILER_PLUGIN_TOOL=" it works in rewriting mode (and all other +plugins are disabled), but when no rewriter is explicitly enabled (i.e., just +"make"), all dual-mode rewriters are enabled in non-rewriting mode (along with +all non-rewriter plugins; and all non--dual-mode plugins are disabled). The +typical process to use such a dual-mode rewriter X in rewriting mode is + + make COMPILER_PLUGIN_WARNINGS_ONLY=X \ + && make COMPILER_PLUGIN_TOOL=X FORCE_COMPILE_ALL=1 UPDATE_FILES=all + +which first generates a full build without failing due to warnings from plugin +X in non-rewriting mode (in case of --enable-werror) and then repeats the build +in rewriting mode (during which no object files are generate). + == Code documentation / howtos == diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx index af4dc28f11cc..210aa36e051a 100644 --- a/compilerplugins/clang/bodynotinblock.cxx +++ b/compilerplugins/clang/bodynotinblock.cxx @@ -29,8 +29,8 @@ For example: Here either both statements should be inside {} or the second statement in indented wrong. */ -BodyNotInBlock::BodyNotInBlock( CompilerInstance& compiler ) - : Plugin( compiler ) +BodyNotInBlock::BodyNotInBlock( const InstantiationData& data ) + : Plugin( data ) { } diff --git a/compilerplugins/clang/bodynotinblock.hxx b/compilerplugins/clang/bodynotinblock.hxx index 5a91b9124ace..e79060b8a073 100644 --- a/compilerplugins/clang/bodynotinblock.hxx +++ b/compilerplugins/clang/bodynotinblock.hxx @@ -22,7 +22,7 @@ class BodyNotInBlock , public Plugin { public: - explicit BodyNotInBlock( CompilerInstance& compiler ); + explicit BodyNotInBlock( const InstantiationData& data ); virtual void run() override; bool VisitIfStmt( const IfStmt* stmt ); bool VisitWhileStmt( const WhileStmt* stmt ); diff --git a/compilerplugins/clang/checkconfigmacros.cxx b/compilerplugins/clang/checkconfigmacros.cxx index 43f723882a02..608800db2642 100644 --- a/compilerplugins/clang/checkconfigmacros.cxx +++ b/compilerplugins/clang/checkconfigmacros.cxx @@ -31,7 +31,7 @@ class CheckConfigMacros , public Plugin { public: - explicit CheckConfigMacros( CompilerInstance& compiler ); + explicit CheckConfigMacros( const InstantiationData& data ); virtual void run() override; #if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3 virtual void MacroDefined( const Token& macroToken, const MacroInfo* info ) override; @@ -56,8 +56,8 @@ class CheckConfigMacros std::set< string > configMacros; }; -CheckConfigMacros::CheckConfigMacros( CompilerInstance& compiler ) - : Plugin( compiler ) +CheckConfigMacros::CheckConfigMacros( const InstantiationData& data ) + : Plugin( data ) { compiler.getPreprocessor().addPPCallbacks( this ); } diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index a804b0d1d70e..e939295e782b 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -99,8 +99,8 @@ class ImplicitBoolConversion: public RecursiveASTVisitor, public loplugin::Plugin { public: - explicit ImplicitBoolConversion(CompilerInstance & compiler): - Plugin(compiler) {} + explicit ImplicitBoolConversion(InstantiationData const & data): + Plugin(data) {} virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/compilerplugins/clang/literalalternative.cxx b/compilerplugins/clang/literalalternative.cxx index 4d2711c3d64c..0d29e0d1d050 100644 --- a/compilerplugins/clang/literalalternative.cxx +++ b/compilerplugins/clang/literalalternative.cxx @@ -21,7 +21,7 @@ class LiteralAlternative: public RecursiveASTVisitor, public loplugin::Plugin { public: - explicit LiteralAlternative(CompilerInstance & compiler): Plugin(compiler) {} + explicit LiteralAlternative(InstantiationData const & data): Plugin(data) {} virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 4a936e4d4166..2aff6cf0c7b5 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -11,6 +11,8 @@ #include "plugin.hxx" +#include + #include #include @@ -22,30 +24,14 @@ Base classes for plugin actions. namespace loplugin { -Plugin::Plugin( CompilerInstance& compiler ) - : compiler( compiler ) +Plugin::Plugin( const InstantiationData& data ) + : compiler( data.compiler ), name( data.name ), handler( data.handler ) { } DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc ) { - return report( level, message, compiler, loc ); - } - -DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, CompilerInstance& compiler, - SourceLocation loc ) - { - DiagnosticsEngine& diag = compiler.getDiagnostics(); - // Do some mappings (e.g. for -Werror) that clang does not do for custom messages for some reason. - if( level == DiagnosticsEngine::Warning && diag.getWarningsAsErrors()) - level = DiagnosticsEngine::Error; - if( level == DiagnosticsEngine::Error && diag.getErrorsAsFatal()) - level = DiagnosticsEngine::Fatal; - string fullMessage = ( message + " [loplugin]" ).str(); - if( loc.isValid()) - return diag.Report( loc, diag.getCustomDiagID( level, fullMessage )); - else - return diag.Report( diag.getCustomDiagID( level, fullMessage )); + return handler.report( level, name, message, compiler, loc ); } bool Plugin::ignoreLocation( SourceLocation loc ) @@ -63,9 +49,9 @@ bool Plugin::ignoreLocation( SourceLocation loc ) return true; } -void Plugin::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback ) +void Plugin::registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ) { - PluginHandler::registerPlugin( create, optionName, isRewriter, isPPCallback ); + PluginHandler::registerPlugin( create, optionName, isPPCallback, byDefault ); } unordered_map< const Stmt*, const Stmt* > Plugin::parents; @@ -152,36 +138,40 @@ SourceLocation Plugin::locationAfterToken( SourceLocation location ) ///// -RewritePlugin::RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter ) - : Plugin( compiler ) - , rewriter( rewriter ) +RewritePlugin::RewritePlugin( const InstantiationData& data ) + : Plugin( data ) + , rewriter( data.rewriter ) { } bool RewritePlugin::insertText( SourceLocation Loc, StringRef Str, bool InsertAfter, bool indentNewLines ) { - if( rewriter.InsertText( Loc, Str, InsertAfter, indentNewLines )) + assert( rewriter ); + if( rewriter->InsertText( Loc, Str, InsertAfter, indentNewLines )) return reportEditFailure( Loc ); return true; } bool RewritePlugin::insertTextAfter( SourceLocation Loc, StringRef Str ) { - if( rewriter.InsertTextAfter( Loc, Str )) + assert( rewriter ); + if( rewriter->InsertTextAfter( Loc, Str )) return reportEditFailure( Loc ); return true; } bool RewritePlugin::insertTextAfterToken( SourceLocation Loc, StringRef Str ) { - if( rewriter.InsertTextAfterToken( Loc, Str )) + assert( rewriter ); + if( rewriter->InsertTextAfterToken( Loc, Str )) return reportEditFailure( Loc ); return true; } bool RewritePlugin::insertTextBefore( SourceLocation Loc, StringRef Str ) { - if( rewriter.InsertTextBefore( Loc, Str )) + assert( rewriter ); + if( rewriter->InsertTextBefore( Loc, Str )) return reportEditFailure( Loc ); return true; } @@ -199,7 +189,8 @@ bool RewritePlugin::removeText( SourceRange range, RewriteOptions opts ) bool RewritePlugin::removeText( CharSourceRange range, RewriteOptions opts ) { - if( rewriter.getRangeSize( range, opts ) == -1 ) + assert( rewriter ); + if( rewriter->getRangeSize( range, opts ) == -1 ) return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code removal, possible plugin error", range.getBegin()); @@ -209,14 +200,15 @@ bool RewritePlugin::removeText( CharSourceRange range, RewriteOptions opts ) if( !adjustRangeForOptions( &range, opts )) return reportEditFailure( range.getBegin()); } - if( rewriter.RemoveText( range, opts )) + if( rewriter->RemoveText( range, opts )) return reportEditFailure( range.getBegin()); return true; } bool RewritePlugin::adjustRangeForOptions( CharSourceRange* range, RewriteOptions opts ) { - SourceManager& SM = rewriter.getSourceMgr(); + assert( rewriter ); + SourceManager& SM = rewriter->getSourceMgr(); SourceLocation fileStartLoc = SM.getLocForStartOfFile( SM.getFileID( range->getBegin())); if( fileStartLoc.isInvalid()) return false; @@ -256,34 +248,37 @@ bool RewritePlugin::adjustRangeForOptions( CharSourceRange* range, RewriteOption bool RewritePlugin::replaceText( SourceLocation Start, unsigned OrigLength, StringRef NewStr ) { + assert( rewriter ); if( OrigLength != 0 && removals.find( Start ) != removals.end()) report( DiagnosticsEngine::Warning, "double code replacement, possible plugin error", Start ); removals.insert( Start ); - if( rewriter.ReplaceText( Start, OrigLength, NewStr )) + if( rewriter->ReplaceText( Start, OrigLength, NewStr )) return reportEditFailure( Start ); return true; } bool RewritePlugin::replaceText( SourceRange range, StringRef NewStr ) { - if( rewriter.getRangeSize( range ) == -1 ) + assert( rewriter ); + if( rewriter->getRangeSize( range ) == -1 ) return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code replacement, possible plugin error", range.getBegin()); removals.insert( range.getBegin()); - if( rewriter.ReplaceText( range, NewStr )) + if( rewriter->ReplaceText( range, NewStr )) return reportEditFailure( range.getBegin()); return true; } bool RewritePlugin::replaceText( SourceRange range, SourceRange replacementRange ) { - if( rewriter.getRangeSize( range ) == -1 ) + assert( rewriter ); + if( rewriter->getRangeSize( range ) == -1 ) return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code replacement, possible plugin error", range.getBegin()); removals.insert( range.getBegin()); - if( rewriter.ReplaceText( range, replacementRange )) + if( rewriter->ReplaceText( range, replacementRange )) return reportEditFailure( range.getBegin()); return true; } diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx index 44939fbb828b..5af4b04619ce 100644 --- a/compilerplugins/clang/plugin.hxx +++ b/compilerplugins/clang/plugin.hxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,8 @@ using namespace std; namespace loplugin { +class PluginHandler; + /** Base class for plugins. @@ -44,17 +47,22 @@ namespace loplugin class Plugin { public: - explicit Plugin( CompilerInstance& compiler ); + struct InstantiationData + { + const char* name; + PluginHandler& handler; + CompilerInstance& compiler; + Rewriter* rewriter; + }; + explicit Plugin( const InstantiationData& data ); virtual ~Plugin(); virtual void run() = 0; template< typename T > class Registration; enum { isPPCallback = false }; - DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); - static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, - CompilerInstance& compiler, SourceLocation loc = SourceLocation()); // Returns location right after the end of the token that starts at the given location. SourceLocation locationAfterToken( SourceLocation location ); protected: + DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); bool ignoreLocation( SourceLocation loc ); bool ignoreLocation( const Decl* decl ); bool ignoreLocation( const Stmt* stmt ); @@ -66,9 +74,11 @@ class Plugin const Stmt* parentStmt( const Stmt* stmt ); Stmt* parentStmt( Stmt* stmt ); private: - static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback ); - template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter ); + static void registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ); + template< typename T > static Plugin* createHelper( const InstantiationData& data ); enum { isRewriter = false }; + const char* name; + PluginHandler& handler; static unordered_map< const Stmt*, const Stmt* > parents; static void buildParents( CompilerInstance& compiler ); }; @@ -82,7 +92,7 @@ class RewritePlugin : public Plugin { public: - explicit RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter ); + explicit RewritePlugin( const InstantiationData& data ); protected: enum RewriteOption { @@ -123,10 +133,9 @@ class RewritePlugin bool replaceText( SourceLocation Start, unsigned OrigLength, StringRef NewStr ); bool replaceText( SourceRange range, StringRef NewStr ); bool replaceText( SourceRange range, SourceRange replacementRange ); - Rewriter& rewriter; + Rewriter* rewriter; private: template< typename T > friend class Plugin::Registration; - template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter ); enum { isRewriter = true }; bool reportEditFailure( SourceLocation loc ); bool adjustRangeForOptions( CharSourceRange* range, RewriteOptions options ); @@ -148,13 +157,13 @@ template< typename T > class Plugin::Registration { public: - Registration( const char* optionName ); + Registration( const char* optionName, bool byDefault = !T::isRewriter ); }; class RegistrationCreate { public: - template< typename T, bool > static T* create( CompilerInstance& compiler, Rewriter& rewriter ); + template< typename T, bool > static T* create( const Plugin::InstantiationData& data ); }; ///// @@ -177,22 +186,16 @@ bool Plugin::ignoreLocation( const Stmt* stmt ) } template< typename T > -Plugin* Plugin::createHelper( CompilerInstance& compiler, Rewriter& ) - { - return new T( compiler ); - } - -template< typename T > -Plugin* RewritePlugin::createHelper( CompilerInstance& compiler, Rewriter& rewriter ) +Plugin* Plugin::createHelper( const InstantiationData& data ) { - return new T( compiler, rewriter ); + return new T( data ); } template< typename T > inline -Plugin::Registration< T >::Registration( const char* optionName ) +Plugin::Registration< T >::Registration( const char* optionName, bool byDefault ) { - registerPlugin( &T::template createHelper< T >, optionName, T::isRewriter, T::isPPCallback ); + registerPlugin( &T::template createHelper< T >, optionName, T::isPPCallback, byDefault ); } inline diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index a49398a53a82..440df1cf07fb 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -38,11 +38,11 @@ namespace loplugin struct PluginData { - Plugin* (*create)( CompilerInstance&, Rewriter& ); + Plugin* (*create)( const Plugin::InstantiationData& ); Plugin* object; const char* optionName; - bool isRewriter; bool isPPCallback; + bool byDefault; }; const int MAX_PLUGINS = 100; @@ -100,6 +100,10 @@ void PluginHandler::handleOption( const string& option ) report( DiagnosticsEngine::Fatal, "unknown scope %0 (no such module directory)" ) << scope; } } + else if( option.substr( 0, 14 ) == "warnings-only=" ) + { + warningsOnly = option.substr(14); + } else report( DiagnosticsEngine::Fatal, "unknown option %0" ) << option; } @@ -110,14 +114,17 @@ void PluginHandler::createPlugin( const string& name ) i < pluginCount; ++i ) { - if( name.empty()) // no plugin given -> create non-writer plugins + // if no plugin is given, create all by-default plugins as non- + // rewriters; otherwise, create the given plugin as a potential + // rewriter: + if( name.empty()) { - if( !plugins[ i ].isRewriter ) - plugins[ i ].object = plugins[ i ].create( compiler, rewriter ); + if( plugins[ i ].byDefault ) + plugins[ i ].object = plugins[ i ].create( Plugin::InstantiationData { plugins[ i ].optionName, *this, compiler, NULL } ); } else if( plugins[ i ].optionName == name ) { - plugins[ i ].object = plugins[ i ].create( compiler, rewriter ); + plugins[ i ].object = plugins[ i ].create( Plugin::InstantiationData { plugins[ i ].optionName, *this, compiler, &rewriter } ); return; } } @@ -125,21 +132,43 @@ void PluginHandler::createPlugin( const string& name ) report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name; } -void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback ) +void PluginHandler::registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ) { assert( !pluginObjectsCreated ); assert( pluginCount < MAX_PLUGINS ); plugins[ pluginCount ].create = create; plugins[ pluginCount ].object = NULL; plugins[ pluginCount ].optionName = optionName; - plugins[ pluginCount ].isRewriter = isRewriter; plugins[ pluginCount ].isPPCallback = isPPCallback; + plugins[ pluginCount ].byDefault = byDefault; ++pluginCount; } +DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, const char* plugin, StringRef message, CompilerInstance& compiler, + SourceLocation loc ) + { + DiagnosticsEngine& diag = compiler.getDiagnostics(); + // Do some mappings (e.g. for -Werror) that clang does not do for custom messages for some reason. + if( level == DiagnosticsEngine::Warning && diag.getWarningsAsErrors() && (plugin == nullptr || plugin != warningsOnly)) + level = DiagnosticsEngine::Error; + if( level == DiagnosticsEngine::Error && diag.getErrorsAsFatal()) + level = DiagnosticsEngine::Fatal; + string fullMessage = ( message + " [loplugin" ).str(); + if( plugin ) + { + fullMessage += ":"; + fullMessage += plugin; + } + fullMessage += "]"; + if( loc.isValid()) + return diag.Report( loc, diag.getCustomDiagID( level, fullMessage )); + else + return diag.Report( diag.getCustomDiagID( level, fullMessage )); + } + DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc ) { - return Plugin::report( level, message, compiler, loc ); + return report( level, nullptr, message, compiler, loc ); } void PluginHandler::HandleTranslationUnit( ASTContext& context ) diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx index ee53a1f837c3..46c620b94847 100644 --- a/compilerplugins/clang/pluginhandler.hxx +++ b/compilerplugins/clang/pluginhandler.hxx @@ -30,7 +30,9 @@ class PluginHandler PluginHandler( CompilerInstance& compiler, const vector< string >& args ); virtual ~PluginHandler(); virtual void HandleTranslationUnit( ASTContext& context ) override; - static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback ); + 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()); private: void handleOption( const string& option ); void createPlugin( const string& name ); @@ -38,6 +40,7 @@ class PluginHandler CompilerInstance& compiler; Rewriter rewriter; string scope; + string warningsOnly; }; /** diff --git a/compilerplugins/clang/pointertobool.cxx b/compilerplugins/clang/pointertobool.cxx index 809e50b5c132..d1637cf5525c 100644 --- a/compilerplugins/clang/pointertobool.cxx +++ b/compilerplugins/clang/pointertobool.cxx @@ -41,15 +41,15 @@ class PointerToBool , public Plugin { public: - explicit PointerToBool( CompilerInstance& compiler ); + explicit PointerToBool( const InstantiationData& data ); void run(); bool VisitImplicitCastExpr( const ImplicitCastExpr* expr ); private: bool ignoreConversion( const Stmt* stmt ); }; -PointerToBool::PointerToBool( CompilerInstance& compiler ) - : Plugin( compiler ) +PointerToBool::PointerToBool( const InstantiationData& data ) + : Plugin( data ) { } diff --git a/compilerplugins/clang/postfixincrementfix.cxx b/compilerplugins/clang/postfixincrementfix.cxx index a97b4a04039f..c4ad68591817 100644 --- a/compilerplugins/clang/postfixincrementfix.cxx +++ b/compilerplugins/clang/postfixincrementfix.cxx @@ -20,8 +20,8 @@ Change all postfix ++ operators of non-trivial types to prefix if possible. namespace loplugin { -PostfixIncrementFix::PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter ) - : RewritePlugin( compiler, rewriter ) +PostfixIncrementFix::PostfixIncrementFix( const InstantiationData& data ) + : RewritePlugin( data ) { } diff --git a/compilerplugins/clang/postfixincrementfix.hxx b/compilerplugins/clang/postfixincrementfix.hxx index 27f4f154c41b..60dc93bb79f6 100644 --- a/compilerplugins/clang/postfixincrementfix.hxx +++ b/compilerplugins/clang/postfixincrementfix.hxx @@ -22,7 +22,7 @@ class PostfixIncrementFix , public RewritePlugin { public: - explicit PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter ); + explicit PostfixIncrementFix( const InstantiationData& data ); virtual void run() override; bool VisitCXXOperatorCallExpr( const CXXOperatorCallExpr* op ); private: diff --git a/compilerplugins/clang/rtlconstasciimacro.cxx b/compilerplugins/clang/rtlconstasciimacro.cxx index 0d7cc05824e3..be627f938e01 100644 --- a/compilerplugins/clang/rtlconstasciimacro.cxx +++ b/compilerplugins/clang/rtlconstasciimacro.cxx @@ -29,7 +29,7 @@ class RtlConstAsciiMacro , public RewritePlugin { public: - explicit RtlConstAsciiMacro( CompilerInstance& compiler, Rewriter& rewriter ); + explicit RtlConstAsciiMacro( const InstantiationData& data ); virtual void run() override; bool VisitCXXConstructExpr( CXXConstructExpr* expr ); bool VisitCXXTemporaryObjectExpr( CXXTemporaryObjectExpr* expr ); @@ -47,8 +47,8 @@ class RtlConstAsciiMacro bool suitableString; }; -RtlConstAsciiMacro::RtlConstAsciiMacro( CompilerInstance& compiler, Rewriter& rewriter ) - : RewritePlugin( compiler, rewriter ) +RtlConstAsciiMacro::RtlConstAsciiMacro( const InstantiationData& data ) + : RewritePlugin( data ) , searchingForString( false ) { compiler.getPreprocessor().addPPCallbacks( this ); diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index c37a2326de33..f427e6567d35 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -26,8 +26,8 @@ report if the area is not listed there. The fix is either use a proper area or a if appropriate. */ -SalLogAreas::SalLogAreas( CompilerInstance& compiler ) - : Plugin( compiler ) +SalLogAreas::SalLogAreas( const InstantiationData& data ) + : Plugin( data ) { } diff --git a/compilerplugins/clang/sallogareas.hxx b/compilerplugins/clang/sallogareas.hxx index c00897c8c8f4..d18df946a428 100644 --- a/compilerplugins/clang/sallogareas.hxx +++ b/compilerplugins/clang/sallogareas.hxx @@ -24,7 +24,7 @@ class SalLogAreas , public Plugin { public: - explicit SalLogAreas( CompilerInstance& compiler ); + explicit SalLogAreas( const InstantiationData& data ); virtual void run() override; bool VisitFunctionDecl( const FunctionDecl* function ); bool VisitCallExpr( const CallExpr* call ); diff --git a/compilerplugins/clang/svstreamoutputoperators.cxx b/compilerplugins/clang/svstreamoutputoperators.cxx index 579ca6fda5e9..442779713059 100644 --- a/compilerplugins/clang/svstreamoutputoperators.cxx +++ b/compilerplugins/clang/svstreamoutputoperators.cxx @@ -37,15 +37,15 @@ class SvStreamOutputOperators , public RewritePlugin { public: - explicit SvStreamOutputOperators( CompilerInstance& compiler, Rewriter& rewriter ); + explicit SvStreamOutputOperators( InstantiationData const & data ); virtual void run() override; bool VisitCallExpr( const CallExpr* call ); private: SourceLocation after(const SourceLocation& loc); }; -SvStreamOutputOperators::SvStreamOutputOperators( CompilerInstance& compiler, Rewriter& rewriter ) - : RewritePlugin( compiler, rewriter ) +SvStreamOutputOperators::SvStreamOutputOperators( InstantiationData const & data ) + : RewritePlugin( data ) { } diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx index cf16e6b21f12..caa16b1fe446 100644 --- a/compilerplugins/clang/unusedvariablecheck.cxx +++ b/compilerplugins/clang/unusedvariablecheck.cxx @@ -38,8 +38,8 @@ 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( CompilerInstance& compiler ) - : Plugin( compiler ) +UnusedVariableCheck::UnusedVariableCheck( const InstantiationData& data ) + : Plugin( data ) { } diff --git a/compilerplugins/clang/unusedvariablecheck.hxx b/compilerplugins/clang/unusedvariablecheck.hxx index cf0ca7dc4c12..b3e8467a709e 100644 --- a/compilerplugins/clang/unusedvariablecheck.hxx +++ b/compilerplugins/clang/unusedvariablecheck.hxx @@ -22,7 +22,7 @@ class UnusedVariableCheck , public Plugin { public: - explicit UnusedVariableCheck( CompilerInstance& compiler ); + explicit UnusedVariableCheck( const InstantiationData& data ); virtual void run() override; bool VisitVarDecl( const VarDecl* var ); }; -- cgit v1.2.3