Kaydet (Commit) 653cdcf5 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

error: cannot use dynamic_cast with -fno-rtti

...with recent Clang trunk towards 3.4

Change-Id: Ie0991c7bd560c30551aeaada426382a889b46391
üst 05944477
...@@ -49,6 +49,7 @@ class CheckConfigMacros ...@@ -49,6 +49,7 @@ class CheckConfigMacros
virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override; virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override;
#endif #endif
#endif #endif
enum { isPPCallback = true };
private: private:
void checkMacro( const Token& macroToken, SourceLocation location ); void checkMacro( const Token& macroToken, SourceLocation location );
std::set< string > configMacros; std::set< string > configMacros;
......
...@@ -62,9 +62,9 @@ bool Plugin::ignoreLocation( SourceLocation loc ) ...@@ -62,9 +62,9 @@ bool Plugin::ignoreLocation( SourceLocation loc )
return true; return true;
} }
void Plugin::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ) void Plugin::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback )
{ {
PluginHandler::registerPlugin( create, optionName, isRewriter ); PluginHandler::registerPlugin( create, optionName, isRewriter, isPPCallback );
} }
unordered_map< const Stmt*, const Stmt* > Plugin::parents; unordered_map< const Stmt*, const Stmt* > Plugin::parents;
......
...@@ -47,6 +47,7 @@ class Plugin ...@@ -47,6 +47,7 @@ class Plugin
virtual ~Plugin(); virtual ~Plugin();
virtual void run() = 0; virtual void run() = 0;
template< typename T > class Registration; template< typename T > class Registration;
enum { isPPCallback = false };
DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message,
CompilerInstance& compiler, SourceLocation loc = SourceLocation()); CompilerInstance& compiler, SourceLocation loc = SourceLocation());
...@@ -62,7 +63,7 @@ class Plugin ...@@ -62,7 +63,7 @@ class Plugin
const Stmt* parentStmt( const Stmt* stmt ); const Stmt* parentStmt( const Stmt* stmt );
Stmt* parentStmt( Stmt* stmt ); Stmt* parentStmt( Stmt* stmt );
private: private:
static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ); static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback );
template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter ); template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter );
enum { isRewriter = false }; enum { isRewriter = false };
static unordered_map< const Stmt*, const Stmt* > parents; static unordered_map< const Stmt*, const Stmt* > parents;
...@@ -186,7 +187,7 @@ template< typename T > ...@@ -186,7 +187,7 @@ template< typename T >
inline inline
Plugin::Registration< T >::Registration( const char* optionName ) Plugin::Registration< T >::Registration( const char* optionName )
{ {
registerPlugin( &T::template createHelper< T >, optionName, T::isRewriter ); registerPlugin( &T::template createHelper< T >, optionName, T::isRewriter, T::isPPCallback );
} }
} // namespace } // namespace
......
...@@ -41,6 +41,7 @@ struct PluginData ...@@ -41,6 +41,7 @@ struct PluginData
Plugin* object; Plugin* object;
const char* optionName; const char* optionName;
bool isRewriter; bool isRewriter;
bool isPPCallback;
}; };
const int MAX_PLUGINS = 100; const int MAX_PLUGINS = 100;
...@@ -79,7 +80,7 @@ PluginHandler::~PluginHandler() ...@@ -79,7 +80,7 @@ PluginHandler::~PluginHandler()
if( plugins[ i ].object != NULL ) if( plugins[ i ].object != NULL )
{ {
// PPCallbacks is owned by preprocessor object, don't delete those // PPCallbacks is owned by preprocessor object, don't delete those
if( dynamic_cast< PPCallbacks* >( plugins[ i ].object ) == NULL ) if( !plugins[ i ].isPPCallback )
delete plugins[ i ].object; delete plugins[ i ].object;
} }
} }
...@@ -123,7 +124,7 @@ void PluginHandler::createPlugin( const string& name ) ...@@ -123,7 +124,7 @@ void PluginHandler::createPlugin( const string& name )
report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name; report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name;
} }
void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ) void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback )
{ {
assert( !pluginObjectsCreated ); assert( !pluginObjectsCreated );
assert( pluginCount < MAX_PLUGINS ); assert( pluginCount < MAX_PLUGINS );
...@@ -131,6 +132,7 @@ void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewrit ...@@ -131,6 +132,7 @@ void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewrit
plugins[ pluginCount ].object = NULL; plugins[ pluginCount ].object = NULL;
plugins[ pluginCount ].optionName = optionName; plugins[ pluginCount ].optionName = optionName;
plugins[ pluginCount ].isRewriter = isRewriter; plugins[ pluginCount ].isRewriter = isRewriter;
plugins[ pluginCount ].isPPCallback = isPPCallback;
++pluginCount; ++pluginCount;
} }
......
...@@ -29,7 +29,7 @@ class PluginHandler ...@@ -29,7 +29,7 @@ class PluginHandler
PluginHandler( CompilerInstance& compiler, const vector< string >& args ); PluginHandler( CompilerInstance& compiler, const vector< string >& args );
virtual ~PluginHandler(); virtual ~PluginHandler();
virtual void HandleTranslationUnit( ASTContext& context ) override; virtual void HandleTranslationUnit( ASTContext& context ) override;
static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter ); static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter, bool isPPCallback );
private: private:
void handleOption( const string& option ); void handleOption( const string& option );
void createPlugin( const string& name ); void createPlugin( const string& name );
......
...@@ -39,6 +39,7 @@ class RtlConstAsciiMacro ...@@ -39,6 +39,7 @@ class RtlConstAsciiMacro
virtual void MacroExpands( const Token& macro, const MacroDirective* directive, virtual void MacroExpands( const Token& macro, const MacroDirective* directive,
SourceRange range, const MacroArgs* args ) override; SourceRange range, const MacroArgs* args ) override;
#endif #endif
enum { isPPCallback = true };
private: private:
map< SourceLocation, SourceLocation > expansions; // start location -> end location map< SourceLocation, SourceLocation > expansions; // start location -> end location
bool searchingForString; bool searchingForString;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment