Skip to content

Commit 748023d

Browse files
authored
[libc++][NFC] Replace _LIBCPP_NORETURN and TEST_NORETURN with [[noreturn]] (llvm#80455)
`[[__noreturn__]]` is now always available, so we can simply use the attribute directly instead of through a macro.
1 parent cd0e867 commit 748023d

39 files changed

+69
-79
lines changed

libcxx/.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ AttributeMacros: [
4444
'_LIBCPP_NO_UNIQUE_ADDRESS',
4545
'_LIBCPP_NOALIAS',
4646
'_LIBCPP_NODISCARD',
47-
'_LIBCPP_NORETURN',
4847
'_LIBCPP_OVERRIDABLE_FUNC_VIS',
4948
'_LIBCPP_STANDALONE_DEBUG',
5049
'_LIBCPP_TEMPLATE_DATA_VIS',

libcxx/include/__chrono/exception.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class nonexistent_local_time : public runtime_error {
7171
};
7272

7373
template <class _Duration>
74-
_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
74+
[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
7575
[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
7676
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
7777
throw nonexistent_local_time(__time, __info);
@@ -115,7 +115,7 @@ class ambiguous_local_time : public runtime_error {
115115
};
116116

117117
template <class _Duration>
118-
_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(
118+
[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(
119119
[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
120120
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
121121
throw ambiguous_local_time(__time, __info);

libcxx/include/__config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
312312
# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
313313
# define _ALIGNAS_TYPE(x) alignas(x)
314314
# define _ALIGNAS(x) alignas(x)
315-
# define _LIBCPP_NORETURN [[noreturn]]
316315
# define _NOEXCEPT noexcept
317316
# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
318317
# define _LIBCPP_CONSTEXPR constexpr
@@ -322,7 +321,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
322321
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
323322
# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
324323
# define _ALIGNAS(x) __attribute__((__aligned__(x)))
325-
# define _LIBCPP_NORETURN __attribute__((__noreturn__))
326324
# define _LIBCPP_HAS_NO_NOEXCEPT
327325
# define nullptr __nullptr
328326
# define _NOEXCEPT throw()

libcxx/include/__exception/exception_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ _LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
159159

160160
_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr);
161161
_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
162-
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
162+
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
163163

164164
// This is a built-in template function which automagically extracts the required
165165
// information.

libcxx/include/__exception/nested_exception.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _LIBCPP_EXPORTED_FROM_ABI nested_exception {
4040
virtual ~nested_exception() _NOEXCEPT;
4141

4242
// access functions
43-
_LIBCPP_NORETURN void rethrow_nested() const;
43+
[[__noreturn__]] void rethrow_nested() const;
4444
_LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; }
4545
};
4646

@@ -55,19 +55,19 @@ struct __throw_with_nested;
5555

5656
template <class _Tp, class _Up>
5757
struct __throw_with_nested<_Tp, _Up, true> {
58-
_LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) {
58+
[[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) {
5959
throw __nested<_Up>(std::forward<_Tp>(__t));
6060
}
6161
};
6262

6363
template <class _Tp, class _Up>
6464
struct __throw_with_nested<_Tp, _Up, false> {
65-
_LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); }
65+
[[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); }
6666
};
6767
#endif
6868

6969
template <class _Tp>
70-
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) {
70+
[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) {
7171
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
7272
using _Up = __decay_t<_Tp>;
7373
static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible");

libcxx/include/__exception/operations.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace std { // purposefully not using versioning namespace
2222
using unexpected_handler = void (*)();
2323
_LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
2424
_LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT;
25-
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void unexpected();
25+
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected();
2626
#endif
2727

2828
using terminate_handler = void (*)();
@@ -37,7 +37,7 @@ _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT;
3737
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
3838

3939
_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
40-
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
40+
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
4141
} // namespace std
4242

4343
#endif // _LIBCPP___EXCEPTION_OPERATIONS_H

libcxx/include/__exception/terminate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#endif
1717

1818
namespace std { // purposefully not using versioning namespace
19-
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;
19+
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;
2020
} // namespace std
2121

2222
#endif // _LIBCPP___EXCEPTION_TERMINATE_H

libcxx/include/__filesystem/filesystem_error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesyst
6969

7070
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
7171
template <class... _Args>
72-
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
72+
[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
7373
__throw_filesystem_error(_Args&&... __args) {
7474
throw filesystem_error(std::forward<_Args>(__args)...);
7575
}
7676
# else
7777
template <class... _Args>
78-
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
78+
[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
7979
__throw_filesystem_error(_Args&&...) {
8080
_LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");
8181
}

libcxx/include/__format/format_error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class _LIBCPP_EXPORTED_FROM_ABI format_error : public runtime_error {
3535
};
3636
_LIBCPP_DIAGNOSTIC_POP
3737

38-
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) {
38+
[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) {
3939
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
4040
throw format_error(__s);
4141
# else

libcxx/include/__format/parser_std_format_spec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5252

5353
namespace __format_spec {
5454

55-
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void
55+
[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void
5656
__throw_invalid_option_format_error(const char* __id, const char* __option) {
5757
std::__throw_format_error(
5858
(string("The format specifier for ") + __id + " does not allow the " + __option + " option").c_str());
5959
}
6060

61-
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) {
61+
[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) {
6262
std::__throw_format_error(
6363
(string("The type option contains an invalid value for ") + __id + " formatting argument").c_str());
6464
}

0 commit comments

Comments
 (0)