[llvm] [LLVM-C] Add binding to `BitcodeReader::getBitcodeProducerString` (PR #166063)
Michal R via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 3 01:47:36 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) {
----------------
vadorovsky wrote:
You're right. I extended the preficate in the `if` statement above to `Ret || Err` and handled the lack of `Producer` as an error.
https://github.com/llvm/llvm-project/pull/166063
More information about the llvm-commits
mailing list