summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-02-04 23:22:28 +0000
committerEric Fiselier <eric@efcs.ca>2017-02-04 23:22:28 +0000
commitb89eba01e80fa5ecbc07bee3f273e1aa79b41158 (patch)
tree54944e3a988957a0d6772d3191b7408827812afe /src
parent236b752f2bc5f6848cd0896b9082896a7d23a52a (diff)
Recommit [libcxx] Never use <cassert> within libc++
It is my opinion that libc++ should never use `<cassert>`, including in the `dylib`. This patch remove all uses of `assert` from within libc++ and replaces most of them with `_LIBCPP_ASSERT` instead. Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS` off by default, because the standard library should not be aborting user programs unless explicitly asked to. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r--src/condition_variable.cpp1
-rw-r--r--src/experimental/filesystem/path.cpp4
-rw-r--r--src/mutex.cpp7
-rw-r--r--src/system_error.cpp4
4 files changed, 5 insertions, 11 deletions
diff --git a/src/condition_variable.cpp b/src/condition_variable.cpp
index 25e66038e..3f607271b 100644
--- a/src/condition_variable.cpp
+++ b/src/condition_variable.cpp
@@ -14,7 +14,6 @@
#include "condition_variable"
#include "thread"
#include "system_error"
-#include "cassert"
_LIBCPP_BEGIN_NAMESPACE_STD
diff --git a/src/experimental/filesystem/path.cpp b/src/experimental/filesystem/path.cpp
index 96b81f7b0..daf2c2bba 100644
--- a/src/experimental/filesystem/path.cpp
+++ b/src/experimental/filesystem/path.cpp
@@ -6,11 +6,9 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#undef NDEBUG
#include "experimental/filesystem"
#include "string_view"
#include "utility"
-#include "cassert"
namespace { namespace parser
{
@@ -113,7 +111,6 @@ public:
void decrement() noexcept {
const PosPtr REnd = &Path.front() - 1;
const PosPtr RStart = getCurrentTokenStartPos() - 1;
- assert(RStart != REnd);
switch (State) {
case PS_AtEnd: {
@@ -322,7 +319,6 @@ string_view_t path::__root_path_raw() const
auto NextCh = PP.peek();
if (NextCh && *NextCh == '/') {
++PP;
- assert(PP.State == PathParser::PS_InRootDir);
return createView(__pn_.data(), &PP.RawEntry.back());
}
return PP.RawEntry;
diff --git a/src/mutex.cpp b/src/mutex.cpp
index 338b79f2f..b858e8877 100644
--- a/src/mutex.cpp
+++ b/src/mutex.cpp
@@ -11,7 +11,6 @@
#include "mutex"
#include "limits"
#include "system_error"
-#include "cassert"
#include "include/atomic_support.h"
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -45,7 +44,7 @@ mutex::unlock() _NOEXCEPT
{
int ec = __libcpp_mutex_unlock(&__m_);
(void)ec;
- assert(ec == 0);
+ _LIBCPP_ASSERT(ec == 0, "call to mutex::unlock failed");
}
// recursive_mutex
@@ -61,7 +60,7 @@ recursive_mutex::~recursive_mutex()
{
int e = __libcpp_recursive_mutex_destroy(&__m_);
(void)e;
- assert(e == 0);
+ _LIBCPP_ASSERT(e == 0, "call to ~recursive_mutex() failed");
}
void
@@ -77,7 +76,7 @@ recursive_mutex::unlock() _NOEXCEPT
{
int e = __libcpp_recursive_mutex_unlock(&__m_);
(void)e;
- assert(e == 0);
+ _LIBCPP_ASSERT(e == 0, "call to recursive_mutex::unlock() failed");
}
bool
diff --git a/src/system_error.cpp b/src/system_error.cpp
index 94114992c..cbbbb5dcd 100644
--- a/src/system_error.cpp
+++ b/src/system_error.cpp
@@ -17,9 +17,9 @@
#include "cstring"
#include "cstdio"
#include "cstdlib"
-#include "cassert"
#include "string"
#include "string.h"
+#include "__debug"
#if defined(__ANDROID__)
#include <android/api-level.h>
@@ -96,7 +96,7 @@ string do_strerror_r(int ev) {
std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
return string(buffer);
} else {
- assert(new_errno == ERANGE);
+ _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerr_r");
// FIXME maybe? 'strerror_buff_size' is likely to exceed the
// maximum error size so ERANGE shouldn't be returned.
std::abort();