From: Eric Fiselier Date: Mon, 14 Nov 2016 07:26:17 +0000 (+0000) Subject: Add explicit (void) cast to unused unique_ptr::release() results X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dffdb5c9bdc8c6db320e72bbd7ea12b39c7b6d74;p=llvm Add explicit (void) cast to unused unique_ptr::release() results Summary: This patch adds explicit `(void)` casts to discarded `release()` calls to suppress -Wunused-result. This patch fixes *all* warnings are generated as a result of [applying `[[nodiscard]]` within libc++](https://reviews.llvm.org/D26596). Similar fixes were applied to Clang in r286796. Reviewers: chandlerc, dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26598 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286797 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/PDB/IPDBSession.h b/include/llvm/DebugInfo/PDB/IPDBSession.h index 3d2c37eff2e..15e97ac198e 100644 --- a/include/llvm/DebugInfo/PDB/IPDBSession.h +++ b/include/llvm/DebugInfo/PDB/IPDBSession.h @@ -40,7 +40,7 @@ public: T *ConcreteSymbol = dyn_cast(Symbol.get()); if (!ConcreteSymbol) return nullptr; - Symbol.release(); + (void)Symbol.release(); return std::unique_ptr(ConcreteSymbol); } diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp index 63854307b7b..f64785b3ad9 100644 --- a/lib/Bitcode/Reader/BitReader.cpp +++ b/lib/Bitcode/Reader/BitReader.cpp @@ -84,7 +84,9 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef, std::unique_ptr Owner(unwrap(MemBuf)); Expected> ModuleOrErr = getOwningLazyBitcodeModule(std::move(Owner), Ctx); - Owner.release(); + // Release the buffer if we didn't take ownership of it since we never owned + // it anyway. + (void)Owner.release(); if (Error Err = ModuleOrErr.takeError()) { std::string Message;