[llvm] r284884 - Support: Annotate Error and Expected<> with LLVM_NODISCARD

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 14:01:12 PDT 2016

Author: bogner
Date: Fri Oct 21 16:01:12 2016
New Revision: 284884

URL: http://llvm.org/viewvc/llvm-project?rev=284884&view=rev
Support: Annotate Error and Expected<> with LLVM_NODISCARD

It's always a mistake to ignore return values with Error or Expected


Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=284884&r1=284883&r2=284884&view=diff
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Fri Oct 21 16:01:12 2016
@@ -135,7 +135,7 @@ private:
 /// *All* Error instances must be checked before destruction, even if
 /// they're moved-assigned or constructed from Success values that have already
 /// been checked. This enforces checking through all levels of the call stack.
-class Error {
+class LLVM_NODISCARD Error {
   // ErrorList needs to be able to yank ErrorInfoBase pointers out of this
   // class to add to the error list.
@@ -611,7 +611,7 @@ private:
 /// Error cannot be copied, this class replaces getError() with
 /// takeError(). It also adds an bool errorIsA<ErrT>() method for testing the
 /// error class type.
-template <class T> class Expected {
+template <class T> class LLVM_NODISCARD Expected {
   template <class OtherT> friend class Expected;
   static const bool isRef = std::is_reference<T>::value;
   typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap;

More information about the llvm-commits mailing list