diff --git a/llvm/include/llvm-c/BitReader.h b/llvm/include/llvm-c/BitReader.h --- a/llvm/include/llvm-c/BitReader.h +++ b/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); diff --git a/llvm/tools/llvm-c-test/diagnostic.c b/llvm/tools/llvm-c-test/diagnostic.c --- a/llvm/tools/llvm-c-test/diagnostic.c +++ b/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");