summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/pluginhandler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/pluginhandler.cxx')
-rw-r--r--compilerplugins/clang/pluginhandler.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 540e58dcd222..4296b981f767 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -46,7 +46,9 @@ struct PluginData
Plugin* object;
const char* optionName;
bool isPPCallback;
+ bool isSharedPlugin;
bool byDefault;
+ bool disabledRun;
};
const int MAX_PLUGINS = 200;
@@ -150,9 +152,26 @@ void PluginHandler::createPlugins( std::set< std::string > rewriters )
}
for( auto r: rewriters )
report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << r;
+ // If there is a shared plugin, make it handle all plugins that it can handle.
+ for( int i = 0; i < pluginCount; ++i )
+ {
+ if( plugins[ i ].isSharedPlugin && plugins[ i ].object != nullptr )
+ {
+ Plugin* plugin = plugins[ i ].object;
+ for( int j = 0; j < pluginCount; ++j )
+ {
+ if( plugins[ j ].object != nullptr
+ && plugin->setSharedPlugin( plugins[ j ].object, plugins[ j ].optionName ))
+ {
+ plugins[ j ].disabledRun = true;
+ }
+ }
+ }
+ }
}
-void PluginHandler::registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault )
+void PluginHandler::registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName,
+ bool isPPCallback, bool isSharedPlugin, bool byDefault )
{
assert( !bPluginObjectsCreated );
assert( pluginCount < MAX_PLUGINS );
@@ -160,7 +179,9 @@ void PluginHandler::registerPlugin( Plugin* (*create)( const InstantiationData&
plugins[ pluginCount ].object = NULL;
plugins[ pluginCount ].optionName = optionName;
plugins[ pluginCount ].isPPCallback = isPPCallback;
+ plugins[ pluginCount ].isSharedPlugin = isSharedPlugin;
plugins[ pluginCount ].byDefault = byDefault;
+ plugins[ pluginCount ].disabledRun = false;
++pluginCount;
}
@@ -281,7 +302,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
for( int i = 0; i < pluginCount; ++i )
{
- if( plugins[ i ].object != NULL )
+ if( plugins[ i ].object != NULL && !plugins[ i ].disabledRun )
{
plugins[ i ].object->run();
}