PluginManager: Don't cast from void-pointer to pointer-to-function

GCC warns on reinterpret_cast expressions involving a void-pointer
source and a pointer-to-function destination.  Take a detour through
intptr_t to silence it.

Differential Revision: http://reviews.llvm.org/D4626

llvm-svn: 213691
This commit is contained in:
David Majnemer 2014-07-22 21:59:22 +00:00
parent bcb865a8ce
commit 5ff0278b68
1 changed files with 16 additions and 2 deletions

View File

@ -79,6 +79,12 @@ SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info)
plugin_map[plugin_file_spec] = plugin_info;
}
template <typename FPtrTy>
static FPtrTy
CastToFPtr (void *VPtr)
{
return reinterpret_cast<FPtrTy>(reinterpret_cast<intptr_t>(VPtr));
}
static FileSpec::EnumerateDirectoryResult
LoadPluginCallback
@ -115,7 +121,11 @@ LoadPluginCallback
if (plugin_info.plugin_handle)
{
bool success = false;
plugin_info.plugin_init_callback = (PluginInitCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
plugin_info.plugin_init_callback =
CastToFPtr<PluginInitCallback>(
Host::DynamicLibraryGetSymbol(plugin_info.plugin_handle,
"LLDBPluginInitialize",
error));
if (plugin_info.plugin_init_callback)
{
// Call the plug-in "bool LLDBPluginInitialize(void)" function
@ -125,7 +135,11 @@ LoadPluginCallback
if (success)
{
// It is ok for the "LLDBPluginTerminate" symbol to be NULL
plugin_info.plugin_term_callback = (PluginTermCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
plugin_info.plugin_term_callback =
CastToFPtr<PluginTermCallback>(
Host::DynamicLibraryGetSymbol(
plugin_info.plugin_handle, "LLDBPluginTerminate",
error));
}
else
{