[cfe-commits] [libcxx] r132125 - in /libcxx/trunk: include/__config include/exception src/exception.cpp

Howard Hinnant hhinnant at apple.com
Thu May 26 10:07:32 PDT 2011


Author: hhinnant
Date: Thu May 26 12:07:32 2011
New Revision: 132125

URL: http://llvm.org/viewvc/llvm-project?rev=132125&view=rev
Log:
Added [[noreturn]] attribute everywhere it should be

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/exception
    libcxx/trunk/src/exception.cpp

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=132125&r1=132124&r2=132125&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu May 26 12:07:32 2011
@@ -116,8 +116,10 @@
 #define _LIBCPP_HAS_NO_DECLTYPE
 #endif
 
-#if !(__has_feature(cxx_attributes))
-#define _LIBCPP_HAS_NO_ATTRIBUTES
+#if __has_feature(cxx_attributes)
+#  define _ATTRIBUTE(x) [[x]]
+#else
+#  define _ATTRIBUTE(x) __attribute__ ((x))
 #endif
 
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS

Modified: libcxx/trunk/include/exception
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=132125&r1=132124&r2=132125&view=diff
==============================================================================
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Thu May 26 12:07:32 2011
@@ -105,19 +105,19 @@
 typedef void (*unexpected_handler)();
 _LIBCPP_VISIBLE unexpected_handler set_unexpected(unexpected_handler) throw();
 _LIBCPP_VISIBLE unexpected_handler get_unexpected() throw();
-_LIBCPP_VISIBLE void unexpected();
+_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void unexpected();
 
 typedef void (*terminate_handler)();
 _LIBCPP_VISIBLE terminate_handler set_terminate(terminate_handler) throw();
 _LIBCPP_VISIBLE terminate_handler get_terminate() throw();
-_LIBCPP_VISIBLE void terminate() __attribute__((__noreturn__));
+_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void terminate() _NOEXCEPT;
 
 _LIBCPP_VISIBLE bool uncaught_exception() throw();
 
 class exception_ptr;
 
 exception_ptr current_exception();
-void rethrow_exception(exception_ptr);  // noreturn
+_ATTRIBUTE(noreturn) void rethrow_exception(exception_ptr);
 
 class _LIBCPP_VISIBLE exception_ptr
 {
@@ -141,7 +141,7 @@
         {return !(__x == __y);}
 
     friend exception_ptr current_exception();
-    friend void rethrow_exception(exception_ptr);  // noreturn
+    _ATTRIBUTE(noreturn) friend void rethrow_exception(exception_ptr);
 };
 
 template<class _E>
@@ -172,7 +172,7 @@
     virtual ~nested_exception();
 
     // access functions
-    void rethrow_nested /*[[noreturn]]*/ () const;
+    _ATTRIBUTE(noreturn) void rethrow_nested() const;
     _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const {return __ptr_;}
 };
 
@@ -185,9 +185,10 @@
 };
 
 template <class _Tp>
+_ATTRIBUTE(noreturn)
 void
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested /*[[noreturn]]*/ (_Tp&& __t, typename enable_if<
+throw_with_nested(_Tp&& __t, typename enable_if<
                   is_class<typename remove_reference<_Tp>::type>::value &&
                   !is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
                                     >::type* = 0)
@@ -203,9 +204,10 @@
 }
 
 template <class _Tp>
+_ATTRIBUTE(noreturn)
 void
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested /*[[noreturn]]*/ (_Tp&& __t, typename enable_if<
+throw_with_nested(_Tp&& __t, typename enable_if<
                   !is_class<typename remove_reference<_Tp>::type>::value ||
                   is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
                                     >::type* = 0)

Modified: libcxx/trunk/src/exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/exception.cpp?rev=132125&r1=132124&r2=132125&view=diff
==============================================================================
--- libcxx/trunk/src/exception.cpp (original)
+++ libcxx/trunk/src/exception.cpp Thu May 26 12:07:32 2011
@@ -35,6 +35,7 @@
     return __sync_fetch_and_add(&__unexpected_handler, (std::unexpected_handler)0);
 }
 
+_ATTRIBUTE(noreturn)
 void
 std::unexpected()
 {
@@ -56,7 +57,7 @@
 }
 
 void
-std::terminate()
+std::terminate() _NOEXCEPT
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
     try
@@ -156,8 +157,9 @@
 {
 }
 
+_ATTRIBUTE(noreturn)
 void
-nested_exception::rethrow_nested /*[[noreturn]]*/ () const
+nested_exception::rethrow_nested() const
 {
     if (__ptr_ == nullptr)
         terminate();





More information about the cfe-commits mailing list