|
34 | 34 | #include "absl/base/attributes.h" |
35 | 35 | #include "absl/base/config.h" |
36 | 36 | #include "absl/base/optimization.h" |
| 37 | +#include "absl/base/options.h" |
37 | 38 | #include "absl/base/port.h" |
38 | 39 |
|
39 | 40 | // ABSL_ARRAYSIZE() |
@@ -120,14 +121,33 @@ ABSL_NAMESPACE_END |
120 | 121 | // |
121 | 122 | // See `ABSL_OPTION_HARDENED` in `absl/base/options.h` for more information on |
122 | 123 | // hardened mode. |
123 | | -#if ABSL_OPTION_HARDENED == 1 && defined(NDEBUG) |
| 124 | +#if (ABSL_OPTION_HARDENED == 1 || ABSL_OPTION_HARDENED == 2) && defined(NDEBUG) |
124 | 125 | #define ABSL_HARDENING_ASSERT(expr) \ |
125 | 126 | (ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \ |
126 | 127 | : [] { ABSL_INTERNAL_HARDENING_ABORT(); }()) |
127 | 128 | #else |
128 | 129 | #define ABSL_HARDENING_ASSERT(expr) ABSL_ASSERT(expr) |
129 | 130 | #endif |
130 | 131 |
|
| 132 | +// ABSL_HARDENING_ASSERT_SLOW() |
| 133 | +// |
| 134 | +// `ABSL_HARDENING_ASSERT()` is like `ABSL_HARDENING_ASSERT()`, |
| 135 | +// but specifically for assertions whose predicates are too slow |
| 136 | +// to be enabled in many applications. |
| 137 | +// |
| 138 | +// When `NDEBUG` is not defined, `ABSL_HARDENING_ASSERT_SLOW()` is identical to |
| 139 | +// `ABSL_ASSERT()`. |
| 140 | +// |
| 141 | +// See `ABSL_OPTION_HARDENED` in `absl/base/options.h` for more information on |
| 142 | +// hardened mode. |
| 143 | +#if ABSL_OPTION_HARDENED == 1 && defined(NDEBUG) |
| 144 | +#define ABSL_HARDENING_ASSERT_SLOW(expr) \ |
| 145 | + (ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \ |
| 146 | + : [] { ABSL_INTERNAL_HARDENING_ABORT(); }()) |
| 147 | +#else |
| 148 | +#define ABSL_HARDENING_ASSERT_SLOW(expr) ABSL_ASSERT(expr) |
| 149 | +#endif |
| 150 | + |
131 | 151 | #ifdef ABSL_HAVE_EXCEPTIONS |
132 | 152 | #define ABSL_INTERNAL_TRY try |
133 | 153 | #define ABSL_INTERNAL_CATCH_ANY catch (...) |
|
0 commit comments