From 614eb71734a284e1a9fefabcc48743a3c8efd653 Mon Sep 17 00:00:00 2001 From: Igor Sugak Date: Wed, 29 Nov 2017 18:14:04 -0800 Subject: [PATCH] add FOLLY_SANITIZE macro Summary: Most of the time we want to guard some code when any of the sanitizers are enabled not just one. Reviewed By: yfeldblum Differential Revision: D6429720 fbshipit-source-id: 7157a0a13f2b2acabd36a19c61b9fdbf38ba96b8 --- folly/CPortability.h | 9 +++++++++ folly/Portability.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/folly/CPortability.h b/folly/CPortability.h index cba31683..3b362d2a 100644 --- a/folly/CPortability.h +++ b/folly/CPortability.h @@ -93,6 +93,15 @@ # define FOLLY_SANITIZE_THREAD 1 #endif +/** + * Define a convenience macro to test when ASAN, UBSAN or TSAN sanitizer are + * being used + */ +#if defined(FOLLY_SANITIZE_ADDRESS) || defined(FOLLY_SANITIZE_THREAD) || \ + defined(UNDEFINED_SANITIZER) +#define FOLLY_SANITIZE 1 +#endif + /** * ASAN/MSAN/TSAN define pre-processor symbols: * ADDRESS_SANITIZER/MEMORY_SANITIZER/THREAD_SANITIZER. diff --git a/folly/Portability.h b/folly/Portability.h index 15f393e0..6c140379 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -199,6 +199,12 @@ constexpr bool kIsSanitizeThread = true; #else constexpr bool kIsSanitizeThread = false; #endif + +#if FOLLY_SANITIZE +constexpr bool kIsSanitize = true; +#else +constexpr bool kIsSanitize = false; +#endif } // namespace folly // packing is very ugly in msvc -- 2.34.1