[llvm] [C-API] Add LLVMIs for ConstantRangeAttribute and ConstantRangeListAttribute (PR #196312)
Valentin Churavy via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 06:12:24 PDT 2026
https://github.com/vchuravy created https://github.com/llvm/llvm-project/pull/196312
#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.
>From 6eb39d2c6ef13ffd317f4b55cb98083955ecb4b8 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <v.churavy at gmail.com>
Date: Thu, 7 May 2026 15:08:32 +0200
Subject: [PATCH] [C-API] Add LLVMIs for ConstantRangeAttribute and
ConstantRangeListAttribute
---
llvm/include/llvm-c/Core.h | 2 ++
llvm/lib/IR/Core.cpp | 8 ++++++++
2 files changed, 10 insertions(+)
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);
More information about the llvm-commits
mailing list