[llvm] [LLVM-C] Add binding to `BitcodeReader::getBitcodeProducerString` (PR #166063)
Tamir Duberstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 2 05:13:34 PST 2025
================
@@ -135,3 +134,36 @@ int llvm_module_list_globals(void) {
return 0;
}
+
+int llvm_module_get_producer_string(void) {
+ LLVMMemoryBufferRef MB;
+ char *Msg = NULL;
+ if (LLVMCreateMemoryBufferWithSTDIN(&MB, &Msg)) {
+ fprintf(stderr, "Error reading file: %s\n", Msg);
+ LLVMDisposeMessage(Msg);
+ return 1;
+ }
+
+ char *Producer = NULL;
+ char *Err = NULL;
+ LLVMBool Ret = LLVMGetBitcodeProducerString(MB, &Producer, &Err);
+ LLVMDisposeMemoryBuffer(MB);
+
+ if (Ret) {
+ fprintf(stderr, "Error reading bitcode: %s\n", Err ? Err : "unknown");
+ if (Err)
+ LLVMDisposeMessage(Err);
+ if (Producer)
+ LLVMDisposeMessage(Producer);
+ return 1;
+ }
+
+ if (Producer) {
----------------
tamird wrote:
is it not an error for Producer to be NULL here (and for Err to be non-NULL)?
https://github.com/llvm/llvm-project/pull/166063
More information about the llvm-commits
mailing list