Skip to content

Commit

Permalink
Change _NODISCARD in source and test files to [[nodiscard]] (#3397)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederick-vs-ja committed Feb 11, 2023
1 parent 29638ba commit 9ae1b3f
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 92 deletions.
12 changes: 6 additions & 6 deletions stl/src/atomic_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace {
CONDITION_VARIABLE _Condition;
};

struct _NODISCARD _Guarded_wait_context : _Wait_context {
struct [[nodiscard]] _Guarded_wait_context : _Wait_context {
_Guarded_wait_context(const void* _Storage_, _Wait_context* const _Head) noexcept
: _Wait_context{_Storage_, _Head, _Head->_Prev, CONDITION_VARIABLE_INIT} {
_Prev->_Next = this;
Expand All @@ -41,7 +41,7 @@ namespace {
_Guarded_wait_context& operator=(const _Guarded_wait_context&) = delete;
};

class _NODISCARD _SrwLock_guard {
class [[nodiscard]] _SrwLock_guard {
public:
explicit _SrwLock_guard(SRWLOCK& _Locked_) noexcept : _Locked(&_Locked_) {
AcquireSRWLockExclusive(_Locked);
Expand Down Expand Up @@ -202,8 +202,8 @@ namespace {
}
#endif // _ATOMIC_WAIT_ON_ADDRESS_STATICALLY_AVAILABLE

_NODISCARD unsigned char __std_atomic_compare_exchange_128_fallback(_Inout_bytecount_(16) long long* _Destination,
_In_ long long _ExchangeHigh, _In_ long long _ExchangeLow,
[[nodiscard]] unsigned char __std_atomic_compare_exchange_128_fallback(
_Inout_bytecount_(16) long long* _Destination, _In_ long long _ExchangeHigh, _In_ long long _ExchangeLow,
_Inout_bytecount_(16) long long* _ComparandResult) noexcept {
static SRWLOCK _Mtx = SRWLOCK_INIT;
_SrwLock_guard _Guard{_Mtx};
Expand Down Expand Up @@ -397,7 +397,7 @@ _Smtx_t* __stdcall __std_atomic_get_mutex(const void* const _Key) noexcept {
}
#pragma warning(pop)

_NODISCARD unsigned char __stdcall __std_atomic_compare_exchange_128(_Inout_bytecount_(16) long long* _Destination,
[[nodiscard]] unsigned char __stdcall __std_atomic_compare_exchange_128(_Inout_bytecount_(16) long long* _Destination,
_In_ long long _ExchangeHigh, _In_ long long _ExchangeLow,
_Inout_bytecount_(16) long long* _ComparandResult) noexcept {
#if !defined(_WIN64)
Expand All @@ -413,7 +413,7 @@ _NODISCARD unsigned char __stdcall __std_atomic_compare_exchange_128(_Inout_byte
#endif // ^^^ _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 0
}

_NODISCARD char __stdcall __std_atomic_has_cmpxchg16b() noexcept {
[[nodiscard]] char __stdcall __std_atomic_has_cmpxchg16b() noexcept {
#if !defined(_WIN64)
return false;
#elif _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 1
Expand Down
2 changes: 1 addition & 1 deletion stl/src/excptptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace {
_Constexpr_excptptr_immortalize_impl<_Ty> _Immortalize_impl;

template <class _Ty>
_NODISCARD _Ty& _Immortalize() noexcept {
[[nodiscard]] _Ty& _Immortalize() noexcept {
return _Immortalize_impl<_Ty>._Storage;
}
#else // choose immortalize strategy
Expand Down
2 changes: 1 addition & 1 deletion stl/src/memory_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace pmr {
return _Unaligned_new_delete_resource();
}

extern "C" _NODISCARD _CRT_SATELLITE_1 memory_resource* __cdecl null_memory_resource() noexcept {
extern "C" [[nodiscard]] _CRT_SATELLITE_1 memory_resource* __cdecl null_memory_resource() noexcept {
class _Null_resource final : public _Identity_equal_resource {
void* do_allocate(size_t, size_t) override { // Sorry, OOM!
_Xbad_alloc();
Expand Down
4 changes: 2 additions & 2 deletions stl/src/multprec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ constexpr int shift = _STD numeric_limits<unsigned long long>::d
constexpr unsigned long long mask = ~(~0ULL << shift);
constexpr unsigned long long maxVal = mask + 1;

_NODISCARD unsigned long long __CLRCALL_PURE_OR_CDECL _MP_Get(
[[nodiscard]] unsigned long long __CLRCALL_PURE_OR_CDECL _MP_Get(
_MP_arr u) noexcept { // convert multi-word value to scalar value
return (u[1] << shift) + u[0];
}
Expand Down Expand Up @@ -98,7 +98,7 @@ static void div(_MP_arr u,
}
}

_NODISCARD static int limit(const unsigned long long* u, int ulen) noexcept { // get index of last non-zero value
[[nodiscard]] static int limit(const unsigned long long* u, int ulen) noexcept { // get index of last non-zero value
while (u[ulen - 1] == 0) {
--ulen;
}
Expand Down
4 changes: 2 additions & 2 deletions stl/src/parallel_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

extern "C" {

_NODISCARD unsigned int __stdcall __std_parallel_algorithms_hw_threads() noexcept {
[[nodiscard]] unsigned int __stdcall __std_parallel_algorithms_hw_threads() noexcept {
static int _Cached_hw_concurrency = -1;
int _Hw_concurrency = __iso_volatile_load32(&_Cached_hw_concurrency);
if (_Hw_concurrency == -1) {
Expand All @@ -20,7 +20,7 @@ _NODISCARD unsigned int __stdcall __std_parallel_algorithms_hw_threads() noexcep
return static_cast<unsigned int>(_Hw_concurrency);
}

_NODISCARD PTP_WORK __stdcall __std_create_threadpool_work(
[[nodiscard]] PTP_WORK __stdcall __std_create_threadpool_work(
PTP_WORK_CALLBACK _Callback, void* _Context, PTP_CALLBACK_ENVIRON _Callback_environ) noexcept {
return CreateThreadpoolWork(_Callback, _Context, _Callback_environ);
}
Expand Down
Loading

0 comments on commit 9ae1b3f

Please sign in to comment.