[PATCH] D26598: 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:22:09 PST 2016


EricWF created this revision.
EricWF added a reviewer: chandlerc.
EricWF added a subscriber: llvm-commits.
EricWF set the repository for this revision to rL LLVM.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D26598

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


Index: lib/Bitcode/Reader/BitReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitReader.cpp
+++ lib/Bitcode/Reader/BitReader.cpp
@@ -102,7 +102,9 @@
 
   ErrorOr<std::unique_ptr<Module>> ModuleOrErr =
       getLazyBitcodeModule(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();
   Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext, true);
 
   if (ModuleOrErr.getError()) {
Index: include/llvm/DebugInfo/PDB/IPDBSession.h
===================================================================
--- include/llvm/DebugInfo/PDB/IPDBSession.h
+++ include/llvm/DebugInfo/PDB/IPDBSession.h
@@ -40,7 +40,7 @@
     T *ConcreteSymbol = dyn_cast<T>(Symbol.get());
     if (!ConcreteSymbol)
       return nullptr;
-    Symbol.release();
+    (void)Symbol.release();
     return std::unique_ptr<T>(ConcreteSymbol);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26598.77770.patch
Type: text/x-patch
Size: 995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/5ee94de0/attachment.bin>


More information about the llvm-commits mailing list