[llvm] [C-API] Add LLVMIs for ConstantRangeAttribute and ConstantRangeListAttribute (PR #196312)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 06:13:16 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Valentin Churavy (vchuravy)

<details>
<summary>Changes</summary>

#<!-- -->90505 added C-API for creating these attributes, but there is currently no way to check
if one is encountering such an attribute. Noticed downstream in LLVM.jl where we iterate over attributes
and encountered an unknown kind.


---
Full diff: https://github.com/llvm/llvm-project/pull/196312.diff


2 Files Affected:

- (modified) llvm/include/llvm-c/Core.h (+2) 
- (modified) llvm/lib/IR/Core.cpp (+8) 


``````````diff
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 86f636c636783..32d997032b4ad 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -802,6 +802,8 @@ LLVM_C_ABI const char *LLVMGetStringAttributeValue(LLVMAttributeRef A,
 LLVM_C_ABI LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
 LLVM_C_ABI LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
 LLVM_C_ABI LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
+LLVM_C_ABI LLVMBool LLVMIsConstantRangeAttribute(LLVMAttributeRef A);
+LLVM_C_ABI LLVMBool LLVMIsConstantRangeListAttribute(LLVMAttributeRef A);
 
 /**
  * Obtain a Type from a context by its registered name.
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 5e6b03d01b6ba..d9c1619f27b98 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -259,6 +259,14 @@ LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A) {
   return unwrap(A).isTypeAttribute();
 }
 
+LLVMBool LLVMIsConstantRangeAttribute(LLVMAttributeRef A) {
+  return unwrap(A).isConstantRangeAttribute();
+}
+
+LLVMBool LLVMIsConstantRangeListAttribute(LLVMAttributeRef A) {
+  return unwrap(A).isConstantRangeListAttribute();
+}
+
 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) {
   std::string MsgStorage;
   raw_string_ostream Stream(MsgStorage);

``````````

</details>


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


More information about the llvm-commits mailing list