[libcxx-commits] [PATCH] D154995: [libc++] Use _LIBCPP_VERBOSE_ABORT in a few remaining __throw_FOO functions

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 12 15:43:27 PDT 2023


philnik added inline comments.


================
Comment at: libcxx/src/system_error.cpp:288
 void
 __throw_system_error(int ev, const char* what_arg)
 {
----------------
ldionne wrote:
> philnik wrote:
> > Maybe we should add an overload for `std::error_code` and replace uses, so we can use `error_code::message()` for a nicer error message.
> Would you put that into the dylib? So you'd do this from uses:
> 
> ```
> if (__m_ == nullptr)
>     __throw_system_error(std::make_error_code(std::errc::operation_not_permitted), "unique_lock::lock: references null mutex");
> 
> // instead of
> 
> if (__m_ == nullptr)
>     __throw_system_error(EPERM, "unique_lock::lock: references null mutex");
> ```
> 
> and then the overload would look like this?
> 
> ```
> _LIBCPP_NORETURN void __throw_system_error(error_code const& __code, char const* __what_arg) {
> #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
>     throw system_error(__code, what_arg);
> #else
>     _LIBCPP_VERBOSE_ABORT("system_error was thrown in -fno-exceptions mode with error_code \"%s\" and message \"%s\"", __code.message(), what_arg);
> #endif
> }
> ```
Yeah, something like that. I wouldn't bother putting it in the dylib though. I don't even know why the have `__throw_system_error` in the dylib.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154995/new/

https://reviews.llvm.org/D154995



More information about the libcxx-commits mailing list