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
virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override;
#endif
#endif
enum { isPPCallback = true };
private:
void checkMacro( const Token& macroToken, SourceLocation location );
std::set< string > configMacros;
......
......@@ -62,9 +62,9 @@ bool Plugin::ignoreLocation( SourceLocation loc )
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;
......
......@@ -47,6 +47,7 @@ class Plugin
virtual ~Plugin();
virtual void run() = 0;
template< typename T > class Registration;
enum { isPPCallback = false };
DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message,
CompilerInstance& compiler, SourceLocation loc = SourceLocation());
......@@ -62,7 +63,7 @@ class Plugin
const Stmt* parentStmt( const Stmt* stmt );
Stmt* parentStmt( Stmt* stmt );
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 );
enum { isRewriter = false };
static unordered_map< const Stmt*, const Stmt* > parents;
......@@ -186,7 +187,7 @@ template< typename T >
inline
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
......
......@@ -41,6 +41,7 @@ struct PluginData
Plugin* object;
const char* optionName;
bool isRewriter;
bool isPPCallback;
};
const int MAX_PLUGINS = 100;
......@@ -79,7 +80,7 @@ PluginHandler::~PluginHandler()
if( plugins[ i ].object != NULL )
{
// 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;
}
}
......@@ -123,7 +124,7 @@ void PluginHandler::createPlugin( const string& 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( pluginCount < MAX_PLUGINS );
......@@ -131,6 +132,7 @@ void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewrit
plugins[ pluginCount ].object = NULL;
plugins[ pluginCount ].optionName = optionName;
plugins[ pluginCount ].isRewriter = isRewriter;
plugins[ pluginCount ].isPPCallback = isPPCallback;
++pluginCount;
}
......
......@@ -29,7 +29,7 @@ class PluginHandler
PluginHandler( CompilerInstance& compiler, const vector< string >& args );
virtual ~PluginHandler();
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:
void handleOption( const string& option );
void createPlugin( const string& name );
......
......@@ -39,6 +39,7 @@ class RtlConstAsciiMacro
virtual void MacroExpands( const Token& macro, const MacroDirective* directive,
SourceRange range, const MacroArgs* args ) override;
#endif
enum { isPPCallback = true };
private:
map< SourceLocation, SourceLocation > expansions; // start location -> end location
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