[llvm] r286797 - Add explicit (void) cast to unused unique_ptr::release() results

Eric Fiselier via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 13 23:26:17 PST 2016


Author: ericwf
Date: Mon Nov 14 01:26:17 2016
New Revision: 286797

URL: http://llvm.org/viewvc/llvm-project?rev=286797&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
    llvm/trunk/lib/Bitcode/Reader/BitReader.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h?rev=286797&r1=286796&r2=286797&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h Mon Nov 14 01:26:17 2016
@@ -40,7 +40,7 @@ public:
     T *ConcreteSymbol = dyn_cast<T>(Symbol.get());
     if (!ConcreteSymbol)
       return nullptr;
-    Symbol.release();
+    (void)Symbol.release();
     return std::unique_ptr<T>(ConcreteSymbol);
   }
 

Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitReader.cpp?rev=286797&r1=286796&r2=286797&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Mon Nov 14 01:26:17 2016
@@ -84,7 +84,9 @@ LLVMBool LLVMGetBitcodeModuleInContext(L
   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;




More information about the llvm-commits mailing list