diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-02-15 15:25:03 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-02-17 17:55:16 +0100 |
commit | 6f69fb5d7d7f66d17b56eca5a5b3f494c597b97a (patch) | |
tree | 6d0ca11b223bc543535fd7d19760d69e70b97c0b /compilerplugins/clang | |
parent | be0177fe422f283e4ab87acd4d6d092366b25bc3 (diff) |
Run the non-rewriter plugins even when rewriters are specified
Change-Id: I8262091c52522c54f84c0fac5fd180871d4a3a9f
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/pluginhandler.cxx | 33 | ||||
-rw-r--r-- | compilerplugins/clang/pluginhandler.hxx | 2 |
2 files changed, 11 insertions, 24 deletions
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index 345363b0a90f..d6595a3d502d 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -56,7 +56,7 @@ PluginHandler::PluginHandler( CompilerInstance& compiler, const vector< string > , rewriter( compiler.getSourceManager(), compiler.getLangOpts()) , scope( "mainfile" ) { - bool wasPlugin = false; + set< string > rewriters; for( vector< string >::const_iterator it = args.begin(); it != args.end(); ++it ) @@ -64,13 +64,9 @@ PluginHandler::PluginHandler( CompilerInstance& compiler, const vector< string > if( it->size() >= 2 && (*it)[ 0 ] == '-' && (*it)[ 1 ] == '-' ) handleOption( it->substr( 2 )); else - { - createPlugin( *it ); - wasPlugin = true; - } + rewriters.insert( *it ); } - if( !wasPlugin ) - createPlugin( "" ); // = all non-rewriters + createPlugins( rewriters ); pluginObjectsCreated = true; } @@ -109,28 +105,19 @@ void PluginHandler::handleOption( const string& option ) report( DiagnosticsEngine::Fatal, "unknown option %0" ) << option; } -void PluginHandler::createPlugin( const string& name ) +void PluginHandler::createPlugins( set< string > rewriters ) { for( int i = 0; i < pluginCount; ++i ) { - // 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 ].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( Plugin::InstantiationData { plugins[ i ].optionName, *this, compiler, &rewriter } ); - return; - } + if( rewriters.erase( plugins[i].optionName ) != 0 ) + plugins[ i ].object = plugins[ i ].create( Plugin::InstantiationData { plugins[ i ].optionName, *this, compiler, &rewriter } ); + else if( plugins[ i ].byDefault ) + plugins[ i ].object = plugins[ i ].create( Plugin::InstantiationData { plugins[ i ].optionName, *this, compiler, NULL } ); } - if( !name.empty()) - report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name; + for( auto r: rewriters ) + report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << r; } void PluginHandler::registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ) diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx index 46c620b94847..dcfac71abdee 100644 --- a/compilerplugins/clang/pluginhandler.hxx +++ b/compilerplugins/clang/pluginhandler.hxx @@ -35,7 +35,7 @@ class PluginHandler CompilerInstance& compiler, SourceLocation loc = SourceLocation()); private: void handleOption( const string& option ); - void createPlugin( const string& name ); + void createPlugins( set< string > rewriters ); DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); CompilerInstance& compiler; Rewriter rewriter; |