diff options
| author | Justin Bogner <mail@justinbogner.com> | 2016-10-16 20:30:40 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2016-10-16 20:30:40 +0000 |
| commit | d727738369fb154d79b60a228e3829500a53b354 (patch) | |
| tree | 253a77602aaf5d89fa25ecea86a58f8611f74d6d | |
| parent | 14994133bb86c038114b1ef906b2841e04add92d (diff) | |
| download | bcm5719-llvm-d727738369fb154d79b60a228e3829500a53b354.tar.gz bcm5719-llvm-d727738369fb154d79b60a228e3829500a53b354.zip | |
ADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for ArrayRef
Instead of annotating (most of) the ArrayRef API, we can just annotate
the type directly. This is less code and it will warn in more cases.
llvm-svn: 284342
| -rw-r--r-- | llvm/include/llvm/ADT/ArrayRef.h | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h index 3efc09ddd36..1c90478e2c9 100644 --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -29,7 +29,7 @@ namespace llvm { /// This is intended to be trivially copyable, so it should be passed by /// value. template<typename T> - class ArrayRef { + class LLVM_NODISCARD ArrayRef { public: typedef const T *iterator; typedef const T *const_iterator; @@ -167,7 +167,6 @@ namespace llvm { } /// slice(n) - Chop off the first N elements of the array. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> slice(size_t N) const { assert(N <= size() && "Invalid specifier"); return ArrayRef<T>(data()+N, size()-N); @@ -175,28 +174,24 @@ namespace llvm { /// slice(n, m) - Chop off the first N elements of the array, and keep M /// elements in the array. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> slice(size_t N, size_t M) const { assert(N+M <= size() && "Invalid specifier"); return ArrayRef<T>(data()+N, M); } /// \brief Drop the first \p N elements of the array. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> drop_front(size_t N = 1) const { assert(size() >= N && "Dropping more elements than exist"); return slice(N, size() - N); } /// \brief Drop the last \p N elements of the array. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> drop_back(size_t N = 1) const { assert(size() >= N && "Dropping more elements than exist"); return slice(0, size() - N); } /// \brief Return a copy of *this with only the first \p N elements. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> take_front(size_t N = 1) const { if (N >= size()) return *this; @@ -204,7 +199,6 @@ namespace llvm { } /// \brief Return a copy of *this with only the last \p N elements. - LLVM_ATTRIBUTE_UNUSED_RESULT ArrayRef<T> take_back(size_t N = 1) const { if (N >= size()) return *this; @@ -265,7 +259,7 @@ namespace llvm { /// This is intended to be trivially copyable, so it should be passed by /// value. template<typename T> - class MutableArrayRef : public ArrayRef<T> { + class LLVM_NODISCARD MutableArrayRef : public ArrayRef<T> { public: typedef T *iterator; @@ -326,7 +320,6 @@ namespace llvm { } /// slice(n) - Chop off the first N elements of the array. - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> slice(size_t N) const { assert(N <= this->size() && "Invalid specifier"); return MutableArrayRef<T>(data()+N, this->size()-N); @@ -334,27 +327,23 @@ namespace llvm { /// slice(n, m) - Chop off the first N elements of the array, and keep M /// elements in the array. - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> slice(size_t N, size_t M) const { assert(N+M <= this->size() && "Invalid specifier"); return MutableArrayRef<T>(data()+N, M); } /// \brief Drop the first \p N elements of the array. - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> drop_front(size_t N = 1) const { assert(this->size() >= N && "Dropping more elements than exist"); return slice(N, this->size() - N); } - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> drop_back(size_t N = 1) const { assert(this->size() >= N && "Dropping more elements than exist"); return slice(0, this->size() - N); } /// \brief Return a copy of *this with only the first \p N elements. - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> take_front(size_t N = 1) const { if (N >= this->size()) return *this; @@ -362,7 +351,6 @@ namespace llvm { } /// \brief Return a copy of *this with only the last \p N elements. - LLVM_ATTRIBUTE_UNUSED_RESULT MutableArrayRef<T> take_back(size_t N = 1) const { if (N >= this->size()) return *this; |

