-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Clean up sanitizer macros #98402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Clean up sanitizer macros #98402
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-libc Author: Fangrui Song (MaskRay) Changeshttps://reviews.llvm.org/D99598 introduced some unneeded macros
To fix this issue, just remove unneeded macros. Full diff: https://github.com/llvm/llvm-project/pull/98402.diff 1 Files Affected:
diff --git a/libc/src/__support/macros/sanitizer.h b/libc/src/__support/macros/sanitizer.h
index baf44f7996cab..def272037f42e 100644
--- a/libc/src/__support/macros/sanitizer.h
+++ b/libc/src/__support/macros/sanitizer.h
@@ -11,43 +11,11 @@
#include "src/__support/macros/config.h" //LIBC_HAS_FEATURE
-//-----------------------------------------------------------------------------
-// Properties to check the presence or absence or sanitizers
-//-----------------------------------------------------------------------------
-
-// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of
-// a compiler instrumentation module and a run-time library. The
-// MEMORY_SANITIZER macro is deprecated but we will continue to honor it for
-// now.
-#ifdef LIBC_HAVE_MEMORY_SANITIZER
-#error "LIBC_HAVE_MEMORY_SANITIZER cannot be directly set."
-#elif defined(MEMORY_SANITIZER) || defined(__SANITIZE_MEMORY__) || \
- (LIBC_HAS_FEATURE(memory_sanitizer) && !defined(__native_client__))
-#define LIBC_HAVE_MEMORY_SANITIZER
-#endif
-
-// AddressSanitizer (ASan) is a fast memory error detector. The
-// ADDRESS_SANITIZER macro is deprecated but we will continue to honor it for
-// now.
-#ifdef LIBC_HAVE_ADDRESS_SANITIZER
-#error "LIBC_HAVE_ADDRESS_SANITIZER cannot be directly set."
-#elif defined(ADDRESS_SANITIZER) || defined(__SANITIZE_ADDRESS__) || \
- LIBC_HAS_FEATURE(address_sanitizer)
-#define LIBC_HAVE_ADDRESS_SANITIZER
-#endif
-
-// HWAddressSanitizer (HWASan) is a fast, low memory overhead error detector.
-#ifdef LIBC_HAVE_HWADDRESS_SANITIZER
-#error "LIBC_HAVE_HWADDRESS_SANITIZER cannot be directly set."
-#elif LIBC_HAS_FEATURE(hwaddress_sanitizer)
-#define LIBC_HAVE_HWADDRESS_SANITIZER
-#endif
-
//-----------------------------------------------------------------------------
// Functions to unpoison memory
//-----------------------------------------------------------------------------
-#if defined(LIBC_HAVE_MEMORY_SANITIZER)
+#if LIBC_HAS_FEATURE(memory_sanitizer)
// Only perform MSAN unpoison in non-constexpr context.
#include <sanitizer/msan_interface.h>
#define MSAN_UNPOISON(addr, size) \
@@ -59,7 +27,7 @@
#define MSAN_UNPOISON(ptr, size)
#endif
-#ifdef LIBC_HAVE_ADDRESS_SANITIZER
+#if LIBC_HAS_FEATURE(address_sanitizer)
#include <sanitizer/asan_interface.h>
#define ASAN_POISON_MEMORY_REGION(addr, size) \
__asan_poison_memory_region((addr), (size))
|
https://reviews.llvm.org/D99598 introduced some unneeded macros including `ADDRESS_SANITIZER` and `MEMORY_SANITIZER`. The definitions appeared to be from older absl/base/internal/dynamic_annotations.h, which has then been cleaned up. `ADDRESS_SANITIZER` is not defined by compilers. Some Bazel users define it as part of --config=asan. If a translation unit specifies -fno-sanitize=address, libc/src/__support/macros/sanitizer.h and sanitizer/asan_interface.h will define ASAN_POISON_MEMORY_REGION differently, leading to ``` libc/src/__support/macros/sanitizer.h:66:9: error: 'ASAN_UNPOISON_MEMORY_REGION' macro redefined [-Werror,-Wmacro-redefined] 66 | #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ | ^ ``` To fix this issue, just remove unneeded macros. Pull Request: llvm#98402
https://reviews.llvm.org/D99598 introduced some unneeded macros
including
ADDRESS_SANITIZER
andMEMORY_SANITIZER
. The definitionsappeared to be from older absl/base/internal/dynamic_annotations.h,
which has then been cleaned up.
ADDRESS_SANITIZER
is not defined by compilers. Some Bazel users defineit as part of --config=asan. If a translation unit specifies
-fno-sanitize=address, libc/src/__support/macros/sanitizer.h and
sanitizer/asan_interface.h will define ASAN_POISON_MEMORY_REGION
differently, leading to
To fix this issue, just remove unneeded macros.