[libcxx-commits] [libcxx] [libc++][hardening] Rework how the assertion handler can be overridden. (PR #77883)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 12 18:00:10 PST 2024
================
@@ -69,6 +69,13 @@ if (NOT "${LIBCXX_HARDENING_MODE}" IN_LIST LIBCXX_SUPPORTED_HARDENING_MODES)
message(FATAL_ERROR
"Unsupported hardening mode: '${LIBCXX_HARDENING_MODE}'. Supported values are ${LIBCXX_SUPPORTED_HARDENING_MODES}.")
endif()
+set(LIBCXX_ASSERTION_HANDLER_FILE
+ "${CMAKE_CURRENT_SOURCE_DIR}/vendor/llvm/default_assertion_handler.in"
+ CACHE STRING
+ "Specify the path to a header that contains a custom implementation of the
+ assertion handler that gets invoked when a hardening assertion fails. If
+ provided, the contents of this header will get injected into the library code
+ and override the default assertion handler.")
----------------
var-const wrote:
@mordante After writing this, I realized that we can just as well do something like:
```cpp
#ifndef _LIBCPP_ASSERTION_HANDLER
#include "__custom_assertion_handler.h"
#endif
```
which alleviates my concern. In fact, I think both approaches have equal expressive power and are not visible to the user/vendor. I think they're very similar, but having a single header seems to be a little simpler/cleaner, so I'll give it a shot based on your suggestion.
https://github.com/llvm/llvm-project/pull/77883
More information about the libcxx-commits
mailing list