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
This commit is contained in:
Christian Blichmann 2022-03-03 07:12:11 -08:00 committed by Copybara-Service
parent 077203fcf2
commit 725a5c11a8

View File

@ -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