[PATCH] D129113: Fix test: LLVMGetBitcodeModule takes ownership of memory buffer

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 11:07:33 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a731d733c56: Fix test: LLVMGetBitcodeModule takes ownership of memory buffer (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129113/new/

https://reviews.llvm.org/D129113

Files:
  llvm/include/llvm-c/BitReader.h
  llvm/tools/llvm-c-test/diagnostic.c


Index: llvm/tools/llvm-c-test/diagnostic.c
===================================================================
--- llvm/tools/llvm-c-test/diagnostic.c
+++ llvm/tools/llvm-c-test/diagnostic.c
@@ -70,13 +70,8 @@
 
   LLVMModuleRef M;
   int Ret = LLVMGetBitcodeModule2(MB, &M);
-  if (Ret) {
-    // We do not return if the bitcode was invalid, as we want to test whether
-    // the diagnostic handler was executed.
-    fprintf(stderr, "Error parsing bitcode: %s\n", msg);
-  }
-
-  LLVMDisposeMemoryBuffer(MB);
+  if (Ret)
+    LLVMDisposeMemoryBuffer(MB);
 
   if (handlerCalled) {
     fprintf(stderr, "Diagnostic handler was called while loading module\n");
Index: llvm/include/llvm-c/BitReader.h
===================================================================
--- llvm/include/llvm-c/BitReader.h
+++ llvm/include/llvm-c/BitReader.h
@@ -61,8 +61,13 @@
                                        LLVMMemoryBufferRef MemBuf,
                                        LLVMModuleRef *OutM, char **OutMessage);
 
-/** Reads a module from the specified path, returning via the OutMP parameter a
- * module provider which performs lazy deserialization. Returns 0 on success. */
+/** Reads a module from the given memory buffer, returning via the OutMP
+ * parameter a module provider which performs lazy deserialization.
+ *
+ * Returns 0 on success.
+ *
+ * Takes ownership of \p MemBuf if (and only if) the module was read
+ * successfully. */
 LLVMBool LLVMGetBitcodeModuleInContext2(LLVMContextRef ContextRef,
                                         LLVMMemoryBufferRef MemBuf,
                                         LLVMModuleRef *OutM);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129113.443294.patch
Type: text/x-patch
Size: 1642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220708/8ea27c33/attachment.bin>


More information about the llvm-commits mailing list