Skip to content

Commit d09dbf2

Browse files
r-barnesmeta-codesync[bot]
authored andcommitted
Extirpate FOLLY_NODISCARD
Summary: `[[nodiscard]]` is now available in all of our compilers. This diff changes the code to rely on it directly. Reviewed By: yfeldblum Differential Revision: D87101329 fbshipit-source-id: 29a60e1cbd3be5103414d9b6bbe52b3bde545bf4
1 parent ffa1b5b commit d09dbf2

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

folly/io/async/DelayedDestructionBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DelayedDestructionBase {
6262
* object, causing problems when the callback function returns and the
6363
* guarded object's method resumes execution.
6464
*/
65-
class FOLLY_NODISCARD DestructorGuard {
65+
class [[nodiscard]] DestructorGuard {
6666
public:
6767
explicit DestructorGuard(DelayedDestructionBase* dd) : dd_(dd) {
6868
if (dd_ != nullptr) {

folly/io/async/EventBaseAtomicNotificationQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class EventBaseAtomicNotificationQueue
9292
* Returns true iff the task was queued.
9393
* Can be called from any thread.
9494
*/
95-
FOLLY_NODISCARD bool tryPutMessage(Task&& task, uint32_t maxSize);
95+
[[nodiscard]] bool tryPutMessage(Task&& task, uint32_t maxSize);
9696

9797
/*
9898
* Detaches the queue from an EventBase.

folly/io/async/Request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ RequestContext::State::~State() {
235235
}
236236
}
237237

238-
class FOLLY_NODISCARD RequestContext::State::LockGuard {
238+
class [[nodiscard]] RequestContext::State::LockGuard {
239239
public:
240240
explicit LockGuard(RequestContext::State& state)
241241
: state_(state), lock_(state.mutex_) {}

folly/io/async/observer/AsyncSocketObserverInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class AsyncSocketObserverInterface {
144144
* and ACK flags, and the other requesting just the SCHED flag, then we
145145
* will add the TX, ACK, and SCHED flags to the request.
146146
*/
147-
FOLLY_NODISCARD const PrewriteRequest& getMergedRequest() const {
147+
[[nodiscard]] const PrewriteRequest& getMergedRequest() const {
148148
return mergedRequest_;
149149
}
150150

@@ -197,7 +197,7 @@ class AsyncSocketObserverInterface {
197197
/**
198198
* For WRITE events, returns if SCHED timestamp requested.
199199
*/
200-
FOLLY_NODISCARD bool schedTimestampRequestedOnWrite() const {
200+
[[nodiscard]] bool schedTimestampRequestedOnWrite() const {
201201
CHECK_EQ(Type::WRITE, type);
202202
CHECK(maybeWriteFlags.has_value());
203203
return isSet(*maybeWriteFlags, WriteFlags::TIMESTAMP_SCHED);
@@ -206,7 +206,7 @@ class AsyncSocketObserverInterface {
206206
/**
207207
* For WRITE events, returns if TX timestamp requested.
208208
*/
209-
FOLLY_NODISCARD bool txTimestampRequestedOnWrite() const {
209+
[[nodiscard]] bool txTimestampRequestedOnWrite() const {
210210
CHECK_EQ(Type::WRITE, type);
211211
CHECK(maybeWriteFlags.has_value());
212212
return isSet(*maybeWriteFlags, WriteFlags::TIMESTAMP_TX);
@@ -215,7 +215,7 @@ class AsyncSocketObserverInterface {
215215
/**
216216
* For WRITE events, returns if ACK timestamp requested.
217217
*/
218-
FOLLY_NODISCARD bool ackTimestampRequestedOnWrite() const {
218+
[[nodiscard]] bool ackTimestampRequestedOnWrite() const {
219219
CHECK_EQ(Type::WRITE, type);
220220
CHECK(maybeWriteFlags.has_value());
221221
return isSet(*maybeWriteFlags, WriteFlags::TIMESTAMP_ACK);

folly/lang/Bits.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ template <class T>
241241
struct n_least_significant_bits_fn {
242242
static_assert(detail::supported_in_bits_operations_v<T>);
243243

244-
FOLLY_NODISCARD constexpr T operator()(std::uint32_t n) const {
244+
[[nodiscard]] constexpr T operator()(std::uint32_t n) const {
245245
if (!folly::is_constant_evaluated_or(true)) {
246246
compiler_may_unsafely_assume(n <= sizeof(T) * 8);
247247

@@ -272,7 +272,7 @@ template <class T>
272272
struct n_most_significant_bits_fn {
273273
static_assert(detail::supported_in_bits_operations_v<T>);
274274

275-
FOLLY_NODISCARD constexpr T operator()(std::uint32_t n) const {
275+
[[nodiscard]] constexpr T operator()(std::uint32_t n) const {
276276
if (!folly::is_constant_evaluated_or(true)) {
277277
compiler_may_unsafely_assume(n <= sizeof(T) * 8);
278278

@@ -303,7 +303,7 @@ inline constexpr n_most_significant_bits_fn<T> n_most_significant_bits;
303303
/// Clears n least significant (right) bits. Other bits stay the same.
304304
struct clear_n_least_significant_bits_fn {
305305
template <typename T>
306-
FOLLY_NODISCARD constexpr T operator()(T x, std::uint32_t n) const {
306+
[[nodiscard]] constexpr T operator()(T x, std::uint32_t n) const {
307307
static_assert(detail::supported_in_bits_operations_v<T>);
308308

309309
// alternative is to do two shifts but that has
@@ -321,7 +321,7 @@ inline constexpr clear_n_least_significant_bits_fn
321321
/// Sets n least significant (right) bits. Other bits stay the same.
322322
struct set_n_least_significant_bits_fn {
323323
template <typename T>
324-
FOLLY_NODISCARD constexpr T operator()(T x, std::uint32_t n) const {
324+
[[nodiscard]] constexpr T operator()(T x, std::uint32_t n) const {
325325
static_assert(detail::supported_in_bits_operations_v<T>);
326326

327327
// alternative is to do two shifts but that has
@@ -338,7 +338,7 @@ inline constexpr set_n_least_significant_bits_fn set_n_least_significant_bits;
338338
/// Clears n most significant (left) bits. Other bits stay the same.
339339
struct clear_n_most_significant_bits_fn {
340340
template <typename T>
341-
FOLLY_NODISCARD constexpr T operator()(T x, std::uint32_t n) const {
341+
[[nodiscard]] constexpr T operator()(T x, std::uint32_t n) const {
342342
static_assert(detail::supported_in_bits_operations_v<T>);
343343

344344
if (!folly::is_constant_evaluated_or(true)) {
@@ -366,7 +366,7 @@ inline constexpr clear_n_most_significant_bits_fn clear_n_most_significant_bits;
366366
/// Sets n most significant (left) bits. Other bits stay the same.
367367
struct set_n_most_significant_bits_fn {
368368
template <typename T>
369-
FOLLY_NODISCARD constexpr T operator()(T x, std::uint32_t n) const {
369+
[[nodiscard]] constexpr T operator()(T x, std::uint32_t n) const {
370370
static_assert(detail::supported_in_bits_operations_v<T>);
371371
return x | n_most_significant_bits<T>(n);
372372
}
@@ -485,7 +485,7 @@ class Endian {
485485
///
486486
struct get_bit_at_fn {
487487
template <typename Uint>
488-
FOLLY_NODISCARD constexpr bool operator()(
488+
[[nodiscard]] constexpr bool operator()(
489489
const Uint* ptr, std::size_t idx) const noexcept {
490490
static_assert(std::is_unsigned_v<std::remove_cv_t<Uint>>);
491491
static_assert(!std::is_same_v<std::remove_cv_t<Uint>, bool>);

0 commit comments

Comments
 (0)