Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace cfg(not?(any with llvm_versions #502

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ impl<'ctx> BasicBlock<'ctx> {
///
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
///
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
Expand Down Expand Up @@ -471,13 +471,13 @@ impl<'ctx> BasicBlock<'ctx> {
pub fn set_name(&self, name: &str) {
let c_string = to_c_str(name);

#[cfg(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0"))]
#[llvm_versions(..7)]
{
use llvm_sys::core::LLVMSetValueName;

unsafe { LLVMSetValueName(LLVMBasicBlockAsValue(self.basic_block), c_string.as_ptr()) };
}
#[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))]
#[llvm_versions(7..)]
{
use llvm_sys::core::LLVMSetValueName2;

Expand Down
106 changes: 36 additions & 70 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ impl<'ctx> Builder<'ctx> {
/// };
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i32_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -708,9 +708,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -740,9 +740,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -775,9 +775,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -813,9 +813,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -935,9 +935,9 @@ impl<'ctx> Builder<'ctx> {
/// };
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -1087,9 +1087,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("struct_gep");
/// let void_type = context.void_type();
/// let i32_ty = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let field_types = &[i32_ty.into(), i32_ty.into()];
/// let struct_ty = context.struct_type(field_types, false);
Expand Down Expand Up @@ -1153,9 +1153,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("struct_gep");
/// let void_type = context.void_type();
/// let i32_ty = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let field_types = &[i32_ty.into(), i32_ty.into()];
/// let struct_ty = context.struct_type(field_types, false);
Expand Down Expand Up @@ -1227,9 +1227,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into(), i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1278,9 +1278,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into(), i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1347,9 +1347,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_seven = i32_type.const_int(7, false);
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
Expand Down Expand Up @@ -1387,9 +1387,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("ret");
/// let builder = context.create_builder();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = i32_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1427,9 +1427,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("ret");
/// let builder = context.create_builder();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = i32_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -2763,21 +2763,9 @@ impl<'ctx> Builder<'ctx> {
///
/// let array_alloca = builder.build_alloca(array_type, "array_alloca").unwrap();
///
/// #[cfg(any(
/// feature = "llvm4-0",
/// feature = "llvm5-0",
/// feature = "llvm6-0",
/// feature = "llvm7-0",
/// feature = "llvm8-0",
/// feature = "llvm9-0",
/// feature = "llvm10-0",
/// feature = "llvm11-0",
/// feature = "llvm12-0",
/// feature = "llvm13-0",
/// feature = "llvm14-0"
/// ))]
/// #[llvm_versions(..15)]
/// let array = builder.build_load(array_alloca, "array_load").unwrap().into_array_value();
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let array = builder.build_load(i32_type, array_alloca, "array_load").unwrap().into_array_value();
///
/// let const_int1 = i32_type.const_int(2, false);
Expand Down Expand Up @@ -2846,21 +2834,9 @@ impl<'ctx> Builder<'ctx> {
///
/// let array_alloca = builder.build_alloca(array_type, "array_alloca").unwrap();
///
/// #[cfg(any(
/// feature = "llvm4-0",
/// feature = "llvm5-0",
/// feature = "llvm6-0",
/// feature = "llvm7-0",
/// feature = "llvm8-0",
/// feature = "llvm9-0",
/// feature = "llvm10-0",
/// feature = "llvm11-0",
/// feature = "llvm12-0",
/// feature = "llvm13-0",
/// feature = "llvm14-0"
/// ))]
/// #[llvm_versions(..15)]
/// let array = builder.build_load(array_alloca, "array_load").unwrap().into_array_value();
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let array = builder.build_load(i32_type, array_alloca, "array_load").unwrap().into_array_value();
///
/// let const_int1 = i32_type.const_int(2, false);
Expand Down Expand Up @@ -3265,9 +3241,9 @@ impl<'ctx> Builder<'ctx> {
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// let i32_seven = i32_type.const_int(7, false);
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("rmw", fn_type, None);
Expand Down Expand Up @@ -3298,12 +3274,7 @@ impl<'ctx> Builder<'ctx> {
));
}

#[cfg(not(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
)))]
#[llvm_versions(..15)]
if ptr.get_type().get_element_type() != value.get_type().into() {
return Err(BuilderError::PointeeTypeMismatch(
"Pointer's pointee type must match the value's type.",
Expand Down Expand Up @@ -3344,9 +3315,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("cmpxchg");
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// #[llvm_versions(..15)]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// #[llvm_versions(15..)]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("", fn_type, None);
Expand Down Expand Up @@ -3384,12 +3355,7 @@ impl<'ctx> Builder<'ctx> {
));
}

#[cfg(not(any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
)))]
#[llvm_versions(..15)]
if ptr.get_type().get_element_type().as_basic_type_enum() != cmp.get_type() {
return Err(BuilderError::PointeeTypeMismatch(
"The pointer does not point to an element of the value type.",
Expand Down
Loading
Loading