compilerplugins/clang/pluginhandler.cxx | 11 ++++++----- compilerplugins/clang/pluginhandler.hxx | 1 + 2 files changed, 7 insertions(+), 5 deletions(-)
New commits: commit 15dce20e8b97dbd0179f01910ca4d0027e80ff4e Author: Stephan Bergmann <[email protected]> Date: Thu Oct 19 21:33:08 2017 +0200 Fully ignore inappropriately named loplugins in unit-test mode ...even if they implement PPCallbacks, so filtering them out in HandleTranslationUnit was ineffective. Change-Id: I9df8103a50739f3176e6d63accfd0334da7faa9a Reviewed-on: https://gerrit.libreoffice.org/43575 Reviewed-by: Stephan Bergmann <[email protected]> Tested-by: Stephan Bergmann <[email protected]> diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index 5712f02dcc3a..d82a369cb119 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -55,6 +55,7 @@ static bool unitTestMode = false; PluginHandler::PluginHandler( CompilerInstance& compiler, const std::vector< std::string >& args ) : compiler( compiler ) + , mainFileName(compiler.getASTContext().getSourceManager().getFileEntryForID(compiler.getASTContext().getSourceManager().getMainFileID())->getName()) , rewriter( compiler.getSourceManager(), compiler.getLangOpts()) , scope( "mainfile" ) , warningsAsErrors( false ) @@ -120,6 +121,10 @@ void PluginHandler::createPlugins( std::set< std::string > rewriters ) for( int i = 0; i < pluginCount; ++i ) { const char* name = plugins[i].optionName; + // When in unit-test mode, ignore plugins whose names don't match the filename of the test, + // so that we only generate warnings for the plugin that we want to test. + if (unitTestMode && mainFileName.find(plugins[ i ].optionName) == StringRef::npos) + continue; if( rewriters.erase( name ) != 0 ) plugins[ i ].object = plugins[ i ].create( Plugin::InstantiationData { name, *this, compiler, &rewriter } ); else if( plugins[ i ].byDefault ) @@ -179,7 +184,6 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) { if( context.getDiagnostics().hasErrorOccurred()) return; - StringRef const mainFileName = context.getSourceManager().getFileEntryForID(context.getSourceManager().getMainFileID())->getName(); if (mainFileName.endswith(".ii")) { report(DiagnosticsEngine::Fatal, @@ -191,10 +195,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) { if( plugins[ i ].object != NULL ) { - // When in unit-test mode, ignore plugins whose names don't match the filename of the test, - // so that we only generate warnings for the plugin that we want to test. - if (!unitTestMode || mainFileName.find(plugins[ i ].optionName) != StringRef::npos) - plugins[ i ].object->run(); + plugins[ i ].object->run(); } } #if defined _WIN32 diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx index 9c3d0a49c839..63210fa11df4 100644 --- a/compilerplugins/clang/pluginhandler.hxx +++ b/compilerplugins/clang/pluginhandler.hxx @@ -43,6 +43,7 @@ private: void createPlugins( std::set< std::string > rewriters ); DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); CompilerInstance& compiler; + StringRef const mainFileName; Rewriter rewriter; std::set< SourceLocation > removals; std::string scope; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
