[llvm] [OCaml] Fix warnings in llvm_debuginfo (PR #173011)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 19 06:54:45 PST 2025


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/173011

Fix an unused variable warning and a warning about missing return. As this is C code we don't have llvm_unreachable() here, so I went with an assert + dummy return.

>From 2745bc20489c433d47d5fde6587b96b7428b6549 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 19 Dec 2025 15:52:45 +0100
Subject: [PATCH] [Ocaml] Fix warnings in llvm_debuginfo

Fix an unused variable warning and a warning about missing return.
As this is C code we don't have llvm_unreachable() here, so I
went with an assert + dummy return.
---
 llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
index 023ebd6d60cd5..26289d785ebd2 100644
--- a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
+++ b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
@@ -15,6 +15,7 @@
 |*                                                                            *|
 \*===----------------------------------------------------------------------===*/
 
+#include <assert.h>
 #include <string.h>
 
 #include "caml/memory.h"
@@ -137,6 +138,8 @@ static LLVMDIFlags map_DIFlag(LLVMDIFlag_i DIF) {
   case i_DIFlagPtrToMemberRep:
     return LLVMDIFlagPtrToMemberRep;
   }
+  assert(0 && "Invalid LLVMDIFlag");
+  return 0;
 }
 
 /* unit -> int */
@@ -380,7 +383,6 @@ value llvm_dibuild_get_or_create_array(value Builder, value Data) {
 
 value llvm_dibuild_create_subroutine_type(value Builder, value File,
                                           value ParameterTypes, value Flags) {
-  mlsize_t Count = Wosize_val(ParameterTypes);
   LLVMMetadataRef *Temp = from_val_array(ParameterTypes);
   LLVMMetadataRef Metadata = LLVMDIBuilderCreateSubroutineType(
       DIBuilder_val(Builder), Metadata_val(File), Temp,



More information about the llvm-commits mailing list