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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 12 15:40:58 PDT 2023


ldionne marked an inline comment as done.
ldionne added inline comments.


================
Comment at: libcxx/src/system_error.cpp:288
 void
 __throw_system_error(int ev, const char* what_arg)
 {
----------------
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
}
```


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