mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1931877, part 1 - Define MOZ_DIAGNOSTIC_CRASH. r=glandium
Also use it in MOZ_ALWAYS_TRUE and fix up the comment. Differential Revision: https://phabricator.services.mozilla.com/D229360
This commit is contained in:
parent
103af1a274
commit
e239bce2c0
@ -302,6 +302,19 @@ MOZ_NoReturn(int aLine) {
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MOZ_DIAGNOSTIC_CRASH acts like MOZ_CRASH in a MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
* build, and does nothing otherwise. See the comment later in this file for a
|
||||
* description of when MOZ_DIAGNOSTIC_ASSERT_ENABLED is defined.
|
||||
*/
|
||||
#if defined(MOZ_DIAGNOSTIC_ASSERT_ENABLED)
|
||||
# define MOZ_DIAGNOSTIC_CRASH(...) MOZ_CRASH(__VA_ARGS__)
|
||||
#else
|
||||
# define MOZ_DIAGNOSTIC_CRASH(...) \
|
||||
do { /* nothing */ \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MOZ_CRASH_UNSAFE(explanation-string) can be used if the explanation string
|
||||
* cannot be a string literal (but no other processing needs to be done on it).
|
||||
@ -654,18 +667,18 @@ struct AssertionConditionType {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MOZ_ALWAYS_TRUE(expr) and friends always evaluate the provided expression,
|
||||
* in debug builds and in release builds both. Then, in debug builds and
|
||||
* Nightly and early beta builds, the value of the expression is
|
||||
* asserted either true or false using MOZ_DIAGNOSTIC_ASSERT.
|
||||
* MOZ_ALWAYS_TRUE(expr) and friends always evaluate the provided expression, in
|
||||
* both debug and release builds. Then, in debug builds and Nightly and early
|
||||
* beta builds, we crash using the string value of the expression as the message
|
||||
* using MOZ_DIAGNOSTIC_CRASH.
|
||||
*/
|
||||
#define MOZ_ALWAYS_TRUE(expr) \
|
||||
do { \
|
||||
if (MOZ_LIKELY(expr)) { \
|
||||
/* Silence [[nodiscard]]. */ \
|
||||
} else { \
|
||||
MOZ_DIAGNOSTIC_ASSERT(false, #expr); \
|
||||
} \
|
||||
#define MOZ_ALWAYS_TRUE(expr) \
|
||||
do { \
|
||||
if (MOZ_LIKELY(expr)) { \
|
||||
/* Silence [[nodiscard]]. */ \
|
||||
} else { \
|
||||
MOZ_DIAGNOSTIC_CRASH(#expr); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define MOZ_ALWAYS_FALSE(expr) MOZ_ALWAYS_TRUE(!(expr))
|
||||
|
Loading…
Reference in New Issue
Block a user