Skip to content

Commit

Permalink
[libc++] NFCI: Remove the _LIBCPP_DEBUG_MODE helper macro
Browse files Browse the repository at this point in the history
It was used inconsistently and the name was pretty confusing, so we might
as well use `#if _LIBCPP_DEBUG_LEVEL == 2` consistently everywhere.
  • Loading branch information
ldionne committed Oct 2, 2020
1 parent 31e8203 commit 870827f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 0 additions & 3 deletions libcxx/include/__debug
Expand Up @@ -29,15 +29,12 @@

#if _LIBCPP_DEBUG_LEVEL == 0
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
# define _LIBCPP_DEBUG_MODE(...) ((void)0)
# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
#elif _LIBCPP_DEBUG_LEVEL == 1
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
# define _LIBCPP_DEBUG_MODE(...) ((void)0)
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#elif _LIBCPP_DEBUG_LEVEL == 2
# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
# define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#else
# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
Expand Down
24 changes: 18 additions & 6 deletions libcxx/include/__hash_table
Expand Up @@ -295,7 +295,9 @@ public:
typedef typename _NodeTypes::__node_value_type_pointer pointer;

_LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}

#if _LIBCPP_DEBUG_LEVEL == 2
Expand Down Expand Up @@ -405,14 +407,18 @@ public:


_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}

_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
_LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__iterator_copy(this, &__x);
#endif
}

#if _LIBCPP_DEBUG_LEVEL == 2
Expand Down Expand Up @@ -518,7 +524,9 @@ public:
typedef typename _NodeTypes::__node_value_type_pointer pointer;

_LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}

#if _LIBCPP_DEBUG_LEVEL == 2
Expand Down Expand Up @@ -650,7 +658,9 @@ public:


_LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__insert_i(this);
#endif
}

_LIBCPP_INLINE_VISIBILITY
Expand All @@ -659,7 +669,9 @@ public:
__bucket_(__x.__bucket_),
__bucket_count_(__x.__bucket_count_)
{
_LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
#if _LIBCPP_DEBUG_LEVEL == 2
__get_db()->__iterator_copy(this, &__x);
#endif
}

#if _LIBCPP_DEBUG_LEVEL == 2
Expand Down

0 comments on commit 870827f

Please sign in to comment.