[libcxx] mark _LIBCPP_VERBOSE_{ABORT,TRAP} nomerge#200078
Conversation
Suggested in llvm#198831 - this may increase binary size slightly (since `TRAP`s can no longer fold together), but makes attribution significantly easier.
|
Will mark ready once CI's happy |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| # define _LIBCPP_VERBOSE_ABORT(...) \ | ||
| ({ \ | ||
| decltype(::std::__use(__VA_ARGS__))(); \ | ||
| [[clang::__nomerge__]] __builtin_abort(); \ |
There was a problem hiding this comment.
TIL that we support __ prefixed+suffixed identifiers for attributes.
There was a problem hiding this comment.
Please don't modify the C++03 headers.
| [[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS | ||
| _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT; |
| void __use(const char*, ...); | ||
| # define _LIBCPP_VERBOSE_ABORT(...) (decltype(::std::__use(__VA_ARGS__))(), __builtin_abort()) | ||
| # define _LIBCPP_VERBOSE_ABORT(...) \ | ||
| ({ \ |
There was a problem hiding this comment.
I'm really not a huge fan of using statement expressions. Unfortunately I didn't manage to come up with anything similar which worked and was still a single expression.
| # define _LIBCPP_VERBOSE_ABORT(...) \ | ||
| ({ \ | ||
| decltype(::std::__use(__VA_ARGS__))(); \ | ||
| [[clang::__nomerge__]] __builtin_abort(); \ |
There was a problem hiding this comment.
| [[clang::__nomerge__]] __builtin_abort(); \ | |
| [[_Clang::__nomerge__]] __builtin_abort(); \ |
| }) | ||
| # else | ||
| # define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__) | ||
| # define _LIBCPP_VERBOSE_ABORT(...) ({ [[clang::__nomerge__]] ::std::__libcpp_verbose_abort(__VA_ARGS__); }) |
There was a problem hiding this comment.
I'm much less certain about this one, since we don't really use that much debuggability while potentially generating significantly more code.
| // The decltype is there to suppress -Wunused warnings in this configuration. | ||
| void __use(const char*, ...); | ||
| # define _LIBCPP_VERBOSE_ABORT(...) (decltype(::std::__use(__VA_ARGS__))(), __builtin_abort()) | ||
| # define _LIBCPP_VERBOSE_ABORT(...) \ |
There was a problem hiding this comment.
Actually, I'm not sure we want to change this. It's really just a fallback for old platforms.
Suggested in #198831 - this may increase binary size slightly (since
TRAPs can no longer fold together), but makes attribution significantly easier.