<div dir="ltr">To all those who wander here from the <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf">sanitizer autoconf buildbot failures</a>.<div><br></div><div>Yes, this commit is responsible for that breakage. The buildbot in question</div><div>attempts to compile libc++ in-tree w/o libc++abi. Previously libc++ silently defaulted</div><div>to using w/e <cxxabi.h> header it found on the system. However it no longer does this</div><div>on Linux, since the <cxxabi.h> header it finds could incorrectly belong to libstdc++ or libcxxrt.</div><div><br></div><div>Instead this builder should be changed to either:</div><div><br></div><div>(A) build libc++abi in-tree as well.</div><div>(B) explicitly specify -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS="<path-to-installed-headers>".</div><div><br></div><div>If these changes cannot be made easily and quickly then please let me know, and I'll implement a temporary workaround in</div><div>libc++.</div><div><br></div><div><br></div><div>/Eric</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 9, 2017 at 9:25 PM, Eric Fiselier via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Thu Feb  9 22:25:33 2017<br>
New Revision: 294707<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=294707&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=294707&view=rev</a><br>
Log:<br>
Split exception.cpp and new.cpp implementation into different files for different runtimes.<br>
<br>
exception.cpp is a bloody mess. It's full of confusing #ifdef branches for<br>
each different ABI library we support, and it's getting unmaintainable.<br>
<br>
This patch breaks down exception.cpp into multiple different header files,<br>
roughly one per implementation. Additionally it moves the definitions of<br>
exceptions in new.cpp into the correct implementation header.<br>
<br>
This patch also removes an unmaintained libc++abi configuration.<br>
This configuration may still be used by Apple internally but there<br>
are no other possible users. If it turns out that Apple still uses<br>
this configuration internally I will re-add it in a later commit.<br>
See <a href="http://llvm.org/PR31904" rel="noreferrer" target="_blank">http://llvm.org/PR31904</a>.<br>
<br>
Added:<br>
    libcxx/trunk/src/support/<wbr>runtime/<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_fallback.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_glibcxx.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_libcxxabi.<wbr>ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_libcxxrt.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_msvc.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>cxxabi.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>glibcxx.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>unimplemented.ipp<br>
    libcxx/trunk/src/support/<wbr>runtime/new_handler_fallback.<wbr>ipp<br>
Modified:<br>
    libcxx/trunk/CMakeLists.txt<br>
    libcxx/trunk/include/exception<br>
    libcxx/trunk/include/new<br>
    libcxx/trunk/include/typeinfo<br>
    libcxx/trunk/src/exception.cpp<br>
    libcxx/trunk/src/new.cpp<br>
    libcxx/trunk/src/typeinfo.cpp<br>
<br>
Modified: libcxx/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/<wbr>CMakeLists.txt?rev=294707&r1=<wbr>294706&r2=294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/CMakeLists.txt (original)<br>
+++ libcxx/trunk/CMakeLists.txt Thu Feb  9 22:25:33 2017<br>
@@ -116,11 +116,19 @@ if (LIBCXX_CXX_ABI STREQUAL "default")<br>
           ${LLVM_MAIN_SRC_DIR}/runtimes/<wbr>libcxxabi/include<br>
     NO_DEFAULT_PATH<br>
   )<br>
+  find_path(<br>
+    LIBCXX_LIBCXXABI_INCLUDES_<wbr>EXTERNAL<br>
+    cxxabi.h<br>
+    PATHS /usr/include<br>
+  )<br>
   if ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND<br>
       IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_<wbr>INTERNAL}")<br>
     set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")<br>
     set(LIBCXX_CXX_ABI_INCLUDE_<wbr>PATHS "${LIBCXX_LIBCXXABI_INCLUDES_<wbr>INTERNAL}")<br>
     set(LIBCXX_CXX_ABI_INTREE 1)<br>
+  elseif(APPLE AND IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_<wbr>INTERNAL}")<br>
+    set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")<br>
+    set(LIBCXX_CXX_ABI_INCLUDE_<wbr>PATHS "${LIBCXX_LIBCXXABI_INCLUDES_<wbr>INTERNAL}")<br>
   else()<br>
     if (LIBCXX_TARGETING_MSVC)<br>
       # FIXME: Figure out how to configure the ABI library on Windows.<br>
<br>
Modified: libcxx/trunk/include/exception<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>exception?rev=294707&r1=<wbr>294706&r2=294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/exception (original)<br>
+++ libcxx/trunk/include/exception Thu Feb  9 22:25:33 2017<br>
@@ -82,6 +82,10 @@ template <class E> void rethrow_if_neste<br>
 #include <cstdlib><br>
 #include <type_traits><br>
<br>
+#if defined(_LIBCPP_ABI_MICROSOFT)<br>
+#include <vcruntime_exception.h><br>
+#endif<br>
+<br>
 #if !defined(_LIBCPP_HAS_NO_<wbr>PRAGMA_SYSTEM_HEADER)<br>
 #pragma GCC system_header<br>
 #endif<br>
@@ -89,6 +93,7 @@ template <class E> void rethrow_if_neste<br>
 namespace std  // purposefully not using versioning namespace<br>
 {<br>
<br>
+#if !defined(_LIBCPP_ABI_<wbr>MICROSOFT)<br>
 class _LIBCPP_EXCEPTION_ABI exception<br>
 {<br>
 public:<br>
@@ -105,6 +110,7 @@ public:<br>
     virtual ~bad_exception() _NOEXCEPT;<br>
     virtual const char* what() const _NOEXCEPT;<br>
 };<br>
+#endif // !_LIBCPP_ABI_MICROSOFT<br>
<br>
 typedef void (*unexpected_handler)();<br>
 _LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_<wbr>handler) _NOEXCEPT;<br>
<br>
Modified: libcxx/trunk/include/new<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>new?rev=294707&r1=294706&r2=<wbr>294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/new (original)<br>
+++ libcxx/trunk/include/new Thu Feb  9 22:25:33 2017<br>
@@ -92,6 +92,10 @@ void  operator delete[](void* ptr, void*<br>
 #include <cstdlib><br>
 #endif<br>
<br>
+#if defined(_LIBCPP_ABI_MICROSOFT)<br>
+#include <new.h><br>
+#endif<br>
+<br>
 #if !defined(_LIBCPP_HAS_NO_<wbr>PRAGMA_SYSTEM_HEADER)<br>
 #pragma GCC system_header<br>
 #endif<br>
@@ -110,6 +114,10 @@ void  operator delete[](void* ptr, void*<br>
 namespace std  // purposefully not using versioning namespace<br>
 {<br>
<br>
+#if !defined(_LIBCPP_ABI_<wbr>MICROSOFT)<br>
+struct _LIBCPP_TYPE_VIS nothrow_t {};<br>
+extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;<br>
+<br>
 class _LIBCPP_EXCEPTION_ABI bad_alloc<br>
     : public exception<br>
 {<br>
@@ -128,6 +136,12 @@ public:<br>
     virtual const char* what() const _NOEXCEPT;<br>
 };<br>
<br>
+typedef void (*new_handler)();<br>
+_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;<br>
+_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;<br>
+<br>
+#endif // !_LIBCPP_ABI_MICROSOFT<br>
+<br>
 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc();  // not in C++ spec<br>
<br>
 #if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)<br>
@@ -153,12 +167,6 @@ enum align_val_t { __zero = 0, __max = (<br>
 #endif<br>
 #endif<br>
<br>
-struct _LIBCPP_TYPE_VIS nothrow_t {};<br>
-extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;<br>
-typedef void (*new_handler)();<br>
-_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;<br>
-_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;<br>
-<br>
 }  // std<br>
<br>
 #if defined(_LIBCPP_CXX03_LANG)<br>
@@ -167,6 +175,8 @@ _LIBCPP_FUNC_VIS new_handler get_new_han<br>
 #define _THROW_BAD_ALLOC<br>
 #endif<br>
<br>
+#if !defined(_LIBCPP_ABI_<wbr>MICROSOFT)<br>
+<br>
 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;<br>
 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;<br>
 _LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p) _NOEXCEPT;<br>
@@ -206,6 +216,8 @@ inline _LIBCPP_INLINE_VISIBILITY void* o<br>
 inline _LIBCPP_INLINE_VISIBILITY void  operator delete  (void*, void*) _NOEXCEPT {}<br>
 inline _LIBCPP_INLINE_VISIBILITY void  operator delete[](void*, void*) _NOEXCEPT {}<br>
<br>
+#endif // !_LIBCPP_ABI_MICROSOFT<br>
+<br>
 _LIBCPP_BEGIN_NAMESPACE_STD<br>
<br>
 inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {<br>
<br>
Modified: libcxx/trunk/include/typeinfo<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/<wbr>typeinfo?rev=294707&r1=294706&<wbr>r2=294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/typeinfo (original)<br>
+++ libcxx/trunk/include/typeinfo Thu Feb  9 22:25:33 2017<br>
@@ -69,7 +69,9 @@ public:<br>
 #pragma GCC system_header<br>
 #endif<br>
<br>
-#if defined(_LIBCPP_NONUNIQUE_<wbr>RTTI_BIT)<br>
+#if defined(_LIBCPP_ABI_MICROSOFT)<br>
+#include <vcruntime_typeinfo.h><br>
+#elif defined(_LIBCPP_NONUNIQUE_<wbr>RTTI_BIT)<br>
 #define _LIBCPP_HAS_NONUNIQUE_TYPEINFO<br>
 #else<br>
 #define _LIBCPP_HAS_UNIQUE_TYPEINFO<br>
@@ -78,6 +80,7 @@ public:<br>
 namespace std  // purposefully not using versioning namespace<br>
 {<br>
<br>
+#if !defined(_LIBCPP_ABI_<wbr>MICROSOFT)<br>
 class _LIBCPP_EXCEPTION_ABI type_info<br>
 {<br>
     type_info& operator=(const type_info&);<br>
@@ -187,6 +190,8 @@ public:<br>
     virtual const char* what() const _NOEXCEPT;<br>
 };<br>
<br>
+#endif // !_LIBCPP_ABI_MICROSOFT<br>
+<br>
 }  // std<br>
<br>
 _LIBCPP_BEGIN_NAMESPACE_STD<br>
<br>
Modified: libcxx/trunk/src/exception.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/exception.cpp?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>exception.cpp?rev=294707&r1=<wbr>294706&r2=294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/exception.cpp (original)<br>
+++ libcxx/trunk/src/exception.cpp Thu Feb  9 22:25:33 2017<br>
@@ -6,328 +6,30 @@<br>
 // Source Licenses. See LICENSE.TXT for details.<br>
 //<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
-#include <stdlib.h><br>
-#include <stdio.h><br>
<br>
 #include "exception"<br>
 #include "new"<br>
<br>
-#if defined(_LIBCPP_ABI_MICROSOFT)<br>
-#include <eh.h><br>
-#include <corecrt_terminate.h><br>
-#elif defined(__APPLE__) && !defined(LIBCXXRT) && \<br>
-    !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY)<br>
+#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_<wbr>LIBCXXABI) || \<br>
+  (defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY))<br>
   #include <cxxabi.h><br>
-<br>
   using namespace __cxxabiv1;<br>
   #define HAVE_DEPENDENT_EH_ABI 1<br>
-  #ifndef _LIBCPPABI_VERSION<br>
-    using namespace __cxxabiapple;<br>
-    // On Darwin, there are two STL shared libraries and a lower level ABI<br>
-    // shared library.  The globals holding the current terminate handler and<br>
-    // current unexpected handler are in the ABI library.<br>
-    #define __terminate_handler  __cxxabiapple::__cxa_<wbr>terminate_handler<br>
-    #define __unexpected_handler __cxxabiapple::__cxa_<wbr>unexpected_handler<br>
-  #endif  // _LIBCPPABI_VERSION<br>
-#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
-  #include <cxxabi.h><br>
-  using namespace __cxxabiv1;<br>
-  #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION)<br>
-    #define HAVE_DEPENDENT_EH_ABI 1<br>
-  #endif<br>
-#elif !defined(__GLIBCXX__) // defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
-  _LIBCPP_SAFE_STATIC static std::terminate_handler  __terminate_handler;<br>
-  _LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;<br>
-#endif // defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
-<br>
-namespace std<br>
-{<br>
-<br>
-#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)<br>
-<br>
-// libcxxrt provides implementations of these functions itself.<br>
-unexpected_handler<br>
-set_unexpected(unexpected_<wbr>handler func) _NOEXCEPT<br>
-{<br>
-#if defined(_LIBCPP_ABI_MICROSOFT)<br>
-  return ::set_unexpected(func);<br>
-#else<br>
-  return __sync_lock_test_and_set(&__<wbr>unexpected_handler, func);<br>
-#endif<br>
-}<br>
-<br>
-unexpected_handler<br>
-get_unexpected() _NOEXCEPT<br>
-{<br>
-#if defined(_LIBCPP_ABI_MICROSOFT)<br>
-  return ::_get_unexpected();<br>
-#else<br>
-  return __sync_fetch_and_add(&__<wbr>unexpected_handler, (unexpected_handler)0);<br>
-#endif<br>
-}<br>
-<br>
-_LIBCPP_NORETURN<br>
-void<br>
-unexpected()<br>
-{<br>
-    (*get_unexpected())();<br>
-    // unexpected handler should not return<br>
-    terminate();<br>
-}<br>
-<br>
-terminate_handler<br>
-set_terminate(terminate_<wbr>handler func) _NOEXCEPT<br>
-{<br>
-#if defined(_LIBCPP_ABI_MICROSOFT)<br>
-  return ::set_terminate(func);<br>
-#else<br>
-  return __sync_lock_test_and_set(&__<wbr>terminate_handler, func);<br>
 #endif<br>
-}<br>
<br>
-terminate_handler<br>
-get_terminate() _NOEXCEPT<br>
-{<br>
 #if defined(_LIBCPP_ABI_MICROSOFT)<br>
-  return ::_get_terminate();<br>
-#else<br>
-  return __sync_fetch_and_add(&__<wbr>terminate_handler, (terminate_handler)0);<br>
-#endif<br>
-}<br>
-<br>
-#ifndef __EMSCRIPTEN__ // We provide this in JS<br>
-_LIBCPP_NORETURN<br>
-void<br>
-terminate() _NOEXCEPT<br>
-{<br>
-#ifndef _LIBCPP_NO_EXCEPTIONS<br>
-    try<br>
-    {<br>
-#endif  // _LIBCPP_NO_EXCEPTIONS<br>
-        (*get_terminate())();<br>
-        // handler should not return<br>
-        fprintf(stderr, "terminate_handler unexpectedly returned\n");<br>
-        ::abort();<br>
-#ifndef _LIBCPP_NO_EXCEPTIONS<br>
-    }<br>
-    catch (...)<br>
-    {<br>
-        // handler should not throw exception<br>
-        fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");<br>
-        ::abort();<br>
-    }<br>
-#endif  // _LIBCPP_NO_EXCEPTIONS<br>
-}<br>
-#endif // !__EMSCRIPTEN__<br>
-#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)<br>
-<br>
-#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)<br>
-<br>
-bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }<br>
-<br>
-int uncaught_exceptions() _NOEXCEPT<br>
-{<br>
-#if !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY) && \<br>
-    (defined(__APPLE__) || defined(_LIBCPPABI_VERSION))<br>
-   // on Darwin, there is a helper function so __cxa_get_globals is private<br>
-# if _LIBCPPABI_VERSION > 1101<br>
-    return __cxa_uncaught_exceptions();<br>
-# else<br>
-    return __cxa_uncaught_exception() ? 1 : 0;<br>
-# endif<br>
-#elif defined(_LIBCPP_ABI_MICROSOFT)<br>
-    return __uncaught_exceptions();<br>
-#else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING("uncaught_<wbr>exceptions not yet implemented")<br>
-#   else<br>
-#       warning uncaught_exception not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "uncaught_exceptions not yet implemented\n");<br>
-    ::abort();<br>
-#endif  // __APPLE__<br>
-}<br>
-<br>
-<br>
-#ifndef _LIBCPPABI_VERSION<br>
-<br>
-exception::~exception() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char* exception::what() const _NOEXCEPT<br>
-{<br>
-  return "std::exception";<br>
-}<br>
-<br>
-#endif  // _LIBCPPABI_VERSION<br>
-#endif //LIBCXXRT<br>
-#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)<br>
-<br>
-bad_exception::~bad_<wbr>exception() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char* bad_exception::what() const _NOEXCEPT<br>
-{<br>
-  return "std::bad_exception";<br>
-}<br>
-<br>
-#endif<br>
-<br>
-#if defined(__GLIBCXX__)<br>
-<br>
-// libsupc++ does not implement the dependent EH ABI and the functionality<br>
-// it uses to implement std::exception_ptr (which it declares as an alias of<br>
-// std::__exception_ptr::<wbr>exception_ptr) is not directly exported to clients. So<br>
-// we have little choice but to hijack std::__exception_ptr::<wbr>exception_ptr's<br>
-// (which fortunately has the same layout as our std::exception_ptr) copy<br>
-// constructor, assignment operator and destructor (which are part of its<br>
-// stable ABI), and its rethrow_exception(std::__<wbr>exception_ptr::exception_ptr)<br>
-// function.<br>
-<br>
-namespace __exception_ptr<br>
-{<br>
-<br>
-struct exception_ptr<br>
-{<br>
-    void* __ptr_;<br>
-<br>
-    exception_ptr(const exception_ptr&) _NOEXCEPT;<br>
-    exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;<br>
-    ~exception_ptr() _NOEXCEPT;<br>
-};<br>
-<br>
-}<br>
-<br>
-_LIBCPP_NORETURN void rethrow_exception(__exception_<wbr>ptr::exception_ptr);<br>
-<br>
-#endif<br>
-<br>
-exception_ptr::~exception_<wbr>ptr() _NOEXCEPT<br>
-{<br>
-#if HAVE_DEPENDENT_EH_ABI<br>
-    __cxa_decrement_exception_<wbr>refcount(__ptr_);<br>
-#elif defined(__GLIBCXX__)<br>
-    reinterpret_cast<__exception_<wbr>ptr::exception_ptr*>(this)->~<wbr>exception_ptr();<br>
-#else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING("exception_ptr not yet implemented")<br>
-#   else<br>
-#       warning exception_ptr not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "exception_ptr not yet implemented\n");<br>
-    ::abort();<br>
-#endif<br>
-}<br>
-<br>
-exception_ptr::exception_ptr(<wbr>const exception_ptr& other) _NOEXCEPT<br>
-    : __ptr_(other.__ptr_)<br>
-{<br>
-#if HAVE_DEPENDENT_EH_ABI<br>
-    __cxa_increment_exception_<wbr>refcount(__ptr_);<br>
-#elif defined(__GLIBCXX__)<br>
-    new (reinterpret_cast<void*>(this)<wbr>) __exception_ptr::exception_<wbr>ptr(<br>
-        reinterpret_cast<const __exception_ptr::exception_<wbr>ptr&>(other));<br>
-#else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING("exception_ptr not yet implemented")<br>
-#   else<br>
-#       warning exception_ptr not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "exception_ptr not yet implemented\n");<br>
-    ::abort();<br>
-#endif<br>
-}<br>
-<br>
-exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT<br>
-{<br>
-#if HAVE_DEPENDENT_EH_ABI<br>
-    if (__ptr_ != other.__ptr_)<br>
-    {<br>
-        __cxa_increment_exception_<wbr>refcount(other.__ptr_);<br>
-        __cxa_decrement_exception_<wbr>refcount(__ptr_);<br>
-        __ptr_ = other.__ptr_;<br>
-    }<br>
-    return *this;<br>
-#elif defined(__GLIBCXX__)<br>
-    *reinterpret_cast<__exception_<wbr>ptr::exception_ptr*>(this) =<br>
-        reinterpret_cast<const __exception_ptr::exception_<wbr>ptr&>(other);<br>
-    return *this;<br>
-#else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING("exception_ptr not yet implemented")<br>
-#   else<br>
-#       warning exception_ptr not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "exception_ptr not yet implemented\n");<br>
-    ::abort();<br>
-#endif<br>
-}<br>
-<br>
-nested_exception::nested_<wbr>exception() _NOEXCEPT<br>
-    : __ptr_(current_exception())<br>
-{<br>
-}<br>
-<br>
-#if !defined(__GLIBCXX__)<br>
-<br>
-nested_exception::~nested_<wbr>exception() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-#endif<br>
-<br>
-_LIBCPP_NORETURN<br>
-void<br>
-nested_exception::rethrow_<wbr>nested() const<br>
-{<br>
-    if (__ptr_ == nullptr)<br>
-        terminate();<br>
-    rethrow_exception(__ptr_);<br>
-}<br>
-<br>
-#if !defined(__GLIBCXX__)<br>
-<br>
-exception_ptr current_exception() _NOEXCEPT<br>
-{<br>
-#if HAVE_DEPENDENT_EH_ABI<br>
-    // be nicer if there was a constructor that took a ptr, then<br>
-    // this whole function would be just:<br>
-    //    return exception_ptr(__cxa_current_<wbr>primary_exception());<br>
-    exception_ptr ptr;<br>
-    ptr.__ptr_ = __cxa_current_primary_<wbr>exception();<br>
-    return ptr;<br>
-#else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING( "exception_ptr not yet implemented" )<br>
-#   else<br>
-#       warning exception_ptr not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "exception_ptr not yet implemented\n");<br>
-    ::abort();<br>
-#endif<br>
-}<br>
-<br>
-#endif  // !__GLIBCXX__<br>
-<br>
-_LIBCPP_NORETURN<br>
-void rethrow_exception(exception_<wbr>ptr p)<br>
-{<br>
-#if HAVE_DEPENDENT_EH_ABI<br>
-    __cxa_rethrow_primary_<wbr>exception(p.__ptr_);<br>
-    // if p.__ptr_ is NULL, above returns so we terminate<br>
-    terminate();<br>
+#include "support/runtime/exception_<wbr>msvc.ipp"<br>
+#include "support/runtime/exception_<wbr>pointer_unimplemented.ipp"<br>
+#elif defined(_LIBCPPABI_VERSION)<br>
+#include "support/runtime/exception_<wbr>libcxxabi.ipp"<br>
+#include "support/runtime/exception_<wbr>pointer_cxxabi.ipp"<br>
+#elif defined(LIBCXXRT)<br>
+#include "support/runtime/exception_<wbr>libcxxrt.ipp"<br>
+#include "support/runtime/exception_<wbr>pointer_cxxabi.ipp"<br>
 #elif defined(__GLIBCXX__)<br>
-    rethrow_exception(reinterpret_<wbr>cast<__exception_ptr::<wbr>exception_ptr&>(p));<br>
+#include "support/runtime/exception_<wbr>glibcxx.ipp"<br>
+#include "support/runtime/exception_<wbr>pointer_glibcxx.ipp"<br>
 #else<br>
-#   if defined(_LIBCPP_MSVC)<br>
-        _LIBCPP_WARNING("exception_ptr not yet implemented")<br>
-#   else<br>
-#       warning exception_ptr not yet implemented<br>
-#   endif<br>
-    fprintf(stderr, "exception_ptr not yet implemented\n");<br>
-    ::abort();<br>
+#include "support/runtime/exception_<wbr>fallback.ipp"<br>
+#include "support/runtime/exception_<wbr>pointer_unimplemented.ipp"<br>
 #endif<br>
-}<br>
-} // std<br>
<br>
Modified: libcxx/trunk/src/new.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/new.<wbr>cpp?rev=294707&r1=294706&r2=<wbr>294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/new.cpp (original)<br>
+++ libcxx/trunk/src/new.cpp Thu Feb  9 22:25:33 2017<br>
@@ -13,27 +13,45 @@<br>
<br>
 #include "new"<br>
<br>
-#if defined(__APPLE__) && !defined(LIBCXXRT) && \<br>
-    !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY)<br>
-    #include <cxxabi.h><br>
-<br>
-    #ifndef _LIBCPPABI_VERSION<br>
-        // On Darwin, there are two STL shared libraries and a lower level ABI<br>
-        // shared library.  The global holding the current new handler is<br>
-        // in the ABI library and named __cxa_new_handler.<br>
-        #define __new_handler __cxxabiapple::__cxa_new_<wbr>handler<br>
-    #endif<br>
-#else  // __APPLE__<br>
-    #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
-        #include <cxxabi.h><br>
-    #endif  // defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
-    #if defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY) || \<br>
-        (!defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__))<br>
-        static std::new_handler __new_handler;<br>
-    #endif  // _LIBCPPABI_VERSION<br>
+#if defined(_LIBCPP_ABI_MICROSOFT)<br>
+// nothing todo<br>
+#elif defined(LIBCXX_BUILDING_<wbr>LIBCXXABI)<br>
+#include <cxxabi.h><br>
+#elif defined(LIBCXXRT)<br>
+#include <cxxabi.h><br>
+#include "new_handler_fallback.ipp"<br>
+#elif defined(__GLIBCXX__)<br>
+// nothing todo<br>
+#elif defined(_LIBCPP_BUILDING_NO_<wbr>ABI_LIBRARY)<br>
+// nothing todo<br>
+#else<br>
+#error UNSUPPORTED configuration<br>
 #endif<br>
<br>
+namespace std<br>
+{<br>
+<br>
 #ifndef __GLIBCXX__<br>
+const nothrow_t nothrow = {};<br>
+#endif<br>
+<br>
+#ifndef LIBSTDCXX<br>
+<br>
+void<br>
+__throw_bad_alloc()<br>
+{<br>
+#ifndef _LIBCPP_NO_EXCEPTIONS<br>
+    throw bad_alloc();<br>
+#else<br>
+    _VSTD::abort();<br>
+#endif<br>
+}<br>
+<br>
+#endif // !LIBSTDCXX<br>
+<br>
+}  // std<br>
+<br>
+#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_<wbr>MICROSOFT)<br>
<br>
 // Implement all new and delete operators as weak definitions<br>
 // in this shared library, so that they can be overridden by programs<br>
@@ -277,107 +295,5 @@ operator delete[] (void* ptr, size_t, st<br>
     ::operator delete[](ptr, alignment);<br>
 }<br>
<br>
-#endif // !defined(_LIBCPP_HAS_NO_<wbr>ALIGNED_ALLOCATION)<br>
-<br>
-#endif // !__GLIBCXX__<br>
-<br>
-namespace std<br>
-{<br>
-<br>
-#ifndef __GLIBCXX__<br>
-const nothrow_t nothrow = {};<br>
-#endif<br>
-<br>
-#ifndef _LIBCPPABI_VERSION<br>
-<br>
-#ifndef __GLIBCXX__<br>
-<br>
-new_handler<br>
-set_new_handler(new_handler handler) _NOEXCEPT<br>
-{<br>
-    return __sync_lock_test_and_set(&__<wbr>new_handler, handler);<br>
-}<br>
-<br>
-new_handler<br>
-get_new_handler() _NOEXCEPT<br>
-{<br>
-    return __sync_fetch_and_add(&__new_<wbr>handler, nullptr);<br>
-}<br>
-<br>
-#endif // !__GLIBCXX__<br>
-<br>
-#ifndef LIBCXXRT<br>
-<br>
-bad_alloc::bad_alloc() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-#ifndef __GLIBCXX__<br>
-<br>
-bad_alloc::~bad_alloc() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char*<br>
-bad_alloc::what() const _NOEXCEPT<br>
-{<br>
-    return "std::bad_alloc";<br>
-}<br>
-<br>
-#endif // !__GLIBCXX__<br>
-<br>
-bad_array_new_length::bad_<wbr>array_new_length() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-#ifndef __GLIBCXX__<br>
-<br>
-bad_array_new_length::~bad_<wbr>array_new_length() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char*<br>
-bad_array_new_length::what() const _NOEXCEPT<br>
-{<br>
-    return "bad_array_new_length";<br>
-}<br>
-<br>
-#endif // !__GLIBCXX__<br>
-<br>
-#endif //LIBCXXRT<br>
-<br>
-bad_array_length::bad_array_<wbr>length() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-#ifndef __GLIBCXX__<br>
-<br>
-bad_array_length::~bad_array_<wbr>length() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char*<br>
-bad_array_length::what() const _NOEXCEPT<br>
-{<br>
-    return "bad_array_length";<br>
-}<br>
-<br>
-#endif // !__GLIBCXX__<br>
-<br>
-#endif // _LIBCPPABI_VERSION<br>
-<br>
-#ifndef LIBSTDCXX<br>
-<br>
-void<br>
-__throw_bad_alloc()<br>
-{<br>
-#ifndef _LIBCPP_NO_EXCEPTIONS<br>
-    throw bad_alloc();<br>
-#else<br>
-    _VSTD::abort();<br>
-#endif<br>
-}<br>
-<br>
-#endif // !LIBSTDCXX<br>
-<br>
-}  // std<br>
+#endif // !_LIBCPP_HAS_NO_ALIGNED_<wbr>ALLOCATION<br>
+#endif // !__GLIBCXX__ && !_LIBCPP_ABI_MICROSOFT<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_fallback.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_fallback.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>fallback.ipp?rev=294707&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_fallback.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_fallback.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,182 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+namespace std {<br>
+<br>
+_LIBCPP_SAFE_STATIC static std::terminate_handler  __terminate_handler;<br>
+_LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;<br>
+<br>
+<br>
+// libcxxrt provides implementations of these functions itself.<br>
+unexpected_handler<br>
+set_unexpected(unexpected_<wbr>handler func) _NOEXCEPT<br>
+{<br>
+  return __sync_lock_test_and_set(&__<wbr>unexpected_handler, func);<br>
+}<br>
+<br>
+unexpected_handler<br>
+get_unexpected() _NOEXCEPT<br>
+{<br>
+  return __sync_fetch_and_add(&__<wbr>unexpected_handler, (unexpected_handler)0);<br>
+<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void unexpected()<br>
+{<br>
+    (*get_unexpected())();<br>
+    // unexpected handler should not return<br>
+    terminate();<br>
+}<br>
+<br>
+terminate_handler<br>
+set_terminate(terminate_<wbr>handler func) _NOEXCEPT<br>
+{<br>
+  return __sync_lock_test_and_set(&__<wbr>terminate_handler, func);<br>
+}<br>
+<br>
+terminate_handler<br>
+get_terminate() _NOEXCEPT<br>
+{<br>
+  return __sync_fetch_and_add(&__<wbr>terminate_handler, (terminate_handler)0);<br>
+<br>
+}<br>
+<br>
+#ifndef __EMSCRIPTEN__ // We provide this in JS<br>
+_LIBCPP_NORETURN<br>
+void<br>
+terminate() _NOEXCEPT<br>
+{<br>
+#ifndef _LIBCPP_NO_EXCEPTIONS<br>
+    try<br>
+    {<br>
+#endif  // _LIBCPP_NO_EXCEPTIONS<br>
+        (*get_terminate())();<br>
+        // handler should not return<br>
+        fprintf(stderr, "terminate_handler unexpectedly returned\n");<br>
+        ::abort();<br>
+#ifndef _LIBCPP_NO_EXCEPTIONS<br>
+    }<br>
+    catch (...)<br>
+    {<br>
+        // handler should not throw exception<br>
+        fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");<br>
+        ::abort();<br>
+    }<br>
+#endif  // _LIBCPP_NO_EXCEPTIONS<br>
+}<br>
+#endif // !__EMSCRIPTEN__<br>
+<br>
+#if !defined(__EMSCRIPTEN__)<br>
+bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }<br>
+<br>
+int uncaught_exceptions() _NOEXCEPT<br>
+{<br>
+#warning uncaught_exception not yet implemented<br>
+  fprintf(stderr, "uncaught_exceptions not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+#endif // !__EMSCRIPTEN__<br>
+<br>
+<br>
+exception::~exception() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char* exception::what() const _NOEXCEPT<br>
+{<br>
+  return "std::exception";<br>
+}<br>
+<br>
+bad_exception::~bad_<wbr>exception() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char* bad_exception::what() const _NOEXCEPT<br>
+{<br>
+  return "std::bad_exception";<br>
+}<br>
+<br>
+<br>
+bad_alloc::bad_alloc() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_alloc::~bad_alloc() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_alloc::what() const _NOEXCEPT<br>
+{<br>
+    return "std::bad_alloc";<br>
+}<br>
+<br>
+bad_array_new_length::bad_<wbr>array_new_length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_new_length::~bad_<wbr>array_new_length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_array_new_length::what() const _NOEXCEPT<br>
+{<br>
+    return "bad_array_new_length";<br>
+}<br>
+<br>
+<br>
+bad_array_length::bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_length::~bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_array_length::what() const _NOEXCEPT<br>
+{<br>
+    return "bad_array_length";<br>
+}<br>
+<br>
+<br>
+bad_cast::bad_cast() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_typeid::bad_typeid() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+#ifndef __GLIBCXX__<br>
+<br>
+bad_cast::~bad_cast() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_cast::what() const _NOEXCEPT<br>
+{<br>
+  return "std::bad_cast";<br>
+}<br>
+<br>
+bad_typeid::~bad_typeid() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_typeid::what() const _NOEXCEPT<br>
+{<br>
+  return "std::bad_typeid";<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_glibcxx.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_glibcxx.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>glibcxx.ipp?rev=294707&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_glibcxx.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_glibcxx.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,38 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef __GLIBCXX__<br>
+#error header can only be used when targeting libstdc++ or libsupc++<br>
+#endif<br>
+<br>
+namespace std {<br>
+<br>
+bad_alloc::bad_alloc() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_new_length::bad_<wbr>array_new_length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_length::bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+<br>
+bad_cast::bad_cast() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_typeid::bad_typeid() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+} // namespace<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_libcxxabi.<wbr>ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>libcxxabi.ipp?rev=294707&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_libcxxabi.<wbr>ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_libcxxabi.<wbr>ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,28 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef _LIBCPPABI_VERSION<br>
+#error this header can only be used with libc++abi<br>
+#endif<br>
+<br>
+namespace std {<br>
+<br>
+bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }<br>
+<br>
+int uncaught_exceptions() _NOEXCEPT<br>
+{<br>
+# if _LIBCPPABI_VERSION > 1101<br>
+    return __cxa_uncaught_exceptions();<br>
+# else<br>
+    return __cxa_uncaught_exception() ? 1 : 0;<br>
+# endif<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_libcxxrt.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_libcxxrt.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>libcxxrt.ipp?rev=294707&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_libcxxrt.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_libcxxrt.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,41 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef LIBCXXRT<br>
+#error this header may only be used when targeting libcxxrt<br>
+#endif<br>
+<br>
+namespace std {<br>
+<br>
+bad_exception::~bad_<wbr>exception() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char* bad_exception::what() const _NOEXCEPT<br>
+{<br>
+  return "std::bad_exception";<br>
+}<br>
+<br>
+<br>
+bad_array_length::bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_length::~bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_array_length::what() const _NOEXCEPT<br>
+{<br>
+    return "bad_array_length";<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_msvc.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_msvc.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>msvc.ipp?rev=294707&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_msvc.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_msvc.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,89 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef _LIBCPP_ABI_MICROSOFT<br>
+#error this header can only be used when targeting the MSVC ABI<br>
+#endif<br>
+<br>
+#include <stdio.h><br>
+#include <stdlib.h><br>
+#include <eh.h><br>
+#include <corecrt_terminate.h><br>
+<br>
+namespace std {<br>
+<br>
+// libcxxrt provides implementations of these functions itself.<br>
+unexpected_handler<br>
+set_unexpected(unexpected_<wbr>handler func) _NOEXCEPT {<br>
+  return ::set_unexpected(func);<br>
+}<br>
+<br>
+unexpected_handler get_unexpected() _NOEXCEPT {<br>
+  return ::_get_unexpected();<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void unexpected() {<br>
+    (*get_unexpected())();<br>
+    // unexpected handler should not return<br>
+    terminate();<br>
+}<br>
+<br>
+terminate_handler set_terminate(terminate_<wbr>handler func) _NOEXCEPT {<br>
+  return ::set_terminate(func);<br>
+}<br>
+<br>
+terminate_handler get_terminate() _NOEXCEPT {<br>
+  return ::_get_terminate();<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void terminate() _NOEXCEPT<br>
+{<br>
+#ifndef _LIBCPP_NO_EXCEPTIONS<br>
+    try<br>
+    {<br>
+#endif  // _LIBCPP_NO_EXCEPTIONS<br>
+        (*get_terminate())();<br>
+        // handler should not return<br>
+        fprintf(stderr, "terminate_handler unexpectedly returned\n");<br>
+        ::abort();<br>
+#ifndef _LIBCPP_NO_EXCEPTIONS<br>
+    }<br>
+    catch (...)<br>
+    {<br>
+        // handler should not throw exception<br>
+        fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");<br>
+        ::abort();<br>
+    }<br>
+#endif  // _LIBCPP_NO_EXCEPTIONS<br>
+}<br>
+<br>
+bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }<br>
+<br>
+int uncaught_exceptions() _NOEXCEPT {<br>
+    return __uncaught_exceptions();<br>
+}<br>
+<br>
+bad_array_length::bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+bad_array_length::~bad_array_<wbr>length() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+const char*<br>
+bad_array_length::what() const _NOEXCEPT<br>
+{<br>
+    return "bad_array_length";<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>cxxabi.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_pointer_cxxabi.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>pointer_cxxabi.ipp?rev=294707&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>cxxabi.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>cxxabi.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,74 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef HAVE_DEPENDENT_EH_ABI<br>
+#error this header may only be used with libc++abi or libcxxrt<br>
+#endif<br>
+<br>
+namespace std {<br>
+<br>
+exception_ptr::~exception_<wbr>ptr() _NOEXCEPT {<br>
+  __cxa_decrement_exception_<wbr>refcount(__ptr_);<br>
+}<br>
+<br>
+exception_ptr::exception_ptr(<wbr>const exception_ptr& other) _NOEXCEPT<br>
+    : __ptr_(other.__ptr_)<br>
+{<br>
+    __cxa_increment_exception_<wbr>refcount(__ptr_);<br>
+}<br>
+<br>
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT<br>
+{<br>
+    if (__ptr_ != other.__ptr_)<br>
+    {<br>
+        __cxa_increment_exception_<wbr>refcount(other.__ptr_);<br>
+        __cxa_decrement_exception_<wbr>refcount(__ptr_);<br>
+        __ptr_ = other.__ptr_;<br>
+    }<br>
+    return *this;<br>
+}<br>
+<br>
+nested_exception::nested_<wbr>exception() _NOEXCEPT<br>
+    : __ptr_(current_exception())<br>
+{<br>
+}<br>
+<br>
+nested_exception::~nested_<wbr>exception() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void<br>
+nested_exception::rethrow_<wbr>nested() const<br>
+{<br>
+    if (__ptr_ == nullptr)<br>
+        terminate();<br>
+    rethrow_exception(__ptr_);<br>
+}<br>
+<br>
+exception_ptr current_exception() _NOEXCEPT<br>
+{<br>
+    // be nicer if there was a constructor that took a ptr, then<br>
+    // this whole function would be just:<br>
+    //    return exception_ptr(__cxa_current_<wbr>primary_exception());<br>
+    exception_ptr ptr;<br>
+    ptr.__ptr_ = __cxa_current_primary_<wbr>exception();<br>
+    return ptr;<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void rethrow_exception(exception_<wbr>ptr p)<br>
+{<br>
+    __cxa_rethrow_primary_<wbr>exception(p.__ptr_);<br>
+    // if p.__ptr_ is NULL, above returns so we terminate<br>
+    terminate();<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>glibcxx.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_pointer_glibcxx.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>pointer_glibcxx.ipp?rev=<wbr>294707&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>glibcxx.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>glibcxx.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,74 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+// libsupc++ does not implement the dependent EH ABI and the functionality<br>
+// it uses to implement std::exception_ptr (which it declares as an alias of<br>
+// std::__exception_ptr::<wbr>exception_ptr) is not directly exported to clients. So<br>
+// we have little choice but to hijack std::__exception_ptr::<wbr>exception_ptr's<br>
+// (which fortunately has the same layout as our std::exception_ptr) copy<br>
+// constructor, assignment operator and destructor (which are part of its<br>
+// stable ABI), and its rethrow_exception(std::__<wbr>exception_ptr::exception_ptr)<br>
+// function.<br>
+<br>
+namespace __exception_ptr<br>
+{<br>
+<br>
+struct exception_ptr<br>
+{<br>
+    void* __ptr_;<br>
+<br>
+    exception_ptr(const exception_ptr&) _NOEXCEPT;<br>
+    exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;<br>
+    ~exception_ptr() _NOEXCEPT;<br>
+};<br>
+<br>
+}<br>
+<br>
+_LIBCPP_NORETURN void rethrow_exception(__exception_<wbr>ptr::exception_ptr);<br>
+<br>
+exception_ptr::~exception_<wbr>ptr() _NOEXCEPT<br>
+{<br>
+    reinterpret_cast<__exception_<wbr>ptr::exception_ptr*>(this)->~<wbr>exception_ptr();<br>
+}<br>
+<br>
+exception_ptr::exception_ptr(<wbr>const exception_ptr& other) _NOEXCEPT<br>
+    : __ptr_(other.__ptr_)<br>
+{<br>
+    new (reinterpret_cast<void*>(this)<wbr>) __exception_ptr::exception_<wbr>ptr(<br>
+        reinterpret_cast<const __exception_ptr::exception_<wbr>ptr&>(other));<br>
+}<br>
+<br>
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT<br>
+{<br>
+    *reinterpret_cast<__exception_<wbr>ptr::exception_ptr*>(this) =<br>
+        reinterpret_cast<const __exception_ptr::exception_<wbr>ptr&>(other);<br>
+    return *this;<br>
+}<br>
+<br>
+nested_exception::nested_<wbr>exception() _NOEXCEPT<br>
+    : __ptr_(current_exception())<br>
+{<br>
+}<br>
+<br>
+<br>
+_LIBCPP_NORETURN<br>
+void<br>
+nested_exception::rethrow_<wbr>nested() const<br>
+{<br>
+    if (__ptr_ == nullptr)<br>
+        terminate();<br>
+    rethrow_exception(__ptr_);<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void rethrow_exception(exception_<wbr>ptr p)<br>
+{<br>
+    rethrow_exception(reinterpret_<wbr>cast<__exception_ptr::<wbr>exception_ptr&>(p));<br>
+}<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>unimplemented.ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_pointer_unimplemented.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/exception_<wbr>pointer_unimplemented.ipp?rev=<wbr>294707&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>unimplemented.ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/exception_pointer_<wbr>unimplemented.ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,80 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include <stdio.h><br>
+#include <stdlib.h><br>
+<br>
+namespace std {<br>
+<br>
+exception_ptr::~exception_<wbr>ptr() _NOEXCEPT<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+<br>
+exception_ptr::exception_ptr(<wbr>const exception_ptr& other) _NOEXCEPT<br>
+    : __ptr_(other.__ptr_)<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+<br>
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+<br>
+nested_exception::nested_<wbr>exception() _NOEXCEPT<br>
+    : __ptr_(current_exception())<br>
+{<br>
+}<br>
+<br>
+#if !defined(__GLIBCXX__)<br>
+<br>
+nested_exception::~nested_<wbr>exception() _NOEXCEPT<br>
+{<br>
+}<br>
+<br>
+#endif<br>
+<br>
+_LIBCPP_NORETURN<br>
+void<br>
+nested_exception::rethrow_<wbr>nested() const<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+#if 0<br>
+  if (__ptr_ == nullptr)<br>
+      terminate();<br>
+  rethrow_exception(__ptr_);<br>
+#endif // FIXME<br>
+}<br>
+<br>
+exception_ptr current_exception() _NOEXCEPT<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+<br>
+_LIBCPP_NORETURN<br>
+void rethrow_exception(exception_<wbr>ptr p)<br>
+{<br>
+#  warning exception_ptr not yet implemented<br>
+  fprintf(stderr, "exception_ptr not yet implemented\n");<br>
+  ::abort();<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Added: libcxx/trunk/src/support/<wbr>runtime/new_handler_fallback.<wbr>ipp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/new_handler_fallback.ipp?rev=294707&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>support/runtime/new_handler_<wbr>fallback.ipp?rev=294707&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/support/<wbr>runtime/new_handler_fallback.<wbr>ipp (added)<br>
+++ libcxx/trunk/src/support/<wbr>runtime/new_handler_fallback.<wbr>ipp Thu Feb  9 22:25:33 2017<br>
@@ -0,0 +1,27 @@<br>
+// -*- C++ -*-<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+namespace std {<br>
+<br>
+_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;<br>
+<br>
+new_handler<br>
+set_new_handler(new_handler handler) _NOEXCEPT<br>
+{<br>
+    return __sync_lock_test_and_set(&__<wbr>new_handler, handler);<br>
+}<br>
+<br>
+new_handler<br>
+get_new_handler() _NOEXCEPT<br>
+{<br>
+    return __sync_fetch_and_add(&__new_<wbr>handler, nullptr);<br>
+}<br>
+<br>
+} // namespace std<br>
<br>
Modified: libcxx/trunk/src/typeinfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/typeinfo.cpp?rev=294707&r1=294706&r2=294707&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>typeinfo.cpp?rev=294707&r1=<wbr>294706&r2=294707&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/typeinfo.cpp (original)<br>
+++ libcxx/trunk/src/typeinfo.cpp Thu Feb  9 22:25:33 2017<br>
@@ -6,74 +6,11 @@<br>
 // Source Licenses. See LICENSE.TXT for details.<br>
 //<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
-#include <stdlib.h><br>
-<br>
-#if !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY) && \<br>
-    (defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_<wbr>LIBCXXABI))<br>
-#include <cxxabi.h><br>
-#endif<br>
<br>
 #include "typeinfo"<br>
<br>
-#if defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY) || \<br>
-    defined(_LIBCPP_ABI_MICROSOFT) // FIXME: This is a temporary workaround<br>
+#if defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY)<br>
 std::type_info::~type_info()<br>
 {<br>
 }<br>
 #endif<br>
-<br>
-#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)<br>
-<br>
-std::bad_cast::bad_cast() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-std::bad_typeid::bad_typeid() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-#ifndef __GLIBCXX__<br>
-<br>
-std::bad_cast::~bad_cast() _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char*<br>
-std::bad_cast::what() const _NOEXCEPT<br>
-{<br>
-  return "std::bad_cast";<br>
-}<br>
-<br>
-std::bad_typeid::~bad_typeid(<wbr>) _NOEXCEPT<br>
-{<br>
-}<br>
-<br>
-const char*<br>
-std::bad_typeid::what() const _NOEXCEPT<br>
-{<br>
-  return "std::bad_typeid";<br>
-}<br>
-<br>
-#if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_<wbr>NO_ABI_LIBRARY)<br>
-  // On Darwin, the cxa_bad_* functions cannot be in the lower level library<br>
-  // because bad_cast and bad_typeid are defined in his higher level library<br>
-  void __cxxabiv1::__cxa_bad_typeid()<br>
-  {<br>
-#ifndef _LIBCPP_NO_EXCEPTIONS<br>
-     throw std::bad_typeid();<br>
-#else<br>
-     _VSTD::abort();<br>
-#endif<br>
-  }<br>
-  void __cxxabiv1::__cxa_bad_cast()<br>
-  {<br>
-#ifndef _LIBCPP_NO_EXCEPTIONS<br>
-      throw std::bad_cast();<br>
-#else<br>
-      _VSTD::abort();<br>
-#endif<br>
-  }<br>
-#endif<br>
-<br>
-#endif  // !__GLIBCXX__<br>
-#endif  // !LIBCXXRT && !_LIBCPPABI_VERSION<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>