[Sanitizer] Workaround for a compiler warning - ISO C++ forbids casting pointer-to-function to pointer-to-object, so we use cast via integral type

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161168 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/interception/interception.h b/lib/interception/interception.h
index b72bff2..d050523 100644
--- a/lib/interception/interception.h
+++ b/lib/interception/interception.h
@@ -148,6 +148,15 @@
   INTERCEPTOR_EX(ret_type, __stdcall, func, __VA_ARGS__)
 #endif
 
+// ISO C++ forbids casting between pointer-to-function and pointer-to-object,
+// so we use casting via an integral type __interception::uptr,
+// assuming that system is POSIX-compliant. Using other hacks seem
+// challenging, as we don't even pass function type to
+// INTERCEPT_FUNCTION macro, only its name.
+namespace __interception {
+typedef unsigned long uptr;  // NOLINT
+}  // namespace __interception
+
 #define INCLUDED_FROM_INTERCEPTION_LIB
 
 #if defined(__linux__)
diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
index 37e5933..009098f 100644
--- a/lib/interception/interception_linux.cc
+++ b/lib/interception/interception_linux.cc
@@ -13,14 +13,15 @@
 //===----------------------------------------------------------------------===//
 
 #ifdef __linux__
+#include "interception.h"
 
 #include <stddef.h>  // for NULL
 #include <dlfcn.h>   // for dlsym
 
 namespace __interception {
-bool GetRealFunctionAddress(const char *func_name, void **func_addr,
-    void *real, void *wrapper) {
-  *func_addr = dlsym(RTLD_NEXT, func_name);
+bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+    uptr real, uptr wrapper) {
+  *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
   return real == wrapper;
 }
 }  // namespace __interception
diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
index 76a29c6..dba60bf 100644
--- a/lib/interception/interception_linux.h
+++ b/lib/interception/interception_linux.h
@@ -23,13 +23,15 @@
 
 namespace __interception {
 // returns true if a function with the given name was found.
-bool GetRealFunctionAddress(const char *func_name, void **func_addr,
-    void *real, void *wrapper);
+bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+    uptr real, uptr wrapper);
 }  // namespace __interception
 
 #define INTERCEPT_FUNCTION_LINUX(func) \
-    ::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func), \
-    (void*)&(func), (void*)&WRAP(func))
+    ::__interception::GetRealFunctionAddress( \
+          #func, (::__interception::uptr*)&REAL(func), \
+          (::__interception::uptr)&(func), \
+          (::__interception::uptr)&WRAP(func))
 
 #endif  // INTERCEPTION_LINUX_H
 #endif  // __linux__
diff --git a/lib/interception/interception_mac.cc b/lib/interception/interception_mac.cc
index cc9e4a7..2c10a71 100644
--- a/lib/interception/interception_mac.cc
+++ b/lib/interception/interception_mac.cc
@@ -14,19 +14,17 @@
 
 #ifdef __APPLE__
 
-#define INCLUDED_FROM_INTERCEPTION_LIB
-#include "interception_mac.h"
-#undef INCLUDED_FROM_INTERCEPTION_LIB
+#include "interception.h"
 #include "mach_override/mach_override.h"
 
 namespace __interception {
-bool OverrideFunction(void *old_func, void *new_func, void **orig_old_func) {
-  *orig_old_func = NULL;
-  int res = __asan_mach_override_ptr_custom(old_func, new_func,
-                                            orig_old_func,
+bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func) {
+  *orig_old_func = 0;
+  int res = __asan_mach_override_ptr_custom((void*)old_func, (void*)new_func,
+                                            (void**)orig_old_func,
                                             __interception_allocate_island,
                                             __interception_deallocate_island);
-  return (res == 0) && (*orig_old_func != NULL);
+  return (res == 0) && (*orig_old_func != 0);
 }
 }  // namespace __interception
 
diff --git a/lib/interception/interception_mac.h b/lib/interception/interception_mac.h
index 224d961..31fd7b3 100644
--- a/lib/interception/interception_mac.h
+++ b/lib/interception/interception_mac.h
@@ -35,12 +35,14 @@
 
 namespace __interception {
 // returns true if the old function existed.
-bool OverrideFunction(void *old_func, void *new_func, void **orig_old_func);
+bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
 }  // namespace __interception
 
 # define OVERRIDE_FUNCTION_MAC(old_func, new_func) \
-    ::__interception::OverrideFunction((void*)old_func, (void*)new_func, \
-                                       (void**)&REAL(old_func))
+    ::__interception::OverrideFunction( \
+          (::__interception::uptr)old_func, \
+          (::__interception::uptr)new_func, \
+          (::__interception::uptr*)&REAL(old_func))
 # define INTERCEPT_FUNCTION_MAC(func) OVERRIDE_FUNCTION_MAC(func, WRAP(func))
 
 #endif  // INTERCEPTION_MAC_H