Commit 4ea1b5a3 authored by Andrew Gallagher's avatar Andrew Gallagher Committed by Facebook GitHub Bot

Fix some `-Wundef` warnings for `FOLLY_SANITIZE`

Summary:
In the vast majority of cases in fbcode, the sanitizer macros are checked with
`#ifdef`, so do the same in some places to fix `-Wundef`.

Reviewed By: luciang

Differential Revision: D32501662

fbshipit-source-id: 123e22d78476c9db0e328ccb01a734a06a163594
parent 3c362348
......@@ -72,7 +72,7 @@
* folly itself was compiled with ASAN enabled.
*/
#ifndef FOLLY_SANITIZE_ADDRESS
#if FOLLY_HAS_FEATURE(address_sanitizer) || __SANITIZE_ADDRESS__
#if FOLLY_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
#define FOLLY_SANITIZE_ADDRESS 1
#endif
#endif
......@@ -144,7 +144,7 @@
#endif
#endif
#if FOLLY_SANITIZE
#ifdef FOLLY_SANITIZE
#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...) \
__attribute__((no_sanitize(__VA_ARGS__)))
#else
......
......@@ -137,7 +137,7 @@ constexpr bool kIsLibrarySanitizeAddress = true;
constexpr bool kIsLibrarySanitizeAddress = false;
#endif
#if FOLLY_SANITIZE_ADDRESS
#ifdef FOLLY_SANITIZE_ADDRESS
constexpr bool kIsSanitizeAddress = true;
#else
constexpr bool kIsSanitizeAddress = false;
......@@ -149,7 +149,7 @@ constexpr bool kIsSanitizeThread = true;
constexpr bool kIsSanitizeThread = false;
#endif
#if FOLLY_SANITIZE
#ifdef FOLLY_SANITIZE
constexpr bool kIsSanitize = true;
#else
constexpr bool kIsSanitize = false;
......
......@@ -28,7 +28,8 @@
* them so that we don't have to include jemalloc.h, in case the program is
* built without jemalloc support.
*/
#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && !FOLLY_SANITIZE
#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && \
!defined(FOLLY_SANITIZE)
// We have JEMalloc, so use it.
#else
#ifndef MALLOCX_LG_ALIGN
......@@ -67,11 +68,11 @@ namespace folly {
/**
* Determine if we are using jemalloc or not.
*/
#if defined(FOLLY_ASSUME_NO_JEMALLOC) || FOLLY_SANITIZE
#if defined(FOLLY_ASSUME_NO_JEMALLOC) || defined(FOLLY_SANITIZE)
inline bool usingJEMalloc() noexcept {
return false;
}
#elif defined(USE_JEMALLOC) && !FOLLY_SANITIZE
#elif defined(USE_JEMALLOC) && !defined(FOLLY_SANITIZE)
inline bool usingJEMalloc() noexcept {
return true;
}
......@@ -136,11 +137,11 @@ inline bool getTCMallocNumericProperty(const char* name, size_t* out) noexcept {
return MallocExtension_Internal_GetNumericProperty(name, strlen(name), out);
}
#if defined(FOLLY_ASSUME_NO_TCMALLOC) || FOLLY_SANITIZE
#if defined(FOLLY_ASSUME_NO_TCMALLOC) || defined(FOLLY_SANITIZE)
inline bool usingTCMalloc() noexcept {
return false;
}
#elif defined(USE_TCMALLOC) && !FOLLY_SANITIZE
#elif defined(USE_TCMALLOC) && !defined(FOLLY_SANITIZE)
inline bool usingTCMalloc() noexcept {
return true;
}
......
......@@ -21,7 +21,7 @@
#include <folly/CPortability.h>
#include <folly/portability/Config.h>
#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE
#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !defined(FOLLY_SANITIZE)
#if defined(FOLLY_ASSUME_NO_JEMALLOC)
#error \
"Both USE_JEMALLOC/FOLLY_USE_JEMALLOC and FOLLY_ASSUME_NO_JEMALLOC defined"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment