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 @@ ...@@ -72,7 +72,7 @@
* folly itself was compiled with ASAN enabled. * folly itself was compiled with ASAN enabled.
*/ */
#ifndef FOLLY_SANITIZE_ADDRESS #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 #define FOLLY_SANITIZE_ADDRESS 1
#endif #endif
#endif #endif
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
#endif #endif
#endif #endif
#if FOLLY_SANITIZE #ifdef FOLLY_SANITIZE
#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...) \ #define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...) \
__attribute__((no_sanitize(__VA_ARGS__))) __attribute__((no_sanitize(__VA_ARGS__)))
#else #else
......
...@@ -137,7 +137,7 @@ constexpr bool kIsLibrarySanitizeAddress = true; ...@@ -137,7 +137,7 @@ constexpr bool kIsLibrarySanitizeAddress = true;
constexpr bool kIsLibrarySanitizeAddress = false; constexpr bool kIsLibrarySanitizeAddress = false;
#endif #endif
#if FOLLY_SANITIZE_ADDRESS #ifdef FOLLY_SANITIZE_ADDRESS
constexpr bool kIsSanitizeAddress = true; constexpr bool kIsSanitizeAddress = true;
#else #else
constexpr bool kIsSanitizeAddress = false; constexpr bool kIsSanitizeAddress = false;
...@@ -149,7 +149,7 @@ constexpr bool kIsSanitizeThread = true; ...@@ -149,7 +149,7 @@ constexpr bool kIsSanitizeThread = true;
constexpr bool kIsSanitizeThread = false; constexpr bool kIsSanitizeThread = false;
#endif #endif
#if FOLLY_SANITIZE #ifdef FOLLY_SANITIZE
constexpr bool kIsSanitize = true; constexpr bool kIsSanitize = true;
#else #else
constexpr bool kIsSanitize = false; constexpr bool kIsSanitize = false;
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
* them so that we don't have to include jemalloc.h, in case the program is * them so that we don't have to include jemalloc.h, in case the program is
* built without jemalloc support. * 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. // We have JEMalloc, so use it.
#else #else
#ifndef MALLOCX_LG_ALIGN #ifndef MALLOCX_LG_ALIGN
...@@ -67,11 +68,11 @@ namespace folly { ...@@ -67,11 +68,11 @@ namespace folly {
/** /**
* Determine if we are using jemalloc or not. * 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 { inline bool usingJEMalloc() noexcept {
return false; return false;
} }
#elif defined(USE_JEMALLOC) && !FOLLY_SANITIZE #elif defined(USE_JEMALLOC) && !defined(FOLLY_SANITIZE)
inline bool usingJEMalloc() noexcept { inline bool usingJEMalloc() noexcept {
return true; return true;
} }
...@@ -136,11 +137,11 @@ inline bool getTCMallocNumericProperty(const char* name, size_t* out) noexcept { ...@@ -136,11 +137,11 @@ inline bool getTCMallocNumericProperty(const char* name, size_t* out) noexcept {
return MallocExtension_Internal_GetNumericProperty(name, strlen(name), out); 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 { inline bool usingTCMalloc() noexcept {
return false; return false;
} }
#elif defined(USE_TCMALLOC) && !FOLLY_SANITIZE #elif defined(USE_TCMALLOC) && !defined(FOLLY_SANITIZE)
inline bool usingTCMalloc() noexcept { inline bool usingTCMalloc() noexcept {
return true; return true;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/CPortability.h> #include <folly/CPortability.h>
#include <folly/portability/Config.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) #if defined(FOLLY_ASSUME_NO_JEMALLOC)
#error \ #error \
"Both USE_JEMALLOC/FOLLY_USE_JEMALLOC and FOLLY_ASSUME_NO_JEMALLOC defined" "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