Bug 1064451 - Convert assertion-expression-type checking code to not perform a function call. r=froydnj
authorJeff Walden <jwalden@mit.edu>
Sun, 07 Sep 2014 01:04:09 -0700
changeset 204228 ff274222817c440de94e851d1c154e91e98722e7
parent 204227 792b0721903ec0ec0b61175cd1dc7624c50fc135
child 204229 d9089681f200dd97235b9bd4e85c1146f2825e2c
push id27452
push usercbook@mozilla.com
push dateTue, 09 Sep 2014 13:57:12 +0000
treeherdermozilla-central@2eaf94a4f837 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1064451
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1064451 - Convert assertion-expression-type checking code to not perform a function call. r=froydnj
mfbt/Assertions.h
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -327,37 +327,40 @@ struct IsFunction
 
 template<typename R, typename... A>
 struct IsFunction<R(A...)>
 {
   static const bool value = true;
 };
 
 template<typename T>
-void ValidateAssertConditionType()
+struct AssertionConditionType
 {
   typedef typename RemoveReference<T>::Type ValueT;
   static_assert(!IsArray<ValueT>::value,
                 "Expected boolean assertion condition, got an array or a "
                 "string!");
   static_assert(!IsFunction<ValueT>::value,
                 "Expected boolean assertion condition, got a function! Did "
                 "you intend to call that function?");
   static_assert(!IsFloatingPoint<ValueT>::value,
                 "It's often a bad idea to assert that a floating-point number "
                 "is nonzero, because such assertions tend to intermittently "
                 "fail. Shouldn't your code gracefully handle this case instead "
                 "of asserting? Anyway, if you really want to do that, write an "
                 "explicit boolean condition, like !!x or x!=0.");
-}
+
+  static const bool isValid = true;
+};
 
 } // namespace detail
 } // namespace mozilla
 #  define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) \
-     mozilla::detail::ValidateAssertConditionType<decltype(x)>()
+     static_assert(mozilla::detail::AssertionConditionType<decltype(x)>::isValid, \
+                   "invalid assertion condition")
 #else
 #  define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x)
 #endif
 
 /* First the single-argument form. */
 #define MOZ_ASSERT_HELPER1(expr) \
   do { \
     MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \