From 725a5c11a8ef531470ec55a296bcbb831efdecbd Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Thu, 3 Mar 2022 07:12:11 -0800 Subject: [PATCH] Extend `config.h` to support HWSan and LSan The constexpr functions can be used to ensure that all branches actually compile (unlike plain preprocessor `#ifdef`s). PiperOrigin-RevId: 432186834 Change-Id: I1a8d97dac8480fe9d4543b0e9e39540ca1efc8fa --- sandboxed_api/config.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sandboxed_api/config.h b/sandboxed_api/config.h index 0e255cd..3c0e042 100644 --- a/sandboxed_api/config.h +++ b/sandboxed_api/config.h @@ -150,8 +150,26 @@ constexpr bool IsASan() { #endif } +constexpr bool IsHwASan() { +#ifdef ABSL_HAVE_HWADDRESS_SANITIZER + return true; +#else + return false; +#endif +} + +constexpr bool IsLSan() { +#ifdef ABSL_HAVE_LEAK_SANITIZER + return true; +#else + return false; +#endif +} + // Returns whether any of the sanitizers is enabled. -constexpr bool IsAny() { return IsMSan() || IsTSan() || IsASan(); } +constexpr bool IsAny() { + return IsMSan() || IsTSan() || IsASan() || IsHwASan() || IsLSan(); +} } // namespace sanitizers