[Lldb-commits] [lldb] r213691 - PluginManager: Don't cast from void-pointer to pointer-to-function
David Majnemer
david.majnemer at gmail.com
Tue Jul 22 14:59:22 PDT 2014
Author: majnemer
Date: Tue Jul 22 16:59:22 2014
New Revision: 213691
URL: http://llvm.org/viewvc/llvm-project?rev=213691&view=rev
Log:
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
Modified:
lldb/trunk/source/Core/PluginManager.cpp
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=213691&r1=213690&r2=213691&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Tue Jul 22 16:59:22 2014
@@ -79,6 +79,12 @@ SetPluginInfo (const FileSpec &plugin_fi
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
{
More information about the lldb-commits
mailing list