]> granicus.if.org Git - llvm/commitdiff
Support: Annotate Error and Expected<> with LLVM_NODISCARD
authorJustin Bogner <mail@justinbogner.com>
Fri, 21 Oct 2016 21:01:12 +0000 (21:01 +0000)
committerJustin Bogner <mail@justinbogner.com>
Fri, 21 Oct 2016 21:01:12 +0000 (21:01 +0000)
It's always a mistake to ignore return values with Error or Expected
types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284884 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Error.h

index afd2660f39c440d4d8a42e8b356ac348f1041043..d228a0fbdbcde93955085dbbed5c9f540f72a6ef 100644 (file)
@@ -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;