[libcxx-commits] [libcxx] [libc++][hardening] Introduce a dylib function to log hardening errors. (PR #148266)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 13 15:00:01 PDT 2025
================
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LOG_ERROR
+#define _LIBCPP___LOG_ERROR
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LogErrorReason {
----------------
var-const wrote:
> I'm not sure whether we should use an enum class. IIRC there were some problems in C++03.
Would these problems be caught by our CI? I think it's green currently.
> Also, we should pin the underlying type.
Can we do it with the unscoped (pre-C++11) enum?
> Could we rename this to `__log_error_reason`?
Done, thanks.
> More generally: do we expect there to be other reasons than a hardening error?
I think the idea here is that introducing new functions into the dylib is quite painful, and since a general-purpose logging function seems useful, we might want to make it flexible in advance. I don't know of a concrete use case at the moment other than supporting the `observe` mode for hardening. I don't have any strong feelings either way. @ldionne Do you have any thoughts on this?
https://github.com/llvm/llvm-project/pull/148266
More information about the libcxx-commits
mailing list