Skip to content

Commit caf5548

Browse files
committed
[libc++] Introduce __debug_db_insert_i()
Introduce `__debug_db_insert_i()` Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D117410
1 parent 0e03c62 commit caf5548

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

libcxx/include/__debug

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
279279
#endif
280280
}
281281

282+
template <class _Tp>
283+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
284+
#if _LIBCPP_DEBUG_LEVEL == 2
285+
if (!__libcpp_is_constant_evaluated())
286+
__get_db()->__insert_i(__i);
287+
#else
288+
(void)(__i);
289+
#endif
290+
}
291+
282292
_LIBCPP_END_NAMESPACE_STD
283293

284294
#endif // _LIBCPP_DEBUG_H

libcxx/include/__hash_table

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ public:
288288
typedef typename _NodeTypes::__node_value_type_pointer pointer;
289289

290290
_LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
291-
#if _LIBCPP_DEBUG_LEVEL == 2
292-
__get_db()->__insert_i(this);
293-
#endif
291+
_VSTD::__debug_db_insert_i(this);
294292
}
295293

296294
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -400,9 +398,7 @@ public:
400398

401399

402400
_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
403-
#if _LIBCPP_DEBUG_LEVEL == 2
404-
__get_db()->__insert_i(this);
405-
#endif
401+
_VSTD::__debug_db_insert_i(this);
406402
}
407403

408404
_LIBCPP_INLINE_VISIBILITY
@@ -517,9 +513,7 @@ public:
517513
typedef typename _NodeTypes::__node_value_type_pointer pointer;
518514

519515
_LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
520-
#if _LIBCPP_DEBUG_LEVEL == 2
521-
__get_db()->__insert_i(this);
522-
#endif
516+
_VSTD::__debug_db_insert_i(this);
523517
}
524518

525519
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -651,9 +645,7 @@ public:
651645

652646

653647
_LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
654-
#if _LIBCPP_DEBUG_LEVEL == 2
655-
__get_db()->__insert_i(this);
656-
#endif
648+
_VSTD::__debug_db_insert_i(this);
657649
}
658650

659651
_LIBCPP_INLINE_VISIBILITY

libcxx/include/__iterator/wrap_iter.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class __wrap_iter
4343
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT
4444
: __i()
4545
{
46-
#if _LIBCPP_DEBUG_LEVEL == 2
47-
if (!__libcpp_is_constant_evaluated())
48-
__get_db()->__insert_i(this);
49-
#endif
46+
_VSTD::__debug_db_insert_i(this);
5047
}
5148
template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
5249
__wrap_iter(const __wrap_iter<_Up>& __u,

libcxx/include/list

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ public:
319319
_LIBCPP_INLINE_VISIBILITY
320320
__list_iterator() _NOEXCEPT : __ptr_(nullptr)
321321
{
322-
#if _LIBCPP_DEBUG_LEVEL == 2
323-
__get_db()->__insert_i(this);
324-
#endif
322+
_VSTD::__debug_db_insert_i(this);
325323
}
326324

327325
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -431,9 +429,7 @@ public:
431429
_LIBCPP_INLINE_VISIBILITY
432430
__list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
433431
{
434-
#if _LIBCPP_DEBUG_LEVEL == 2
435-
__get_db()->__insert_i(this);
436-
#endif
432+
_VSTD::__debug_db_insert_i(this);
437433
}
438434
_LIBCPP_INLINE_VISIBILITY
439435
__list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT

0 commit comments

Comments
 (0)