[libcxx-commits] [libcxx] [libc++][hardening] Check that `_LIBCPP_HARDENING_MODE_DEFAULT` is defined (PR #80353)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 1 14:11:56 PST 2024
https://github.com/var-const created https://github.com/llvm/llvm-project/pull/80353
If the `_LIBCPP_HARDENING_MODE_DEFAULT` macro is not defined, `_LIBCPP_HARDENING_MODE` will be considered defined but fail the check for a valid hardening mode, resulting in a slightly less understandable error (that error is really meant more to prevent users from passing incorrect values such as `0` or `1` directly rather than catching configuration issues).
>From bc75091f1807d915b933e5adae4e440adf61400b Mon Sep 17 00:00:00 2001
From: Konstantin Varlamov <varconsteq at gmail.com>
Date: Thu, 1 Feb 2024 14:02:12 -0800
Subject: [PATCH] [libc++][hardening] Check that
`_LIBCPP_HARDENING_MODE_DEFAULT` is defined
If the `_LIBCPP_HARDENING_MODE_DEFAULT` macro is not defined,
`_LIBCPP_HARDENING_MODE` will be considered defined but fail the check
for a valid hardening mode, resulting in a slightly less understandable
error (that error is really meant more to prevent users from passing
incorrect values such as `0` or `1` directly rather than catching
configuration issues).
---
libcxx/include/__config | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index d356960e9e62b..2101490c3a8c5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -325,6 +325,11 @@
// clang-format on
# ifndef _LIBCPP_HARDENING_MODE
+
+# ifndef _LIBCPP_HARDENING_MODE_DEFAULT
+# error _LIBCPP_HARDENING_MODE_DEFAULT is not defined.
+# endif
+
# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
# endif
More information about the libcxx-commits
mailing list