[libcxx-commits] [PATCH] D118950: [libc++] Remove `_LIBCPP_DEBUG` and replace with `_LIBCPP_DEBUG_LEVEL`
Jordan Rupprecht via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 3 15:08:04 PST 2022
rupprecht created this revision.
rupprecht requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, sstefan1.
Herald added a project: libc++.
Herald added a reviewer: libc++.
In libc++, checking specific `_LIBCPP_DEBUG_LEVEL` levels is used everywhere except in `comp_ref_type.h`.
The definition of `std::__debug_less` doesn't need to be hidden behind the macro, we can unconditionally expose it. It will be unused by `__comp_ref_type` unless debug mode is enabled.
This was suggested in D118940 <https://reviews.llvm.org/D118940>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118950
Files:
libcxx/include/__algorithm/comp_ref_type.h
Index: libcxx/include/__algorithm/comp_ref_type.h
===================================================================
--- libcxx/include/__algorithm/comp_ref_type.h
+++ libcxx/include/__algorithm/comp_ref_type.h
@@ -10,11 +10,8 @@
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
#include <__config>
-
-#ifdef _LIBCPP_DEBUG
-# include <__debug>
-# include <__utility/declval.h>
-#endif
+#include <__debug>
+#include <__utility/declval.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -22,8 +19,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifdef _LIBCPP_DEBUG
-
template <class _Compare>
struct __debug_less
{
@@ -59,6 +54,8 @@
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
_LIBCPP_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
+ (void)__l;
+ (void)__r;
}
template <class _LHS, class _RHS>
@@ -67,13 +64,11 @@
void __do_compare_assert(long, _LHS &, _RHS &) {}
};
-#endif // _LIBCPP_DEBUG
-
template <class _Comp>
struct __comp_ref_type {
// Pass the comparator by lvalue reference. Or in debug mode, using a
// debugging wrapper that stores a reference.
-#ifndef _LIBCPP_DEBUG
+#if _LIBCPP_DEBUG_LEVEL == 0
typedef _Comp& type;
#else
typedef __debug_less<_Comp> type;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118950.405811.patch
Type: text/x-patch
Size: 1319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220203/d243c538/attachment.bin>
More information about the libcxx-commits
mailing list