add FOLLY_SANITIZE macro
authorIgor Sugak <sugak@fb.com>
Thu, 30 Nov 2017 02:14:04 +0000 (18:14 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 30 Nov 2017 02:25:20 +0000 (18:25 -0800)
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
folly/Portability.h

index cba31683dff3251e41bf949fe397a412befee199..3b362d2a885b96781ea4a7bbf000574694cb3387 100644 (file)
 # define FOLLY_SANITIZE_THREAD 1
 #endif
 
 # 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.
 /**
  * ASAN/MSAN/TSAN define pre-processor symbols:
  * ADDRESS_SANITIZER/MEMORY_SANITIZER/THREAD_SANITIZER.
index 15f393e0be911d2f8eacb252ddc1bad9a362f07b..6c140379de9e9920755e3eb70cb615c6bd8acb88 100644 (file)
@@ -199,6 +199,12 @@ constexpr bool kIsSanitizeThread = true;
 #else
 constexpr bool kIsSanitizeThread = false;
 #endif
 #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
 } // namespace folly
 
 // packing is very ugly in msvc