Commit 68ce303d by Abseil Team Committed by Copybara-Service

Respect `NDEBUG_SANITIZER`

Often code needs to know that it's built with sanitizers.
There are two common use for such information:
1. Work around incompatibility with sanitizers
2. Use sanitizers for more aggressive bug detection

With the current `ABSL_HAVE_*_SANITIZER` we can't distinguish
this two cased, and we didn't need that before.

Now user can define `NDEBUG_SANITIZER` to ask code like this
to avoid unnecessary checks.

I am not 100% sure that `NDEBUG` is not enough.
However relying on `NDEBUG` today will relax many tests, which
runs in NDEBUG mode only. So new `NDEBUG_SANITIZER` is safer
approach.

PiperOrigin-RevId: 619268413
Change-Id: I58185cd6886593a3742b8424deccdec366c2a35a
parent e7858c73
...@@ -77,9 +77,10 @@ namespace container_internal { ...@@ -77,9 +77,10 @@ namespace container_internal {
#ifdef ABSL_BTREE_ENABLE_GENERATIONS #ifdef ABSL_BTREE_ENABLE_GENERATIONS
#error ABSL_BTREE_ENABLE_GENERATIONS cannot be directly set #error ABSL_BTREE_ENABLE_GENERATIONS cannot be directly set
#elif defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ #elif (defined(ABSL_HAVE_ADDRESS_SANITIZER) || \
defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \
defined(ABSL_HAVE_MEMORY_SANITIZER) defined(ABSL_HAVE_MEMORY_SANITIZER)) && \
!defined(NDEBUG_SANITIZER) // If defined, performance is important.
// When compiled in sanitizer mode, we add generation integers to the nodes and // When compiled in sanitizer mode, we add generation integers to the nodes and
// iterators. When iterators are used, we validate that the container has not // iterators. When iterators are used, we validate that the container has not
// been mutated since the iterator was constructed. // been mutated since the iterator was constructed.
......
...@@ -240,9 +240,10 @@ namespace container_internal { ...@@ -240,9 +240,10 @@ namespace container_internal {
#ifdef ABSL_SWISSTABLE_ENABLE_GENERATIONS #ifdef ABSL_SWISSTABLE_ENABLE_GENERATIONS
#error ABSL_SWISSTABLE_ENABLE_GENERATIONS cannot be directly set #error ABSL_SWISSTABLE_ENABLE_GENERATIONS cannot be directly set
#elif defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ #elif (defined(ABSL_HAVE_ADDRESS_SANITIZER) || \
defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \
defined(ABSL_HAVE_MEMORY_SANITIZER) defined(ABSL_HAVE_MEMORY_SANITIZER)) && \
!defined(NDEBUG_SANITIZER) // If defined, performance is important.
// When compiled in sanitizer mode, we add generation integers to the backing // When compiled in sanitizer mode, we add generation integers to the backing
// array and iterators. In the backing array, we store the generation between // array and iterators. In the backing array, we store the generation between
// the control bytes and the slots. When iterators are dereferenced, we assert // the control bytes and the slots. When iterators are dereferenced, we assert
......
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