From 5ff0278b6806ecaa1073d464460db64212bffb8f Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 22 Jul 2014 21:59:22 +0000 Subject: [PATCH] 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 --- lldb/source/Core/PluginManager.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 2c29c6566389..5bbdbcdf615c 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -79,6 +79,12 @@ SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info) plugin_map[plugin_file_spec] = plugin_info; } +template +static FPtrTy +CastToFPtr (void *VPtr) +{ + return reinterpret_cast(reinterpret_cast(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( + 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( + Host::DynamicLibraryGetSymbol( + plugin_info.plugin_handle, "LLDBPluginTerminate", + error)); } else {