[llvm] [libcxx] [libc++][hardening] Rework macros for enabling the hardening mode. (PR #70575)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 13:51:04 PDT 2023


================
@@ -217,33 +217,36 @@
 
 // TODO(hardening): deprecate this in LLVM 19.
 // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
-// equivalent to setting the safe mode.
+// equivalent to setting the debug-lite mode.
 #  ifdef _LIBCPP_ENABLE_ASSERTIONS
 #    if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
 #      error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
 #    endif
 #    if _LIBCPP_ENABLE_ASSERTIONS
-#      define _LIBCPP_ENABLE_SAFE_MODE 1
+#      define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEBUG_LITE
 #    endif
 #  endif
 
+// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
+// - `_LIBCPP_HARDENING_MODE_UNCHECKED`;
+// - `_LIBCPP_HARDENING_MODE_HARDENED`;
+// - `_LIBCPP_HARDENING_MODE_DEBUG_LITE`;
+// - `_LIBCPP_HARDENING_MODE_DEBUG`.
+
 // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes
-// security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with
-// `_LIBCPP_ENABLE_SAFE_MODE` and `_LIBCPP_ENABLE_DEBUG_MODE`.
+// security-critical checks that can be done with relatively little overhead in constant time.
 //
-// #define _LIBCPP_ENABLE_HARDENED_MODE 1
+// #define _LIBCPP_HARDENING_MODE_HARDENED 1
----------------
ldionne wrote:

I think this part of the documentation needs to be updated too.

https://github.com/llvm/llvm-project/pull/70575


More information about the llvm-commits mailing list