summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/exception57
-rw-r--r--libcxx/lib/CMakeLists.txt1
-rw-r--r--libcxx/src/exception.cpp2
-rw-r--r--libcxx/src/support/runtime/exception_pointer_msvc.ipp94
-rw-r--r--libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp4
-rw-r--r--libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp5
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp3
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp9
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp9
16 files changed, 167 insertions, 38 deletions
diff --git a/libcxx/include/exception b/libcxx/include/exception
index 9999ca096c0..ca2eaf5c6a0 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -134,23 +134,26 @@ class _LIBCPP_TYPE_VIS exception_ptr;
_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
+#ifndef _LIBCPP_ABI_MICROSOFT
+
class _LIBCPP_TYPE_VIS exception_ptr
{
void* __ptr_;
public:
_LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {}
_LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
+
exception_ptr(const exception_ptr&) _NOEXCEPT;
exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
~exception_ptr() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool() const _NOEXCEPT {return __ptr_ != nullptr;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+ {return __ptr_ != nullptr;}
friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
{return __x.__ptr_ == __y.__ptr_;}
+
friend _LIBCPP_INLINE_VISIBILITY
bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
{return !(__x == __y);}
@@ -178,6 +181,54 @@ make_exception_ptr(_Ep __e) _NOEXCEPT
#endif
}
+#else // _LIBCPP_ABI_MICROSOFT
+
+class _LIBCPP_TYPE_VIS exception_ptr
+{
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-private-field"
+#endif
+ void* __ptr1_;
+ void* __ptr2_;
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+public:
+ exception_ptr() _NOEXCEPT;
+ exception_ptr(nullptr_t) _NOEXCEPT;
+ exception_ptr(const exception_ptr& __other) _NOEXCEPT;
+ exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT;
+ exception_ptr& operator=(nullptr_t) _NOEXCEPT;
+ ~exception_ptr() _NOEXCEPT;
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT;
+};
+
+_LIBCPP_FUNC_VIS
+bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT;
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
+ {return !(__x == __y);}
+
+_LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
+
+_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr);
+_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p);
+
+// This is a built-in template function which automagically extracts the required
+// information.
+template <class _E> void *__GetExceptionInfo(_E);
+
+template<class _Ep>
+exception_ptr
+make_exception_ptr(_Ep __e) _NOEXCEPT
+{
+ return __copy_exception_ptr(_VSTD::addressof(__e), __GetExceptionInfo(__e));
+}
+
+#endif // _LIBCPP_ABI_MICROSOFT
// nested_exception
class _LIBCPP_EXCEPTION_ABI nested_exception
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index 15dc05c761c..6161838d0df 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -121,6 +121,7 @@ if (LIBCXX_TARGETING_MSVC)
add_library_flags(ucrt${LIB_SUFFIX}) # Universal C runtime
add_library_flags(vcruntime${LIB_SUFFIX}) # C++ runtime
add_library_flags(msvcrt${LIB_SUFFIX}) # C runtime startup files
+ add_library_flags(msvcprt${LIB_SUFFIX}) # C++ standard library. Required for exception_ptr internals.
# Required for standards-complaint wide character formatting functions
# (e.g. `printfw`/`scanfw`)
add_library_flags(iso_stdio_wide_specifiers)
diff --git a/libcxx/src/exception.cpp b/libcxx/src/exception.cpp
index 0b502cd134c..4359d126173 100644
--- a/libcxx/src/exception.cpp
+++ b/libcxx/src/exception.cpp
@@ -20,7 +20,7 @@
#if defined(_LIBCPP_ABI_MICROSOFT)
#include "support/runtime/exception_msvc.ipp"
-#include "support/runtime/exception_pointer_unimplemented.ipp"
+#include "support/runtime/exception_pointer_msvc.ipp"
#elif defined(_LIBCPPABI_VERSION)
#include "support/runtime/exception_libcxxabi.ipp"
#include "support/runtime/exception_pointer_cxxabi.ipp"
diff --git a/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/libcxx/src/support/runtime/exception_pointer_msvc.ipp
new file mode 100644
index 00000000000..a8cd0e8d304
--- /dev/null
+++ b/libcxx/src/support/runtime/exception_pointer_msvc.ipp
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(_Out_ void*,
+ _In_ const void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrAssign(_Inout_ void*, _In_ const void*);
+_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrCompare(_In_ const void*, _In_ const void*);
+_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrToBool(_In_ const void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrSwap(_Inout_ void*,
+ _Inout_ void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrCurrentException(_Out_ void*);
+[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrRethrow(_In_ const void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
+__ExceptionPtrCopyException(_Inout_ void*, _In_ const void*, _In_ const void*);
+
+namespace std {
+
+exception_ptr::exception_ptr() _NOEXCEPT { __ExceptionPtrCreate(this); }
+exception_ptr::exception_ptr(nullptr_t) _NOEXCEPT { __ExceptionPtrCreate(this); }
+
+exception_ptr::exception_ptr(const exception_ptr& __other) _NOEXCEPT {
+ __ExceptionPtrCopy(this, &__other);
+}
+exception_ptr& exception_ptr::operator=(const exception_ptr& __other) _NOEXCEPT {
+ __ExceptionPtrAssign(this, &__other);
+ return *this;
+}
+
+exception_ptr& exception_ptr::operator=(nullptr_t) _NOEXCEPT {
+ exception_ptr dummy;
+ __ExceptionPtrAssign(this, &dummy);
+ return *this;
+}
+
+exception_ptr::~exception_ptr() _NOEXCEPT { __ExceptionPtrDestroy(this); }
+
+exception_ptr::operator bool() const _NOEXCEPT {
+ return __ExceptionPtrToBool(this);
+}
+
+bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {
+ return __ExceptionPtrCompare(&__x, &__y);
+}
+
+
+void swap(exception_ptr& lhs, exception_ptr& rhs) _NOEXCEPT {
+ __ExceptionPtrSwap(&rhs, &lhs);
+}
+
+exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) {
+ exception_ptr __ret = nullptr;
+ if (__ptr)
+ __ExceptionPtrCopyException(&__ret, __except, __ptr);
+ return __ret;
+}
+
+exception_ptr current_exception() _NOEXCEPT {
+ exception_ptr __ret;
+ __ExceptionPtrCurrentException(&__ret);
+ return __ret;
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }
+
+nested_exception::nested_exception() _NOEXCEPT : __ptr_(current_exception()) {}
+
+nested_exception::~nested_exception() _NOEXCEPT {}
+
+_LIBCPP_NORETURN
+void nested_exception::rethrow_nested() const {
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+}
+
+} // namespace std
diff --git a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
index 12c0a3d5ef4..9efa597d73e 100644
--- a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
+++ b/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
@@ -6,10 +6,6 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-
-// This test depends on std::exception_ptr which has not yet been implemented.
-// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: libcpp-has-no-threads
diff --git a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
index 713f4716c76..dca493382ba 100644
--- a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
+++ b/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// This test depends on std::exception_ptr which has not yet been implemented.
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp
index ec5575d072c..6338c8aaa26 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <exception>
// class nested_exception;
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
index 92134c993af..4cbdbb2ec89 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <exception>
// class nested_exception;
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
index 8f8503b254d..18ca9968ff5 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <exception>
// class nested_exception;
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
index fe9cd6042ba..88e2253d08c 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -7,10 +7,11 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
+// UNSUPPORTED: libcpp-no-exceptions
+
+// This test fails due to a stack overflow
// XFAIL: LIBCXX-WINDOWS-FIXME
-// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// class nested_exception;
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
index 73d02da3933..d511a72f9f5 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// UNSUPPORTED: libcpp-no-exceptions
// <exception>
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
index 6353afcb239..6a9f25cd085 100644
--- a/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// UNSUPPORTED: libcpp-no-exceptions
// <exception>
diff --git a/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
index 2046997774a..c33d64d06f0 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -7,7 +7,8 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
+// This test needs to be rewritten for the Windows exception_ptr semantics
+// which copy the exception each time the exception_ptr is copied.
// XFAIL: LIBCXX-WINDOWS-FIXME
// UNSUPPORTED: libcpp-no-exceptions
diff --git a/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
index 9621a736036..3aa8dcf55bb 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// <exception>
// typedef unspecified exception_ptr;
diff --git a/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
index 4980c656b2b..35821d9bd1b 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// UNSUPPORTED: libcpp-no-exceptions
// <exception>
@@ -41,7 +38,12 @@ int main()
}
catch (const A& a)
{
+#ifndef _LIBCPP_ABI_MICROSOFT
assert(A::constructed == 1);
+#else
+ // On Windows exception_ptr copies the exception
+ assert(A::constructed == 2);
+#endif
assert(p != nullptr);
p = nullptr;
assert(p == nullptr);
@@ -50,4 +52,5 @@ int main()
}
assert(A::constructed == 0);
}
+ assert(A::constructed == 0);
}
diff --git a/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
index 7d27eee6689..37ffb5be506 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// exception_ptr has not been implemented on Windows
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
// UNSUPPORTED: libcpp-no-exceptions
// <exception>
@@ -49,7 +46,12 @@ int main()
}
catch (const A& a)
{
+#ifndef _LIBCPP_ABI_MICROSOFT
assert(A::constructed == 1);
+#else
+ // On Windows the exception_ptr copies the exception
+ assert(A::constructed == 2);
+#endif
assert(p != nullptr);
p = nullptr;
assert(p == nullptr);
@@ -58,4 +60,5 @@ int main()
}
assert(A::constructed == 0);
}
+ assert(A::constructed == 0);
}
OpenPOWER on IntegriCloud