From 8659d16631fdd1ff519a25d6867ddd9dbda8aea9 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 21 Oct 2016 21:01:12 +0000 Subject: [PATCH] Support: Annotate Error and Expected<> with LLVM_NODISCARD It's always a mistake to ignore return values with Error or Expected types. llvm-svn: 284884 --- llvm/include/llvm/Support/Error.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index afd2660..d228a0f 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -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() method for testing the /// error class type. -template class Expected { +template class LLVM_NODISCARD Expected { template friend class Expected; static const bool isRef = std::is_reference::value; typedef ReferenceStorage::type> wrap; -- 2.7.4