diff options
Diffstat (limited to 'compilerplugins/clang/plugin.hxx')
-rw-r--r-- | compilerplugins/clang/plugin.hxx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx index 4aab4beb4b8d..19908d8257e5 100644 --- a/compilerplugins/clang/plugin.hxx +++ b/compilerplugins/clang/plugin.hxx @@ -51,11 +51,20 @@ class Plugin public: explicit Plugin( const InstantiationData& data ); virtual ~Plugin() {} + // The main function of the plugin. + // Note that for shared plugins, its functionality must be split into preRun() and postRun(), + // see sharedvisitor/generator.cxx . virtual void run() = 0; + // Should be called from run() before TraverseDecl(). + // If returns false, run() should not do anything. + virtual bool preRun() { return true; } + virtual void postRun() {} template< typename T > class Registration; - enum { isPPCallback = false }; // Returns location right after the end of the token that starts at the given location. SourceLocation locationAfterToken( SourceLocation location ); + virtual bool setSharedPlugin( Plugin* /*plugin*/, const char* /*name*/ ) { return false; } + enum { isPPCallback = false }; + enum { isSharedPlugin = false }; protected: DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()) const; bool ignoreLocation( SourceLocation loc ) const @@ -92,7 +101,8 @@ protected: Expr const * argument1, Expr const * argument2); private: - static void registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ); + static void registerPlugin( Plugin* (*create)( const InstantiationData& ), const char* optionName, + bool isPPCallback, bool isSharedPlugin, bool byDefault ); template< typename T > static Plugin* createHelper( const InstantiationData& data ); bool evaluate(const Expr* expr, APSInt& x); @@ -220,7 +230,7 @@ template< typename T > inline Plugin::Registration< T >::Registration( const char* optionName, bool byDefault ) { - registerPlugin( &T::template createHelper< T >, optionName, T::isPPCallback, byDefault ); + registerPlugin( &T::template createHelper< T >, optionName, T::isPPCallback, T::isSharedPlugin, byDefault ); } inline |