Bug 1494671 - Make MOZ_AssertAssignmentTest() constexpr. r=froydnj
authorBotond Ballo <botond@mozilla.com>
Mon, 01 Oct 2018 19:53:06 +0000
changeset 494797 dd9071744c9f93df9891ea5ca1a203594be815d2
parent 494796 c209b19271072f5225e86bfe2f7b8b40511233e0
child 494798 8fb46c61e091b2b812ebeee76466abb520cf4f85
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1494671
milestone64.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 1494671 - Make MOZ_AssertAssignmentTest() constexpr. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D7323
mfbt/StaticAnalysisFunctions.h
--- a/mfbt/StaticAnalysisFunctions.h
+++ b/mfbt/StaticAnalysisFunctions.h
@@ -6,16 +6,19 @@
 
 #ifndef mozilla_StaticAnalysisFunctions_h
 #define mozilla_StaticAnalysisFunctions_h
 
 #ifndef __cplusplus
 #ifndef bool
 #include <stdbool.h>
 #endif
+#define MOZ_CONSTEXPR
+#else  // __cplusplus
+#define MOZ_CONSTEXPR constexpr
 #endif
 /*
  * Functions that are used as markers in Gecko code for static analysis. Their
  * purpose is to have different AST nodes generated during compile time and to
  * match them based on different checkers implemented in build/clang-plugin
  */
 
 #ifdef MOZ_CLANG_PLUGIN
@@ -32,34 +35,29 @@ template <typename T>
 static MOZ_ALWAYS_INLINE T* MOZ_KnownLive(T* ptr) { return ptr; }
 
 /**
  * Ditto, but for references.
  */
 template <typename T>
 static MOZ_ALWAYS_INLINE T& MOZ_KnownLive(T& ref) { return ref; }
 
-extern "C" {
 #endif
 
 /**
  * MOZ_AssertAssignmentTest - used in MOZ_ASSERT in order to test the possible
  * presence of assignment instead of logical comparisons.
  *
  * Example:
  * MOZ_ASSERT(retVal = true);
  */
-static MOZ_ALWAYS_INLINE bool MOZ_AssertAssignmentTest(bool exprResult) {
+static MOZ_ALWAYS_INLINE MOZ_CONSTEXPR bool MOZ_AssertAssignmentTest(bool exprResult) {
   return exprResult;
 }
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
 #define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) MOZ_AssertAssignmentTest(!!(expr))
 
 #else
 
 #define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) (!!(expr))
 #define MOZ_KnownLive(expr) (expr)
 
 #endif /* MOZ_CLANG_PLUGIN */