mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-12-02 17:06:18 +00:00
This is a start at making the libc++ test suite friendlier to the -fnoexceptions flag. Although this is not a complete solution, it does reduce the number of test failures on OS X from 467 to 128 on OS X when -fno-exceptions is enabled, and does not impact the number of failures at all when -fno-exceptions is not enabled. The bulk of this code was donated anonymously.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@177824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
06d8bf6ce2
commit
9976b5511a
@ -29,8 +29,13 @@ private:
|
|||||||
public:
|
public:
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (n > N - (ptr_ - buf_) / sizeof(value_type))
|
if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
pointer r = (T*)ptr_;
|
pointer r = (T*)ptr_;
|
||||||
ptr_ += n * sizeof(T);
|
ptr_ += n * sizeof(T);
|
||||||
return r;
|
return r;
|
||||||
|
@ -48,8 +48,13 @@ public:
|
|||||||
const_pointer address(const_reference x) const {return &x;}
|
const_pointer address(const_reference x) const {return &x;}
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (count >= throw_after)
|
if (count >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,13 @@ public:
|
|||||||
const_pointer address(const_reference x) const {return &x;}
|
const_pointer address(const_reference x) const {return &x;}
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (count >= throw_after)
|
if (count >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,13 @@ public:
|
|||||||
const_pointer address(const_reference x) const {return &x;}
|
const_pointer address(const_reference x) const {return &x;}
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (count >= throw_after)
|
if (count >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,13 @@ public:
|
|||||||
const_pointer address(const_reference x) const {return &x;}
|
const_pointer address(const_reference x) const {return &x;}
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (count >= throw_after)
|
if (count >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,13 @@ public:
|
|||||||
const_pointer address(const_reference x) const {return &x;}
|
const_pointer address(const_reference x) const {return &x;}
|
||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
if (count >= throw_after)
|
if (count >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,13 @@ public:
|
|||||||
pointer allocate(size_type n, const void* = 0)
|
pointer allocate(size_type n, const void* = 0)
|
||||||
{
|
{
|
||||||
assert(data_ >= 0);
|
assert(data_ >= 0);
|
||||||
if (time_to_throw >= throw_after)
|
if (time_to_throw >= throw_after) {
|
||||||
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
++time_to_throw;
|
++time_to_throw;
|
||||||
++alloc_count;
|
++alloc_count;
|
||||||
return (pointer)std::malloc(n * sizeof(T));
|
return (pointer)std::malloc(n * sizeof(T));
|
||||||
|
Loading…
Reference in New Issue
Block a user