Bug 1365460 - Define MOZ_DIAGNOSTIC_ASSERT_ENABLED when MOZ_DIAGNOSTIC_ASSERT does something. r?froydnj draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 18 May 2017 11:14:17 +0900
changeset 580760 a254c463bbd323387a3450c6f1f86306d9f120fb
parent 580759 46384aaa0e54ca91c08756375c0ca3a93a19e279
child 580761 b0b79cdcdc362151e253b8a72d82352307419fa7
push id59654
push userbmo:mh+mozilla@glandium.org
push dateThu, 18 May 2017 22:44:22 +0000
reviewersfroydnj
bugs1365460
milestone55.0a1
Bug 1365460 - Define MOZ_DIAGNOSTIC_ASSERT_ENABLED when MOZ_DIAGNOSTIC_ASSERT does something. r?froydnj
mfbt/Assertions.h
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -359,16 +359,19 @@ MOZ_END_EXTERN_C
  * MOZ_RELEASE_ASSERT, which applies to non-debug builds as well.
  *
  * MOZ_DIAGNOSTIC_ASSERT works like MOZ_RELEASE_ASSERT in Nightly/Aurora and
  * MOZ_ASSERT in Beta/Release - use this when a condition is potentially rare
  * enough to require real user testing to hit, but is not security-sensitive.
  * This can cause user pain, so use it sparingly. If a MOZ_DIAGNOSTIC_ASSERT
  * is firing, it should promptly be converted to a MOZ_ASSERT while the failure
  * is being investigated, rather than letting users suffer.
+ *
+ * MOZ_DIAGNOSTIC_ASSERT_ENABLED is defined when MOZ_DIAGNOSTIC_ASSERT is like
+ * MOZ_RELEASE_ASSERT rather than MOZ_ASSERT.
  */
 
 /*
  * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against
  * accidentally passing something unintended in lieu of an assertion condition.
  */
 
 #ifdef __cplusplus
@@ -441,18 +444,22 @@ struct AssertionConditionType
 #ifdef DEBUG
 #  define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__)
 #else
 #  define MOZ_ASSERT(...) do { } while (0)
 #endif /* DEBUG */
 
 #ifdef RELEASE_OR_BETA
 #  define MOZ_DIAGNOSTIC_ASSERT MOZ_ASSERT
+#  ifdef DEBUG
+#    define MOZ_DIAGNOSTIC_ASSERT_ENABLED 1
+#  endif
 #else
 #  define MOZ_DIAGNOSTIC_ASSERT MOZ_RELEASE_ASSERT
+#  define MOZ_DIAGNOSTIC_ASSERT_ENABLED 1
 #endif
 
 /*
  * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is
  * true.
  *
  *   MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num));
  *