diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index f3910b1fb9f7..1eb9abcbf126 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -77,7 +77,7 @@ public: return const_iterator(getBucketsEnd(), getBucketsEnd(), *this, true); } - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + LLVM_NODISCARD bool empty() const { return getNumEntries() == 0; } unsigned size() const { return getNumEntries(); } diff --git a/llvm/include/llvm/ADT/PriorityWorklist.h b/llvm/include/llvm/ADT/PriorityWorklist.h index 9dd575fa96bf..511606b1fd84 100644 --- a/llvm/include/llvm/ADT/PriorityWorklist.h +++ b/llvm/include/llvm/ADT/PriorityWorklist.h @@ -116,7 +116,7 @@ public: } while (!V.empty() && V.back() == T()); } - T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { + LLVM_NODISCARD T pop_back_val() { T Ret = back(); pop_back(); return Ret; diff --git a/llvm/include/llvm/ADT/ScopeExit.h b/llvm/include/llvm/ADT/ScopeExit.h index 28a1124773dc..4e64352c77df 100644 --- a/llvm/include/llvm/ADT/ScopeExit.h +++ b/llvm/include/llvm/ADT/ScopeExit.h @@ -43,8 +43,8 @@ public: // // Interface is specified by p0052r2. template -detail::scope_exit::type> - LLVM_ATTRIBUTE_UNUSED_RESULT make_scope_exit(Callable &&F) { +LLVM_NODISCARD detail::scope_exit::type> +make_scope_exit(Callable &&F) { return detail::scope_exit::type>( std::forward(F)); } diff --git a/llvm/include/llvm/ADT/SetVector.h b/llvm/include/llvm/ADT/SetVector.h index 01d38a8f3b97..455f8a89e107 100644 --- a/llvm/include/llvm/ADT/SetVector.h +++ b/llvm/include/llvm/ADT/SetVector.h @@ -212,7 +212,7 @@ public: vector_.pop_back(); } - T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { + LLVM_NODISCARD T pop_back_val() { T Ret = back(); pop_back(); return Ret; diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h index eaed6aa05dcb..1f8571a851e1 100644 --- a/llvm/include/llvm/ADT/SmallPtrSet.h +++ b/llvm/include/llvm/ADT/SmallPtrSet.h @@ -84,7 +84,7 @@ protected: public: typedef unsigned size_type; - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return size() == 0; } + LLVM_NODISCARD bool empty() const { return size() == 0; } size_type size() const { return NumNonEmpty - NumTombstones; } void clear() { diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h index aaa5ff0ae939..07bdf0c33df1 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h @@ -47,7 +47,7 @@ public: typedef size_t size_type; SmallSet() {} - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + LLVM_NODISCARD bool empty() const { return Vector.empty() && Set.empty(); } diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 94035797e570..996f56f0f548 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -54,7 +54,7 @@ public: return size_t((char*)CapacityX - (char*)BeginX); } - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return BeginX == EndX; } + LLVM_NODISCARD bool empty() const { return BeginX == EndX; } }; template struct SmallVectorStorage; @@ -376,7 +376,7 @@ public: this->grow(N); } - T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { + LLVM_NODISCARD T pop_back_val() { T Result = ::std::move(this->back()); this->pop_back(); return Result; diff --git a/llvm/include/llvm/ADT/simple_ilist.h b/llvm/include/llvm/ADT/simple_ilist.h index 9235bad6ab32..a1ab59170840 100644 --- a/llvm/include/llvm/ADT/simple_ilist.h +++ b/llvm/include/llvm/ADT/simple_ilist.h @@ -124,10 +124,10 @@ public: } /// Check if the list is empty in constant time. - bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return Sentinel.empty(); } + LLVM_NODISCARD bool empty() const { return Sentinel.empty(); } /// Calculate the size of the list in linear time. - size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const { + LLVM_NODISCARD size_type size() const { return std::distance(begin(), end()); }