Bug 1329520 - Switch MOZ_NORETURN to C++11-style attribute for compatibility with libc++ 4.0. r?froydnj draft
authorJan Beich <jbeich@FreeBSD.org>
Tue, 10 Jan 2017 02:00:46 +0000
changeset 457882 960ea16159af
parent 457880 845cc4dea57f
child 541613 fbb6da867aa5
push id40919
push userbmo:jbeich@FreeBSD.org
push dateTue, 10 Jan 2017 02:45:10 +0000
reviewersfroydnj
bugs1329520
milestone53.0a1
Bug 1329520 - Switch MOZ_NORETURN to C++11-style attribute for compatibility with libc++ 4.0. r?froydnj MozReview-Commit-ID: JMnYGykZVGg
js/public/Utility.h
memory/mozalloc/mozalloc_abort.h
memory/mozalloc/throw_gcc.h
mfbt/Attributes.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -33,17 +33,17 @@ namespace JS {}
 namespace mozilla {}
 
 /* The private JS engine namespace. */
 namespace js {}
 
 #define JS_STATIC_ASSERT(cond)           static_assert(cond, "JS_STATIC_ASSERT")
 #define JS_STATIC_ASSERT_IF(cond, expr)  MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF")
 
-extern MOZ_NORETURN MOZ_COLD JS_PUBLIC_API(void)
+MOZ_NORETURN MOZ_COLD extern JS_PUBLIC_API(void)
 JS_Assert(const char* s, const char* file, int ln);
 
 /*
  * Custom allocator support for SpiderMonkey
  */
 #if defined JS_USE_CUSTOM_ALLOCATOR
 # include "jscustomallocator.h"
 #else
--- a/memory/mozalloc/mozalloc_abort.h
+++ b/memory/mozalloc/mozalloc_abort.h
@@ -13,16 +13,16 @@
 
 /**
  * Terminate this process in such a way that breakpad is triggered, if
  * at all possible.
  *
  * Note: MOZ_NORETURN seems to break crash stacks on ARM, so we don't
  * use that annotation there.
  */
-MFBT_API
 #if !defined(__arm__)
   MOZ_NORETURN
 #endif
+  MFBT_API
   void mozalloc_abort(const char* const msg);
 
 
 #endif  /* ifndef mozilla_mozalloc_abort_h */
--- a/memory/mozalloc/throw_gcc.h
+++ b/memory/mozalloc/throw_gcc.h
@@ -20,108 +20,108 @@
 #include "mozilla/mozalloc_abort.h"
 
 namespace std {
 
 // NB: user code is not supposed to touch the std:: namespace.  We're
 // doing this after careful review because we want to define our own
 // exception throwing semantics.  Don't try this at home!
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_bad_exception(void)
 {
     mozalloc_abort("fatal: STL threw bad_exception");
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_bad_alloc(void)
 {
     mozalloc_abort("fatal: STL threw bad_alloc");
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_bad_cast(void)
 {
     mozalloc_abort("fatal: STL threw bad_cast");
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_bad_typeid(void)
 {
     mozalloc_abort("fatal: STL threw bad_typeid");
 }
 
 // used by <functional>
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_bad_function_call(void)
 {
     mozalloc_abort("fatal: STL threw bad_function_call");
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_logic_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_domain_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_invalid_argument(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_length_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_out_of_range(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_runtime_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_range_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_overflow_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_underflow_error(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_ios_failure(const char* msg)
 {
     mozalloc_abort(msg);
 }
 
-MOZ_EXPORT MOZ_NORETURN MOZ_ALWAYS_INLINE void
+MOZ_NORETURN MOZ_ALWAYS_INLINE MOZ_EXPORT void
 __throw_system_error(int err)
 {
     char error[128];
     snprintf(error, sizeof(error)-1,
              "fatal: STL threw system_error: %s (%d)", strerror(err), err);
     mozalloc_abort(error);
 }
 
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -56,17 +56,21 @@
     */
 #  ifndef __has_extension
 #    define __has_extension __has_feature /* compatibility, for older versions of clang */
 #  endif
 #  if __has_attribute(noinline)
 #    define MOZ_HAVE_NEVER_INLINE        __attribute__((noinline))
 #  endif
 #  if __has_attribute(noreturn)
-#    define MOZ_HAVE_NORETURN            __attribute__((noreturn))
+#    if __has_feature(cxx_attributes)
+#      define MOZ_HAVE_NORETURN          [[noreturn]]
+#    else
+#      define MOZ_HAVE_NORETURN          __attribute__((noreturn))
+#    endif
 #  endif
 #elif defined(__GNUC__)
 #  define MOZ_HAVE_NEVER_INLINE          __attribute__((noinline))
 #  define MOZ_HAVE_NORETURN              __attribute__((noreturn))
 #endif
 
 /*
  * When built with clang analyzer (a.k.a scan-build), define MOZ_HAVE_NORETURN