[libcxx-commits] [libcxx] f3966ea - [libc++] Make the Debug mode a configuration-time only option
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 7 13:34:05 PDT 2022
Author: Louis Dionne
Date: 2022-06-07T16:33:53-04:00
New Revision: f3966eaf869b7bdd9113ab9d5b78469eb0f5f028
URL: https://github.com/llvm/llvm-project/commit/f3966eaf869b7bdd9113ab9d5b78469eb0f5f028
DIFF: https://github.com/llvm/llvm-project/commit/f3966eaf869b7bdd9113ab9d5b78469eb0f5f028.diff
LOG: [libc++] Make the Debug mode a configuration-time only option
The debug mode has been broken pretty much ever since it was shipped
because it was possible to enable the debug mode in user code without
actually enabling it in the dylib, leading to ODR violations that
caused various kinds of failures.
This commit makes the debug mode a knob that is configured when
building the library and which can't be changed afterwards. This is
less flexible for users, however it will actually work as intended
and it will allow us, in the future, to add various kinds of checks
that do not assume the same ABI as the normal library. Furthermore,
this will make the debug mode more robust, which means that vendors
might be more tempted to support it properly, which hasn't been the
case with the current debug mode.
This patch shouldn't break any user code, except folks who are building
against a library that doesn't have the debug mode enabled and who try
to enable the debug mode in their code. Such users will get a compile-time
error explaining that this configuration isn't supported anymore.
In the future, we should further increase the granularity of the debug
mode checks so that we can cherry-pick which checks to enable, like we
do for unspecified behavior randomization.
Differential Revision: https://reviews.llvm.org/D122941
Added:
libcxx/cmake/caches/Generic-debug-mode.cmake
libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp
libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp
Modified:
libcxx/CMakeLists.txt
libcxx/cmake/caches/Apple.cmake
libcxx/docs/DesignDocs/DebugMode.rst
libcxx/docs/ReleaseNotes.rst
libcxx/docs/TestingLibcxx.rst
libcxx/docs/UsingLibcxx.rst
libcxx/include/__algorithm/comp_ref_type.h
libcxx/include/__algorithm/nth_element.h
libcxx/include/__algorithm/partial_sort.h
libcxx/include/__algorithm/shuffle.h
libcxx/include/__algorithm/sort.h
libcxx/include/__algorithm/unwrap_iter.h
libcxx/include/__assert
libcxx/include/__config
libcxx/include/__config_site.in
libcxx/include/__debug
libcxx/include/__format/buffer.h
libcxx/include/__hash_table
libcxx/include/__iterator/wrap_iter.h
libcxx/include/list
libcxx/include/locale
libcxx/include/span
libcxx/include/string
libcxx/include/unordered_map
libcxx/include/unordered_set
libcxx/include/vector
libcxx/lib/abi/CMakeLists.txt
libcxx/src/CMakeLists.txt
libcxx/test/CMakeLists.txt
libcxx/test/libcxx/algorithms/alg.modifying.operations/copy.pass.cpp
libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
libcxx/test/libcxx/algorithms/debug_less.pass.cpp
libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp
libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp
libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp
libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp
libcxx/test/libcxx/debug/containers.multithread.pass.cpp
libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp
libcxx/test/libcxx/debug/containers/string.pass.cpp
libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp
libcxx/test/libcxx/debug/extern-templates.sh.cpp
libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
libcxx/test/support/container_debug_tests.h
libcxx/utils/ci/buildkite-pipeline.yml
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/features.py
libcxx/utils/libcxx/test/params.py
Removed:
libcxx/cmake/caches/Generic-debug-iterators.cmake
libcxx/cmake/caches/Generic-no-debug.cmake
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index c36b8e61b30d1..829e414103e8d 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -68,11 +68,11 @@ option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ lib
${ENABLE_FILESYSTEM_DEFAULT})
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF)
-option(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT
- "Whether to include support for libc++'s debugging mode in the library.
- By default, this is turned on. If you turn it off and try to enable the
- debug mode when compiling a program against libc++, it will fail to link
- since the required support isn't provided in the library." ON)
+option(LIBCXX_ENABLE_DEBUG_MODE
+ "Whether to build libc++ with the debug mode enabled.
+ By default, this is turned off. Turning it on results in a
diff erent ABI (additional
+ symbols but also potentially
diff erent layouts of types), and one should not mix code
+ built against a dylib that has debug mode and code built against a regular dylib." OFF)
option(LIBCXX_ENABLE_RANDOM_DEVICE
"Whether to include support for std::random_device in the library. Disabling
this can be useful when building the library for platforms that don't have
@@ -210,6 +210,13 @@ set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros
option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site")
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
+cmake_dependent_option(LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS
+ "Whether to include the old Debug mode symbols in the compiled library. This
+ is provided for backwards compatibility since the compiled library used to
+ always contain those symbols, regardless of whether the library was built
+ with the debug mode enabled." ON
+ "LIBCXX_ABI_VERSION EQUAL 1" OFF) # Always OFF in ABI version != 1
+
# ABI Library options ---------------------------------------------------------
if (LIBCXX_TARGETING_MSVC)
set(LIBCXX_DEFAULT_ABI_LIBRARY "vcruntime")
@@ -854,6 +861,7 @@ config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
+config_define_if(LIBCXX_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE)
if (LIBCXX_ENABLE_ASSERTIONS)
config_define(1 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT)
else()
diff --git a/libcxx/cmake/caches/Apple.cmake b/libcxx/cmake/caches/Apple.cmake
index 4581d4d87b803..db567bd394b12 100644
--- a/libcxx/cmake/caches/Apple.cmake
+++ b/libcxx/cmake/caches/Apple.cmake
@@ -9,7 +9,7 @@ set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
set(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT ON CACHE BOOL "")
-set(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS ON CACHE BOOL "")
set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-debug-iterators.cmake b/libcxx/cmake/caches/Generic-debug-iterators.cmake
deleted file mode 100644
index a43f27c027060..0000000000000
--- a/libcxx/cmake/caches/Generic-debug-iterators.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-set(LIBCXX_TEST_PARAMS "debug_level=1" CACHE STRING "")
-set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git a/libcxx/cmake/caches/Generic-debug-mode.cmake b/libcxx/cmake/caches/Generic-debug-mode.cmake
new file mode 100644
index 0000000000000..1908da98b18b8
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-debug-mode.cmake
@@ -0,0 +1 @@
+set(LIBCXX_ENABLE_DEBUG_MODE ON CACHE BOOL "")
diff --git a/libcxx/cmake/caches/Generic-no-debug.cmake b/libcxx/cmake/caches/Generic-no-debug.cmake
deleted file mode 100644
index a62760fa78fd6..0000000000000
--- a/libcxx/cmake/caches/Generic-no-debug.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT OFF CACHE BOOL "")
diff --git a/libcxx/docs/DesignDocs/DebugMode.rst b/libcxx/docs/DesignDocs/DebugMode.rst
index b7922513fa91b..9d0e78e7581bd 100644
--- a/libcxx/docs/DesignDocs/DebugMode.rst
+++ b/libcxx/docs/DesignDocs/DebugMode.rst
@@ -12,35 +12,33 @@ Using the debug mode
Libc++ provides a debug mode that enables special debugging checks meant to detect
incorrect usage of the standard library. These checks are disabled by default, but
-they can be enabled using the ``_LIBCPP_DEBUG`` macro.
+they can be enabled by vendors when building the library by using ``LIBCXX_ENABLE_DEBUG_MODE``.
-Note that using the debug mode discussed in this document requires that the library
-has been compiled with support for the debug mode (see ``LIBCXX_ENABLE_DEBUG_MODE_SUPPORT``).
+Since the debug mode has ABI implications, users should compile their whole program,
+including any dependent libraries, against a Standard library configured identically
+with respect to the debug mode. In other words, they should not mix code built against
+a Standard library with the debug mode enabled with code built against a Standard library
+where the debug mode is disabled.
-Also note that while the debug mode has no effect on libc++'s ABI, it does have broad ODR
-implications. Users should compile their whole program at the same debugging level.
+Furthermore, users should not rely on a stable ABI being provided when the debug mode is
+enabled -- we reserve the right to change the ABI at any time. If you need a stable ABI
+and still want some level of hardening, you should look into enabling :ref:`assertions <assertions-mode>`
+instead.
-The various levels of checking provided by the debug mode follow.
+The debug mode provides various checks to aid application debugging.
-No debugging checks (``_LIBCPP_DEBUG`` not defined)
----------------------------------------------------
-When ``_LIBCPP_DEBUG`` is not defined, there are no debugging checks performed by
-the library. This is the default.
-
-Comparator consistency checks (``_LIBCPP_DEBUG == 1``)
-------------------------------------------------------
+Comparator consistency checks
+-----------------------------
Libc++ provides some checks for the consistency of comparators passed to algorithms. Specifically,
many algorithms such as ``binary_search``, ``merge``, ``next_permutation``, and ``sort``, wrap the
user-provided comparator to assert that `!comp(y, x)` whenever `comp(x, y)`. This can cause the
user-provided comparator to be evaluated up to twice as many times as it would be without the
debug mode, and causes the library to violate some of the Standard's complexity clauses.
-Iterator debugging checks (``_LIBCPP_DEBUG == 1``)
---------------------------------------------------
-Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging", which provides
-additional assertions about the validity of iterators used by the program.
-
-The following containers and classes support iterator debugging:
+Iterator debugging checks
+-------------------------
+The library contains various assertions to check the validity of iterators used
+by the program. The following containers and classes support iterator debugging:
- ``std::string``
- ``std::vector<T>`` (``T != bool``)
@@ -53,34 +51,11 @@ The following containers and classes support iterator debugging:
The remaining containers do not currently support iterator debugging.
Patches welcome.
-Randomizing Unspecified Behavior (``_LIBCPP_DEBUG == 1``)
----------------------------------------------------------
-This also enables the randomization of unspecified behavior, for
-example, for equal elements in ``std::sort`` or randomizing both parts of
-the partition after ``std::nth_element`` call. This effort helps you to migrate
-to potential future faster versions of these algorithms and deflake your tests
-which depend on such behavior. To fix the seed, use
-``_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED=seed`` definition.
-
-Handling Assertion Failures
-===========================
-When a debug assertion fails the assertion handler is called via the
-``std::__libcpp_debug_function`` function pointer. It is possible to override
-this function pointer using a
diff erent handler function. Libc++ provides a
-the default handler, ``std::__libcpp_abort_debug_handler``, which aborts the
-program. The handler may not return. Libc++ can be changed to use a custom
-assertion handler as follows.
-
-.. code-block:: cpp
-
- #define _LIBCPP_DEBUG 1
- #include <string>
- void my_handler(std::__libcpp_debug_info const&);
- int main(int, char**) {
- std::__libcpp_debug_function = &my_handler;
-
- std::string::iterator bad_it;
- std::string str("hello world");
- str.insert(bad_it, '!'); // causes debug assertion
- // control flow doesn't return
- }
+Randomizing unspecified behavior
+--------------------------------
+The library supports the randomization of unspecified behavior. For example, randomizing
+the relative order of equal elements in ``std::sort`` or randomizing both parts of the
+partition after calling ``std::nth_element``. This effort helps migrating to potential
+future faster versions of these algorithms that might not have the exact same behavior.
+In particular, it makes it easier to deflake tests that depend on unspecified behavior.
+A seed can be used to make such failures reproducible: use ``_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED=seed``.
diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index c21d1f9e29f77..cb4691fc8b26a 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -113,6 +113,13 @@ API Changes
- ``vector<bool>::const_reference``, ``vector<bool>::const_iterator::reference``
and ``bitset::const_reference`` are now aliases for `bool` in the unstable ABI.
+- The ``_LIBCPP_DEBUG`` macro is not supported anymore. It will be honoured until
+ LLVM 16, and then it will be an error to define that macro. To enable basic
+ assertions (previously ``_LIBCPP_DEBUG=0``), please use ``_LIBCPP_ENABLE_ASSERTIONS=1``.
+ To enable the debug mode (previously ``_LIBCPP_DEBUG=1|2``), please ensure that
+ the library has been built with support for the debug mode, and it will be
+ enabled automatically (no need to define ``_LIBCPP_DEBUG``).
+
ABI Changes
-----------
@@ -168,3 +175,7 @@ Build System Changes
configuration and isn't supported by one of the configurations in ``libcxx/test/configs``,
``libcxxabi/test/configs`` or ``libunwind/test/configs``, please move to one of those
configurations or define your own.
+
+- The ``LIBCXX_ENABLE_DEBUG_MODE_SUPPORT`` CMake configuration is not supported anymore. If you
+ were disabling support for the debug mode with that flag, please use ``LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS=OFF``
+ instead.
diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst
index b5c7ae89c0ad8..04ed5316df23a 100644
--- a/libcxx/docs/TestingLibcxx.rst
+++ b/libcxx/docs/TestingLibcxx.rst
@@ -158,13 +158,6 @@ default.
still be used to specify the path of the library to link to and run against,
respectively.
-.. option:: debug_level=<level>
-
- **Values**: 0, 1
-
- Enable the use of debug mode. Level 0 enables assertions and level 1 enables
- assertions and debugging of iterator misuse.
-
.. option:: use_sanitizer=<sanitizer name>
**Values**: Memory, MemoryWithOrigins, Address, Undefined
diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst
index 0d7e3a99028f8..1f46f0a2c3f95 100644
--- a/libcxx/docs/UsingLibcxx.rst
+++ b/libcxx/docs/UsingLibcxx.rst
@@ -214,9 +214,6 @@ Libc++ provides a number of configuration macros which can be used to enable
or disable extended libc++ behavior, including enabling "debug mode" or
thread safety annotations.
-**_LIBCPP_DEBUG**:
- See :ref:`using-debug-mode` for more information.
-
**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
This macro is used to enable -Wthread-safety annotations on libc++'s
``std::mutex`` and ``std::lock_guard``. By default, these annotations are
diff --git a/libcxx/include/__algorithm/comp_ref_type.h b/libcxx/include/__algorithm/comp_ref_type.h
index c94c9634170cb..4719871461cfe 100644
--- a/libcxx/include/__algorithm/comp_ref_type.h
+++ b/libcxx/include/__algorithm/comp_ref_type.h
@@ -68,7 +68,7 @@ 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.
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
typedef __debug_less<_Comp> type;
#else
typedef _Comp& type;
diff --git a/libcxx/include/__algorithm/nth_element.h b/libcxx/include/__algorithm/nth_element.h
index 0f9f66d3ca66f..60b9280f75f00 100644
--- a/libcxx/include/__algorithm/nth_element.h
+++ b/libcxx/include/__algorithm/nth_element.h
@@ -13,6 +13,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sort.h>
#include <__config>
+#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/partial_sort.h b/libcxx/include/__algorithm/partial_sort.h
index 8adf5b2f4f459..3870c0cc93354 100644
--- a/libcxx/include/__algorithm/partial_sort.h
+++ b/libcxx/include/__algorithm/partial_sort.h
@@ -15,6 +15,7 @@
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__config>
+#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/shuffle.h b/libcxx/include/__algorithm/shuffle.h
index 647aa3f067181..6c6ff5675dade 100644
--- a/libcxx/include/__algorithm/shuffle.h
+++ b/libcxx/include/__algorithm/shuffle.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_SHUFFLE_H
#include <__config>
+#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index b5eaf75055ff1..6b925038ded34 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -16,6 +16,7 @@
#include <__algorithm/unwrap_iter.h>
#include <__bits>
#include <__config>
+#include <__debug>
#include <__functional/operations.h>
#include <__utility/swap.h>
#include <climits>
diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h
index 2edf16b70ddc8..7261ff44a0f20 100644
--- a/libcxx/include/__algorithm/unwrap_iter.h
+++ b/libcxx/include/__algorithm/unwrap_iter.h
@@ -43,7 +43,7 @@ struct __unwrap_iter_impl {
}
};
-#if _LIBCPP_DEBUG_LEVEL < 2
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Iter>
struct __unwrap_iter_impl<_Iter, true> {
@@ -53,7 +53,7 @@ struct __unwrap_iter_impl<_Iter, true> {
}
};
-#endif // _LIBCPP_DEBUG_LEVEL < 2
+#endif // !_LIBCPP_ENABLE_DEBUG_MODE
template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index a9096d92bb888..84ddcd25b0b51 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -19,7 +19,15 @@
// This is for backwards compatibility with code that might have been enabling
// assertions through the Debug mode previously.
-#if _LIBCPP_DEBUG_LEVEL >= 1
+// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
+#if defined(_LIBCPP_DEBUG)
+# ifndef _LIBCPP_ENABLE_ASSERTIONS
+# define _LIBCPP_ENABLE_ASSERTIONS 1
+# endif
+#endif
+
+// Automatically enable assertions when the debug mode is enabled.
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE)
# ifndef _LIBCPP_ENABLE_ASSERTIONS
# define _LIBCPP_ENABLE_ASSERTIONS 1
# endif
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 31a31b1b09f80..050704c472f54 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -792,55 +792,14 @@ typedef unsigned int char32_t;
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
#endif // _LIBCPP_CXX03_LANG
-// _LIBCPP_DEBUG potential values:
-// - undefined: No assertions. This is the default.
-// - 0: Basic assertions
-// - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
-# if !defined(_LIBCPP_DEBUG)
-# define _LIBCPP_DEBUG_LEVEL 0
-# elif _LIBCPP_DEBUG == 0
-# define _LIBCPP_DEBUG_LEVEL 1
-# elif _LIBCPP_DEBUG == 1
-# define _LIBCPP_DEBUG_LEVEL 2
-# else
-# error Supported values for _LIBCPP_DEBUG are 0 and 1
-# endif
-
-# if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
-# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
-# endif
-
-# if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
-# if defined(_LIBCPP_CXX03_LANG)
-# error Support for unspecified stability is only for C++11 and higher
-# endif
-# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
- do { \
- if (!__builtin_is_constant_evaluated()) \
- _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
- } while (false)
-# else
-# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
- do { \
- } while (false)
-# endif
-
// Libc++ allows disabling extern template instantiation declarations by
// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
//
-// Furthermore, when the Debug mode is enabled, we disable extern declarations
-// when building user code because we don't want to use the functions compiled
-// in the library, which might not have had the debug mode enabled when built.
-// However, some extern declarations need to be used, because code correctness
-// depends on it (several instances in <locale>). Those special declarations
-// are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
-// even when the debug mode is enabled.
+// TODO: Remove _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is not needed
+// since the Debug mode is a configuration-time property.
#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
-#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
-# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
#else
# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
diff --git a/libcxx/include/__config_site.in b/libcxx/include/__config_site.in
index 38f654ac69f79..c615575226eaa 100644
--- a/libcxx/include/__config_site.in
+++ b/libcxx/include/__config_site.in
@@ -33,6 +33,7 @@
#cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
#cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_RANGES
#cmakedefine01 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
+#cmakedefine _LIBCPP_ENABLE_DEBUG_MODE
// __USE_MINGW_ANSI_STDIO gets redefined on MinGW
#ifdef __clang__
diff --git a/libcxx/include/__debug b/libcxx/include/__debug
index 39539af0e9185..403710600b0d6 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -18,23 +18,44 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
-# include <cstddef>
-# include <cstdio>
-# include <cstdlib>
+// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
+#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
+# error "Enabling the debug mode now requires having configured the library with support for the debug mode"
#endif
-#if _LIBCPP_DEBUG_LEVEL == 0 || _LIBCPP_DEBUG_LEVEL == 1
-# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
-#elif _LIBCPP_DEBUG_LEVEL == 2
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
+#endif
+
+// TODO: Define this as a function instead
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+# if defined(_LIBCPP_CXX03_LANG)
+# error Support for unspecified stability is only for C++11 and higher
+# endif
+# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
+ do { \
+ if (!__builtin_is_constant_evaluated()) \
+ std::shuffle(__first, __last, __libcpp_debug_randomizer()); \
+ } while (false)
+#else
+# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
+ do { \
+ } while (false)
+#endif
+
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
#else
-# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
+# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
+
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
-#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+_LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TYPE_VIS __c_node;
@@ -203,12 +224,15 @@ private:
_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY)
-#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
+_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_c(__c);
#else
@@ -218,7 +242,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_i(__i);
#else
@@ -228,7 +252,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__erase_c(__c);
#else
@@ -238,7 +262,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->swap(__lhs, __rhs);
#else
@@ -249,7 +273,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__invalidate_all(__c);
#else
diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index 55cde0044e175..d9b08064dfb30 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -119,7 +119,7 @@ class _LIBCPP_TEMPLATE_VIS __direct_storage {};
template <class _OutIt, class _CharT>
concept __enable_direct_output = __formatter::__char_type<_CharT> &&
(same_as<_OutIt, _CharT*>
-#if _LIBCPP_DEBUG_LEVEL < 2
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
|| same_as<_OutIt, __wrap_iter<_CharT*>>
#endif
);
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index eaef97a798588..be28a035e75b4 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -294,7 +294,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_iterator(const __hash_iterator& __i)
: __node_(__i.__node_)
@@ -318,7 +318,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -365,7 +365,7 @@ private:
: __node_(__node)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
}
@@ -404,12 +404,12 @@ public:
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __hash_const_iterator& __i)
: __node_(__i.__node_)
@@ -433,7 +433,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -479,7 +479,7 @@ private:
: __node_(__node)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
}
@@ -511,7 +511,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_local_iterator(const __hash_local_iterator& __i)
: __node_(__i.__node_),
@@ -539,7 +539,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -591,7 +591,7 @@ private:
__bucket_count_(__bucket_count)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
if (__node_ != nullptr)
@@ -639,12 +639,12 @@ public:
__bucket_(__x.__bucket_),
__bucket_count_(__x.__bucket_count_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator(const __hash_const_local_iterator& __i)
: __node_(__i.__node_),
@@ -672,7 +672,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -724,7 +724,7 @@ private:
__bucket_count_(__bucket_count)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
if (__node_ != nullptr)
@@ -1281,14 +1281,14 @@ public:
return const_local_iterator(nullptr, __n, bucket_count(), this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptr
diff _t __n) const;
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
void __rehash(size_type __n);
@@ -1510,7 +1510,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
while (__np != nullptr)
{
__next_pointer __next = __np->__next_;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -2480,7 +2480,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
__pn->__next_ = __cn->__next_;
__cn->__next_ = nullptr;
--size();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
{
@@ -2663,7 +2663,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
__x.swap(__y);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Hash, class _Equal, class _Alloc>
bool
@@ -2693,7 +2693,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index a3f42ca77352c..f780048754c9d 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -50,12 +50,12 @@ class __wrap_iter
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
: __i(__u.base())
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__iterator_copy(this, _VSTD::addressof(__u));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__wrap_iter(const __wrap_iter& __x)
: __i(__x.base())
@@ -139,7 +139,7 @@ class __wrap_iter
explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)
{
(void)__p;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated())
__get_db()->__insert_ic(this, __p);
#endif
diff --git a/libcxx/include/list b/libcxx/include/list
index bcca7f0c67bb6..45ccfec6f3362 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -304,7 +304,7 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator
: __ptr_(__p)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
}
@@ -325,7 +325,7 @@ public:
_VSTD::__debug_db_insert_i(this);
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__list_iterator(const __list_iterator& __p)
@@ -351,7 +351,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
@@ -413,7 +413,7 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator
: __ptr_(__p)
{
(void)__c;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__insert_ic(this, __c);
#endif
}
@@ -436,12 +436,12 @@ public:
__list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
: __ptr_(__p.__ptr_)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__get_db()->__iterator_copy(this, _VSTD::addressof(__p));
#endif
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
__list_const_iterator(const __list_const_iterator& __p)
@@ -467,7 +467,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
{
@@ -750,7 +750,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
else
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
@@ -1075,14 +1075,14 @@ public:
return __hold_pointer(__p, __node_destructor(__na, 1));
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptr
diff _t __n) const;
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1624,7 +1624,7 @@ list<_Tp, _Alloc>::pop_front()
__link_pointer __n = base::__end_.__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1653,7 +1653,7 @@ list<_Tp, _Alloc>::pop_back()
__link_pointer __n = base::__end_.__prev_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1686,7 +1686,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
__link_pointer __r = __n->__next_;
base::__unlink_nodes(__n, __n);
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
{
@@ -1724,7 +1724,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
__link_pointer __n = __f.__ptr_;
++__f;
--base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
@@ -1862,7 +1862,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__link_nodes(__p.__ptr_, __f, __l);
base::__sz() += __c.__sz();
__c.__sz() = 0;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -1903,7 +1903,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
__link_nodes(__p.__ptr_, __f, __f);
--__c.__sz();
++base::__sz();
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -1964,7 +1964,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
}
base::__unlink_nodes(__first, __last);
__link_nodes(__p.__ptr_, __first, __last);
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (_VSTD::addressof(__c) != this) {
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -2101,7 +2101,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
++__f1;
}
splice(__e1, __c);
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c));
@@ -2225,7 +2225,7 @@ list<_Tp, _Alloc>::__invariants() const
return size() == _VSTD::distance(begin(), end());
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Alloc>
bool
@@ -2255,7 +2255,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptr
diff _t) const
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/locale b/libcxx/include/locale
index 3bed47c071e5b..c350605d981cf 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -1461,7 +1461,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return do_put(__s, __iob, __fl, (unsigned long)__v);
const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
typedef typename numpunct<char_type>::string_type string_type;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
string_type __tmp(__v ? __np.truename() : __np.falsename());
string_type __nm = _VSTD::move(__tmp);
#else
diff --git a/libcxx/include/span b/libcxx/include/span
index e65af7971e5f2..38b2ae1cb157b 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -197,7 +197,7 @@ concept __span_compatible_range =
is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
+#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
# define _LIBCPP_SPAN_USE_POINTER_ITERATOR
#endif
diff --git a/libcxx/include/string b/libcxx/include/string
index 86370e5260a5b..65ce145346c12 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1450,14 +1450,14 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptr
diff _t __n) const;
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
template<class _Alloc>
@@ -1840,7 +1840,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
{
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
if (!__libcpp_is_constant_evaluated()) {
__c_node* __c = __get_db()->__find_c_and_lock(this);
if (__c)
@@ -1862,7 +1862,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
}
#else
(void)__pos;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
}
template <class _CharT, class _Traits, class _Allocator>
@@ -4595,7 +4595,7 @@ inline _LIBCPP_HIDE_FROM_ABI
}
#endif
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template<class _CharT, class _Traits, class _Allocator>
bool
@@ -4629,7 +4629,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
return data() <= __p && __p < data() + size();
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
#if _LIBCPP_STD_VER > 11
// Literal suffixes for basic_string [basic.string.literals]
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 16b843b944aef..c1cd7f48d1d60 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -1512,7 +1512,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
@@ -1523,7 +1523,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const
{return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
@@ -2288,7 +2288,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
@@ -2299,7 +2299,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const
{return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index 890475f36f7a8..a74116d1689d7 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -843,7 +843,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -854,7 +854,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
@@ -1481,7 +1481,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const
{return __table_.__dereferenceable(__i);}
@@ -1492,7 +1492,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
};
diff --git a/libcxx/include/vector b/libcxx/include/vector
index e522c1a842bde..19c634927de6d 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -634,14 +634,14 @@ public:
bool __invariants() const;
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptr
diff _t __n) const;
bool __subscriptable(const const_iterator* __i, ptr
diff _t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
pointer __begin_ = nullptr;
@@ -1898,7 +1898,7 @@ vector<_Tp, _Allocator>::__invariants() const
return true;
}
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Allocator>
bool
@@ -1930,13 +1930,13 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptr
diff _t __
return this->__begin_ <= __p && __p < this->__end_;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_ENABLE_DEBUG_MODE
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
-#if _LIBCPP_DEBUG_LEVEL == 2
+#ifdef _LIBCPP_ENABLE_DEBUG_MODE
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
--__p;
diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index a06678a8eece2..e0f52c628cc3b 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -55,6 +55,11 @@ if (CMAKE_CXX_COMPILER_TARGET)
else()
set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
endif()
+if (LIBCXX_ENABLE_DEBUG_MODE OR LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS)
+ set(has_debug_symbols ON)
+else()
+ set(has_debug_symbols OFF)
+endif()
cxx_abi_list_identifier(abi_list_identifier
"${triple}"
"${LIBCXX_CXX_ABI}"
@@ -62,7 +67,7 @@ cxx_abi_list_identifier(abi_list_identifier
"${LIBCXX_ABI_UNSTABLE}"
"${LIBCXX_ENABLE_EXCEPTIONS}"
"${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"
- "${LIBCXX_ENABLE_DEBUG_MODE_SUPPORT}"
+ "${has_debug_symbols}"
"${LIBCXX_ENABLE_INCOMPLETE_FEATURES}"
)
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 570464f08c9ee..d3034999c392f 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -64,7 +64,7 @@ set(LIBCXX_SOURCES
vector.cpp
)
-if (LIBCXX_ENABLE_DEBUG_MODE_SUPPORT)
+if (LIBCXX_ENABLE_DEBUG_MODE OR LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS)
list(APPEND LIBCXX_SOURCES
debug.cpp
legacy_debug_handler.cpp
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 6a398e4afbec8..b85f726fd1c02 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -101,10 +101,6 @@ if (NOT LIBCXX_ENABLE_RTTI)
serialize_lit_param(enable_rtti False)
endif()
-if (NOT LIBCXX_ENABLE_DEBUG_MODE_SUPPORT)
- serialize_lit_param(enable_debug_tests False)
-endif()
-
if (LIBCXX_ENABLE_ASSERTIONS)
serialize_lit_param(enable_assertions True)
endif()
diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy.pass.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy.pass.cpp
index b710f5aa6a53e..eddf8bec3ca2b 100644
--- a/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/copy.pass.cpp
@@ -7,7 +7,10 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: debug_level=1
+
+// When the debug mode is enabled, we don't unwrap iterators in std::copy
+// so we don't get this optimization.
+// UNSUPPORTED: libcpp-has-debug-mode
// <algorithm>
@@ -59,7 +62,9 @@ struct NotIncrementableIt {
return *this;
}
- friend constexpr NotIncrementableIt operator+(const NotIncrementableIt& it, ptr
diff _t size) { return it.i + size; }
+ friend constexpr NotIncrementableIt operator+(const NotIncrementableIt& it,
diff erence_type size) { return it.i + size; }
+ friend constexpr
diff erence_type operator-(const NotIncrementableIt& x, const NotIncrementableIt& y) { return x.i - y.i; }
+ friend constexpr NotIncrementableIt operator-(const NotIncrementableIt& x,
diff erence_type size) { return NotIncrementableIt(x.i - size); }
};
static_assert(std::__is_cpp17_contiguous_iterator<NotIncrementableIt<S>>::value);
diff --git a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
index fcabbb9f74a24..a878508f63d3c 100644
--- a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
@@ -64,7 +64,7 @@ int main(int, char**)
std::make_heap(v.begin(), v.end());
assert(stats.copied == 0);
assert(stats.moved == 153'486);
-#ifndef _LIBCPP_DEBUG
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
assert(stats.compared == 188'285);
#endif
diff --git a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
index dbf808a0b8502..0ed37a2b920e9 100644
--- a/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
@@ -65,7 +65,7 @@ int main(int, char**)
std::sort_heap(v.begin(), v.end());
assert(stats.copied == 0);
assert(stats.moved == 1'764'997);
-#ifndef _LIBCPP_DEBUG
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
assert(stats.compared == 1'534'701);
#endif
diff --git a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
index 6d1e96a8ad908..4f7d4793949d0 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
@@ -13,8 +13,7 @@
// Make sure __debug_less asserts when the comparator is not consistent.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <algorithm>
#include <iterator>
diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
index 6caad3ad1176b..89f12e5aa0cd3 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
@@ -13,8 +13,7 @@
// __debug_less checks that a comparator actually provides a strict-weak ordering.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <algorithm>
#include <cassert>
diff --git a/libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp b/libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
index 2383f8390bce2..4913a7085bf6f 100644
--- a/libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
@@ -10,8 +10,8 @@
// Test std::nth_element stability randomization
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#include <algorithm>
#include <array>
diff --git a/libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp b/libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
index 674cb30ee8e92..8aa91bd551c1c 100644
--- a/libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
@@ -10,8 +10,8 @@
// Test std::partial_sort stability randomization
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#include <algorithm>
#include <array>
diff --git a/libcxx/test/libcxx/algorithms/sort_stability.pass.cpp b/libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
index 8b3ec2b686524..664ea708a6ec8 100644
--- a/libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
@@ -10,8 +10,8 @@
// Test std::sort stability randomization
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#include <algorithm>
#include <array>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp
index 518d44df91a07..d4442048312dc 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp
@@ -11,8 +11,7 @@
// list(list&& c);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp
index ab2b2576d2976..ce1eb674f97fc 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp
@@ -11,8 +11,7 @@
// template <class... Args> void emplace(const_iterator p, Args&&... args);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp
index 843dcfff37dfd..f389ef4fab2d8 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with iterator from another container
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp
index 583dfa1fc201d..78b8b09453f7c 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with various invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp
index 218a964b79d5d..7cf1c5d71cffc 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp
@@ -12,8 +12,7 @@
// iterator insert(const_iterator position, Iter first, Iter last);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp
index 880cbcf71ee07..71ba4e5b265c6 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator position, value_type&& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp
index bc791b9ddc290..e3907fa2e6b1a 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator position, size_type n, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp
index 363c5c1a806eb..ce260c640a45f 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator position, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp
index 0ced467aa77bf..6d3fb65d9245f 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp
@@ -11,8 +11,7 @@
// void splice(const_iterator position, list& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp
index c9163a4652c90..6ac7a6950aa71 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp
@@ -11,8 +11,7 @@
// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp
index 1f7a523fa5595..ec318f457c393 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// void splice(const_iterator position, list& x, iterator first, iterator last);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <list>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp
index 929be18b441fe..9e80a7ee0ee7e 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp
@@ -11,8 +11,7 @@
// Add to iterator out of bounds.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp
index b59f095d8ce77..669c34989a4a7 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp
@@ -11,8 +11,7 @@
// Compare iterators from
diff erent containers with <.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp
index f84776434a23d..c7f65d1efa5a2 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp
@@ -11,8 +11,7 @@
// Decrement iterator prior to begin.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp
index 203656fecb849..e421e554b8789 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp
index b950aa20527d9..83dcce12625b3 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp
index 409002d31fe4d..ff43d0816526e 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp
@@ -11,8 +11,7 @@
// Index iterator out of bounds.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp
index 5378de0b07c4a..a5b35cef4fbc4 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp
@@ -11,8 +11,7 @@
// Subtract iterators from
diff erent containers.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <vector>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp
index 8317c9f058960..a3fe4110dd1c3 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp
index af78854b7beef..4646ff59784b0 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp
@@ -13,8 +13,7 @@
// iterator insert(const_iterator p, P&& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp
index 3427758f6256e..f08f5b13dc6e2 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <string>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp
index 91e6f7eb88180..bb2055f5656d1 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp
index c38082c1c9eae..1a5a93c2239e5 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <string>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp
index 15dfca6d95ea2..6b33131e8a006 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment local_iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <string>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp
index 012b5458dfecb..c639b92358f6a 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp
@@ -15,8 +15,7 @@
// void swap(unordered_map& x, unordered_map& y);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp
index 3a9318f8c993c..d106dea764ae0 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp
index f5f3e6b99998b..5035aabf9fed3 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp
index 1ba4b3009e073..ce3b3dde2e324 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp
index 3895c4ea57333..5a242424f7df0 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp
@@ -13,8 +13,7 @@
// iterator insert(const_iterator p, P&& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp
index b5a869dc9b3fe..05990a03843b1 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp
index bd8a5affd592b..f84726ecfc516 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp
index bf8ebc9bc6a0f..d1d6e379bfeda 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <string>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp
index 2df1eb2472480..2a9732826c36d 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment local_iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp
index 2ea194678f3e8..29efbe225135e 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp
@@ -15,8 +15,7 @@
// void swap(unordered_multimap& x, unordered_multimap& y);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp
index 31d96168cfcfc..1b29719ed3622 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp
index 89142fa6d4140..85879e074d77a 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_map>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp
index 190d085ae886e..7d477e3d6cdd2 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp
index 921bc16bb60f4..f229b9925362c 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp
index 7337f02b49487..50e0d8a1d628c 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp
index 0557e50f6b6d1..a7fdff7c47927 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp
index a1e6d9a7e1190..9ca0d4a5157f9 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp
index efe486a43ca8f..0b4bc9e4b6a73 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp
index 6e2df71d82eb7..8f82dfbba2d8c 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment local_iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp
index c66b46065b6e4..476eb594ccf0f 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp
@@ -15,8 +15,7 @@
// void swap(unordered_multiset& x, unordered_multiset& y);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp
index 6bae7421223f6..1f3f5ad19cc0d 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp
index 0fa5d7be68dae..542d38298a873 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp
index ef4488373271c..b452a8d23cb85 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, const value_type& x);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp
index 64011f505a978..2e8c0c27801b8 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp
index e8da843b93618..a858aa8b35def 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp
index 5043a89419f22..30582d92598c0 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp
index e1042d3a11880..022b66eeb6219 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment local_iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
#include <cassert>
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp
index 4d721997bb2f0..afcaded19073d 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp
@@ -15,8 +15,7 @@
// void swap(unordered_set& x, unordered_set& y);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <unordered_set>
diff --git a/libcxx/test/libcxx/debug/containers.multithread.pass.cpp b/libcxx/test/libcxx/debug/containers.multithread.pass.cpp
index e8f87b1d20d75..a389c31b2142e 100644
--- a/libcxx/test/libcxx/debug/containers.multithread.pass.cpp
+++ b/libcxx/test/libcxx/debug/containers.multithread.pass.cpp
@@ -9,8 +9,7 @@
// UNSUPPORTED: c++11, c++14
// UNSUPPORTED: no-threads
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
// test multithreaded container debugging
diff --git a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
index 8a07efe237f51..00471ceb617a6 100644
--- a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
+++ b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
@@ -7,8 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, c++11, c++14
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03, c++11, c++14
// test container debugging
diff --git a/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp b/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp
index e98c18b29e3dd..c9a9fbcb33b5a 100644
--- a/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp
+++ b/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp
@@ -7,8 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, c++11, c++14
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03, c++11, c++14
// test container debugging
diff --git a/libcxx/test/libcxx/debug/containers/string.pass.cpp b/libcxx/test/libcxx/debug/containers/string.pass.cpp
index ba54643b6da45..fc6cc42febeef 100644
--- a/libcxx/test/libcxx/debug/containers/string.pass.cpp
+++ b/libcxx/test/libcxx/debug/containers/string.pass.cpp
@@ -7,8 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, c++11, c++14
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03, c++11, c++14
// test container debugging
diff --git a/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp b/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp
index 70a6e92113570..19a21241a5c61 100644
--- a/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp
+++ b/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp
@@ -7,8 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03, c++11, c++14
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03, c++11, c++14
// test container debugging
diff --git a/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp b/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp
new file mode 100644
index 0000000000000..037805b126115
--- /dev/null
+++ b/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This test ensures that assertions are enabled by default when the debug mode is enabled.
+
+// REQUIRES: libcpp-has-debug-mode
+
+#include <version>
+
+#if !defined(_LIBCPP_ENABLE_ASSERTIONS) || _LIBCPP_ENABLE_ASSERTIONS == 0
+# error "Assertions should be enabled automatically when the debug mode is enabled"
+#endif
diff --git a/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp b/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp
new file mode 100644
index 0000000000000..ac265c99ced68
--- /dev/null
+++ b/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This test ensures that we issue an error if we try to enable the debug mode with
+// a library that was not built with support for the debug mode.
+
+// REQUIRES: !libcpp-has-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// This test fails when modules are enabled because we fail to build module 'std' instead of
+// issuing the preprocessor error.
+// UNSUPPORTED: modules-build
+
+#include <__debug>
+
+// expected-error@*:* {{Enabling the debug mode now requires having configured the library with support for the debug mode}}
diff --git a/libcxx/test/libcxx/debug/extern-templates.sh.cpp b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
index 774f675a785ae..612da5e0f0f1a 100644
--- a/libcxx/test/libcxx/debug/extern-templates.sh.cpp
+++ b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
@@ -10,7 +10,7 @@
// for members of <locale> even when the debug mode is enabled, which is
// necessary for correctness. See https://llvm.org/D94718 for details.
-// UNSUPPORTED: libcxx-no-debug-mode
+// UNSUPPORTED: !libcpp-has-debug-mode
// UNSUPPORTED: no-localization
// UNSUPPORTED: cant-build-shared-library
@@ -23,8 +23,8 @@
// XFAIL: LIBCXX-AIX-FIXME
-// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -D_LIBCPP_DEBUG=1 -fvisibility=hidden -shared -o %t.lib
-// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -D_LIBCPP_DEBUG=1 -fvisibility=hidden -o %t.exe
+// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -fvisibility=hidden -shared -o %t.lib
+// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -fvisibility=hidden -o %t.exe
// RUN: %{exec} %t.exe
#include <cassert>
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
index f1f81c6bbd075..af767d087d0a3 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03, c++11, c++14, c++17, libcxx-no-debug-mode, libcpp-has-no-incomplete-ranges
+// UNSUPPORTED: c++03, c++11, c++14, c++17, !libcpp-has-debug-mode, libcpp-has-no-incomplete-ranges
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
// <ranges>
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
index 4907d3cb13838..5ea72a84b6bb4 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
// REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03, c++11, c++14, c++17, libcxx-no-debug-mode, libcpp-has-no-incomplete-ranges
+// UNSUPPORTED: c++03, c++11, c++14, c++17, !libcpp-has-debug-mode, libcpp-has-no-incomplete-ranges
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
// <ranges>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
index 53c1613e3e662..6d97ea1a0d282 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
@@ -11,8 +11,7 @@
// Add to iterator out of bounds.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
#include <cassert>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
index c34e3fdef6722..025cd18aabd55 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
@@ -11,8 +11,7 @@
// Compare iterators from
diff erent containers with <.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
index b36bbffd8ea18..548a62b0fc232 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
@@ -11,8 +11,7 @@
// Decrement iterator prior to begin.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
#include <cassert>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
index 6a9e7d6fdd773..fccf98c76384e 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
@@ -11,8 +11,7 @@
// Dereference non-dereferenceable iterator.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
index 96f6002a3c603..73366f26e6190 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
@@ -11,8 +11,7 @@
// Increment iterator past end.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
#include <cassert>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
index 9528f5184fe45..f1b4e5666569b 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
@@ -11,8 +11,7 @@
// Index iterator out of bounds.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
#include <cassert>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
index 4cf6bccc91cd7..74b4048d9e2f2 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
@@ -11,8 +11,7 @@
// Subtract iterators from
diff erent containers.
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
index 07b2537fcfd96..1844dd3149275 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator position) with an iterator from another container
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
index 0606f125d5402..8afe65b39d925 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
@@ -11,8 +11,7 @@
// Call erase(const_iterator first, const_iterator last); with invalid iterators
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
index 4decaa40510f1..7e0e236dfb79a 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, charT c);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
// TODO: Since string::insert(iter, char) is intantiated in the dylib, this test doesn't
// actually work if the dylib hasn't been built with debug assertions enabled.
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
index a95fa8cfcac00..0bd4b43752d06 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
@@ -12,8 +12,7 @@
// iterator insert(const_iterator p, InputIterator first, InputIterator last);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
index d251dfc396930..0f4d087781af1 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
@@ -11,8 +11,7 @@
// iterator insert(const_iterator p, size_type n, charT c);
// REQUIRES: has-unix-headers
-// UNSUPPORTED: libcxx-no-debug-mode, c++03
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: !libcpp-has-debug-mode, c++03
#include <string>
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
index 17115686b6a26..0d572fc57f9bf 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -79,7 +79,7 @@ test_one(unsigned N, unsigned M)
assert(ia[0] == static_cast<int>(N)-1);
assert(ia[N-1] == 0);
assert(std::is_sorted(ia, ia+N, std::greater<value_type>()));
-#ifndef _LIBCPP_DEBUG
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
assert(pred.count() <= (N-1));
#endif
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
index 5555e1157c2b2..b1341ee8325d8 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: LIBCXX-DEBUG-FIXME
-
// UNSUPPORTED: c++03
// <filesystem>
diff --git a/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp b/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
index 504ebc3dbeabc..6a6846b6b355e 100644
--- a/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
@@ -9,11 +9,6 @@
// UNSUPPORTED: no-localization
// UNSUPPORTED: libcpp-has-no-incomplete-format
-// The issue is caused in __format_spec::__determine_grouping().
-// There a string iterator is modified. The string is returned
-// from the dylib's use_facet<numpunct<_CharT>>::grouping()
-// XFAIL: LIBCXX-DEBUG-FIXME
-
// TODO FMT Evaluate gcc-11 status
// UNSUPPORTED: gcc-11
diff --git a/libcxx/test/support/container_debug_tests.h b/libcxx/test/support/container_debug_tests.h
index fc0d60f86d0f2..0a11ac881ddac 100644
--- a/libcxx/test/support/container_debug_tests.h
+++ b/libcxx/test/support/container_debug_tests.h
@@ -14,8 +14,8 @@
#error This header may only be used for libc++ tests
#endif
-#ifndef _LIBCPP_DEBUG
-#error _LIBCPP_DEBUG must be defined before including this header
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
+#error The library must be built with the debug mode enabled in order to use this header
#endif
#include <__debug>
diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index d3db1e125c5cb..94047508e7c39 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -379,8 +379,8 @@ steps:
limit: 2
timeout_in_minutes: 120
- - label: "Debug iterators"
- command: "libcxx/utils/ci/run-buildbot generic-debug-iterators"
+ - label: "Debug mode"
+ command: "libcxx/utils/ci/run-buildbot generic-debug-mode"
artifact_paths:
- "**/test-results.xml"
- "**/*.abilist"
@@ -423,20 +423,6 @@ steps:
limit: 2
timeout_in_minutes: 120
- - label: "No debug mode"
- command: "libcxx/utils/ci/run-buildbot generic-no-debug"
- artifact_paths:
- - "**/test-results.xml"
- - "**/*.abilist"
- agents:
- queue: "libcxx-builders"
- os: "linux"
- retry:
- automatic:
- - exit_status: -1 # Agent was lost
- limit: 2
- timeout_in_minutes: 120
-
- label: "No filesystem"
command: "libcxx/utils/ci/run-buildbot generic-no-filesystem"
artifact_paths:
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 49cfde466835b..2e4d9b5bea7ba 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -233,9 +233,9 @@ generic-assertions)
check-runtimes
check-abi-list
;;
-generic-debug-iterators)
+generic-debug-mode)
clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug-iterators.cmake"
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug-mode.cmake"
check-runtimes
check-abi-list
;;
@@ -329,12 +329,6 @@ generic-no-threads)
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"
check-runtimes
;;
-generic-no-debug)
- clean
- generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-debug.cmake"
- check-runtimes
- check-abi-list
-;;
generic-no-filesystem)
clean
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 20fdbe9bba449..d7e4c849a0fc7 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -191,6 +191,7 @@ def _hasSuitableClangTidy(cfg):
'_LIBCPP_HAS_NO_INCOMPLETE_FORMAT': 'libcpp-has-no-incomplete-format',
'_LIBCPP_HAS_NO_INCOMPLETE_RANGES': 'libcpp-has-no-incomplete-ranges',
'_LIBCPP_HAS_NO_UNICODE': 'libcpp-has-no-unicode',
+ '_LIBCPP_ENABLE_DEBUG_MODE': 'libcpp-has-debug-mode',
}
for macro, feature in macros.items():
DEFAULT_FEATURES.append(
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 2c18aba41af63..2f537f1f2d94b 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -126,15 +126,6 @@ def getStdFlag(cfg, std):
[AddCompileFlag('-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER')]
),
- Parameter(name='debug_level', choices=['', '0', '1'], type=str, default='',
- help="The debugging level to enable in the test suite.",
- actions=lambda debugLevel: [] if debugLevel == '' else filter(None, [
- AddFeature('debug_level={}'.format(debugLevel)),
- AddCompileFlag('-Wno-macro-redefined'),
- AddCompileFlag('-D_LIBCPP_DEBUG={}'.format(debugLevel)),
- AddFeature('LIBCXX-DEBUG-FIXME') if debugLevel == '1' else None
- ])),
-
Parameter(name='use_sanitizer', choices=['', 'Address', 'Undefined', 'Memory', 'MemoryWithOrigins', 'Thread', 'DataFlow', 'Leaks'], type=str, default='',
help="An optional sanitizer to enable when building and running the test suite.",
actions=lambda sanitizer: filter(None, [
@@ -177,12 +168,6 @@ def getStdFlag(cfg, std):
AddFeature('long_tests')
]),
- Parameter(name='enable_debug_tests', choices=[True, False], type=bool, default=True,
- help="Whether to enable tests that exercise the libc++ debugging mode.",
- actions=lambda enabled: [] if enabled else [
- AddFeature('libcxx-no-debug-mode')
- ]),
-
Parameter(name='enable_assertions', choices=[True, False], type=bool, default=False,
help="Whether to enable assertions when compiling the test suite. This is only meaningful when "
"running the tests against libc++.",
More information about the libcxx-commits
mailing list