[llvm] [LLVM-C] Add binding to `BitcodeReader::getBitcodeProducerString` (PR #166063)

Tamir Duberstein via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 06:39:46 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:

I'm not sure this is what I meant. I was thinking we'd want the test to be as strict as possible - to me that means no `||` anywhere.

https://github.com/llvm/llvm-project/pull/166063


More information about the llvm-commits mailing list