Skip to content

Commit

Permalink
Add explicit (void) cast to unused unique_ptr::release() results
Browse files Browse the repository at this point in the history
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
  • Loading branch information
EricWF committed Nov 14, 2016
1 parent 1d94ec7 commit dffdb5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/llvm/DebugInfo/PDB/IPDBSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IPDBSession {
T *ConcreteSymbol = dyn_cast<T>(Symbol.get());
if (!ConcreteSymbol)
return nullptr;
Symbol.release();
(void)Symbol.release();
return std::unique_ptr<T>(ConcreteSymbol);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Bitcode/Reader/BitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
Expected<std::unique_ptr<Module>> 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;
Expand Down

0 comments on commit dffdb5c

Please sign in to comment.