[PATCH] D22758: [compiler-rt] Fix warnings in interception code
Etienne Bergeron via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 11:48:12 PDT 2016
etienneb updated this revision to Diff 65394.
etienneb added a comment.
fix ifdef
https://reviews.llvm.org/D22758
Files:
lib/asan/asan_interceptors.cc
lib/asan/tests/asan_str_test.cc
lib/interception/interception.h
lib/sanitizer_common/sanitizer_common_interceptors.inc
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -663,12 +663,16 @@
return internal_memchr(s, c, n);
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, memchr, s, c, n);
+#if SANITIZER_WINDOWS
void *res;
if (REAL(memchr)) {
res = REAL(memchr)(s, c, n);
} else {
res = internal_memchr(s, c, n);
}
+#else
+ void *res = REAL(memchr)(s, c, n);
+#endif
uptr len = res ? (char *)res - (const char *)s + 1 : n;
COMMON_INTERCEPTOR_READ_RANGE(ctx, s, len);
return res;
Index: lib/interception/interception.h
===================================================================
--- lib/interception/interception.h
+++ lib/interception/interception.h
@@ -158,10 +158,12 @@
namespace __interception { \
extern FUNC_TYPE(func) PTR_TO_REAL(func); \
}
+# define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src)
#else // __APPLE__
# define REAL(x) x
# define DECLARE_REAL(ret_type, func, ...) \
extern "C" ret_type func(__VA_ARGS__);
+# define ASSIGN_REAL(x, y)
#endif // __APPLE__
#define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \
Index: lib/asan/tests/asan_str_test.cc
===================================================================
--- lib/asan/tests/asan_str_test.cc
+++ lib/asan/tests/asan_str_test.cc
@@ -457,12 +457,14 @@
#if !defined(__APPLE__) || !defined(MAC_OS_X_VERSION_10_7) || \
(MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7)
// Check "memcpy". Use Ident() to avoid inlining.
+#if PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE
memset(str, 'z', size);
Ident(memcpy)(str + 1, str + 11, 10);
Ident(memcpy)(str, str, 0);
EXPECT_DEATH(Ident(memcpy)(str, str + 14, 15), OverlapErrorMessage("memcpy"));
EXPECT_DEATH(Ident(memcpy)(str + 14, str, 15), OverlapErrorMessage("memcpy"));
#endif
+#endif
// We do not treat memcpy with to==from as a bug.
// See http://llvm.org/bugs/show_bug.cgi?id=11763.
Index: lib/asan/asan_interceptors.cc
===================================================================
--- lib/asan/asan_interceptors.cc
+++ lib/asan/asan_interceptors.cc
@@ -725,11 +725,13 @@
InitializeCommonInterceptors();
// Intercept mem* functions.
- ASAN_INTERCEPT_FUNC(memcpy);
+ ASAN_INTERCEPT_FUNC(memmove);
ASAN_INTERCEPT_FUNC(memset);
if (PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE) {
// In asan, REAL(memmove) is not used, but it is used in msan.
- ASAN_INTERCEPT_FUNC(memmove);
+ ASAN_INTERCEPT_FUNC(memcpy);
+ } else {
+ ASSIGN_REAL(memcpy, memmove);
}
CHECK(REAL(memcpy));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22758.65394.patch
Type: text/x-patch
Size: 2728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160725/955a702a/attachment.bin>
More information about the llvm-commits
mailing list