Skip to content

Commit 9bd575d

Browse files
authored
[libc++] Deprecate _LIBCPP_ENABLE_ASSERTIONS & friends (#98364)
In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated with the goal of removing them entirely in LLVM 20.
1 parent 3fe8ce3 commit 9bd575d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

libcxx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTER
784784
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
785785
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
786786

787-
# TODO(LLVM 19): Produce a deprecation warning.
788787
if (LIBCXX_ENABLE_ASSERTIONS)
788+
message(DEPRECATION "LIBCXX_ENABLE_ASSERTIONS is deprecated and will be removed in LLVM 20. Please use LIBCXX_HARDENING_MODE instead.")
789789
set(LIBCXX_HARDENING_MODE "extensive")
790790
endif()
791791
if (LIBCXX_HARDENING_MODE STREQUAL "none")

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Deprecations and Removals
8989
This decision is based on LEWGs discussion on `P3122 <https://wg21.link/P3122>` and `P3162 <https://wg21.link/P3162>`
9090
to not use ``[[nodiscard]]`` in the standard.
9191

92-
- TODO: The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the safe mode has been deprecated and setting
92+
- The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the safe mode has been deprecated and setting
9393
it triggers an error; use the ``LIBCXX_HARDENING_MODE`` CMake variable with the value ``extensive`` instead. Similarly,
9494
the ``_LIBCPP_ENABLE_ASSERTIONS`` macro has been deprecated (setting it to ``1`` still enables the extensive mode in
9595
the LLVM 19 release while also issuing a deprecation warning). See :ref:`the hardening documentation

libcxx/include/__config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
// HARDENING {
4040

41-
// TODO(hardening): deprecate this in LLVM 19.
4241
// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
43-
// equivalent to setting the extensive mode.
42+
// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
4443
# ifdef _LIBCPP_ENABLE_ASSERTIONS
44+
# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
4545
# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
4646
# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
4747
# endif

libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// HWASAN replaces TRAP with abort or error exit code.
2020
// XFAIL: hwasan
2121
// Note that GCC doesn't support `-Wno-macro-redefined`.
22-
// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1
22+
// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wno-#warnings -Wno-cpp
2323

2424
#include <cassert>
2525
#include "check_assertion.h"

0 commit comments

Comments
 (0)