From 3b4f4af1e4a1259d0b3b3eef160e2bce9d821f6a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 May 2024 17:18:34 +0200 Subject: [PATCH] Replace `cfg(not?(any` with `llvm_versions` in `tests/**/*.rs` --- tests/all/main.rs | 4 +- tests/all/test_builder.rs | 546 +++-------------------- tests/all/test_context.rs | 14 +- tests/all/test_debug_info.rs | 222 ++------- tests/all/test_execution_engine.rs | 14 +- tests/all/test_instruction_conversion.rs | 14 +- tests/all/test_instruction_values.rs | 168 +------ tests/all/test_module.rs | 6 +- tests/all/test_passes.rs | 94 +--- tests/all/test_targets.rs | 6 +- tests/all/test_types.rs | 133 +----- tests/all/test_values.rs | 203 ++------- 12 files changed, 195 insertions(+), 1229 deletions(-) diff --git a/tests/all/main.rs b/tests/all/main.rs index 2f57a23914c..e8e3b751022 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -7,7 +7,7 @@ mod test_attributes; mod test_basic_block; mod test_builder; mod test_context; -#[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] +#[llvm_versions(7..)] mod test_debug_info; mod test_execution_engine; mod test_instruction_conversion; @@ -15,7 +15,7 @@ mod test_instruction_values; mod test_intrinsics; mod test_module; mod test_object_file; -#[cfg(not(any(feature = "llvm17-0", feature = "llvm18-0")))] +#[llvm_versions(..17)] mod test_passes; mod test_targets; mod test_tari_example; diff --git a/tests/all/test_builder.rs b/tests/all/test_builder.rs index 8d22573684a..41f657f3253 100644 --- a/tests/all/test_builder.rs +++ b/tests/all/test_builder.rs @@ -47,19 +47,9 @@ fn test_build_call() { let function3 = module.add_function("call_fn", fn_type2, None); let basic_block3 = context.append_basic_block(function3, "entry"); let fn_ptr = function3.as_global_value().as_pointer_value(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let fn_ptr_type = fn_ptr.get_type(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let fn_ptr_type = context.ptr_type(AddressSpace::default()); builder.position_at_end(basic_block3); @@ -68,55 +58,21 @@ fn test_build_call() { builder.build_store(alloca, fn_ptr).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 load = builder.build_load(alloca, "load").unwrap().into_pointer_value(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let load = builder .build_load(fn_ptr_type, alloca, "load") .unwrap() .into_pointer_value(); - #[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)] { use inkwell::values::CallableValue; let callable_value = CallableValue::try_from(load).unwrap(); builder.build_call(callable_value, &[], "call").unwrap(); } - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] builder.build_indirect_call(fn_type2, load, &[], "call").unwrap(); builder.build_return(None).unwrap(); @@ -179,19 +135,9 @@ fn test_build_invoke_cleanup_resume() { }; // 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 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); @@ -263,19 +209,9 @@ fn test_build_invoke_catch_all() { }; // 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 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); @@ -351,19 +287,9 @@ fn landing_pad_filter() { }; // 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 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); @@ -409,19 +335,9 @@ fn test_null_checked_ptr_ops() { // } let i8_type = context.i8_type(); - #[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 i8_ptr_type = context.ptr_type(AddressSpace::default()); let i64_type = context.i64_type(); let fn_type = i8_type.fn_type(&[i8_ptr_type.into()], false); @@ -454,26 +370,9 @@ fn test_null_checked_ptr_ops() { let new_ptr = builder .build_int_to_ptr(new_ptr_as_int, i8_ptr_type, "int_as_ptr") .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 index1 = builder.build_load(new_ptr, "deref").unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let index1 = builder.build_load(i8_ptr_type, new_ptr, "deref").unwrap(); builder.build_return(Some(&index1)).unwrap(); @@ -513,26 +412,9 @@ fn test_null_checked_ptr_ops() { let new_ptr = builder .build_int_to_ptr(new_ptr_as_int, i8_ptr_type, "int_as_ptr") .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 index1 = builder.build_load(new_ptr, "deref").unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let index1 = builder.build_load(i8_ptr_type, new_ptr, "deref").unwrap(); builder.build_return(Some(&index1)).unwrap(); @@ -1016,19 +898,9 @@ fn test_vector_pointer_ops() { let context = Context::create(); let module = context.create_module("test"); let int32_vec_type = context.i32_type().vec_type(4); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let i8_ptr_vec_type = context.i8_type().ptr_type(AddressSpace::default()).vec_type(4); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let i8_ptr_vec_type = context.ptr_type(AddressSpace::default()).vec_type(4); let bool_vec_type = context.bool_type().vec_type(4); @@ -1064,29 +936,12 @@ fn test_insert_value() { builder.position_at_end(entry); 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(array_type, array_alloca, "array_load") .unwrap() @@ -1123,29 +978,12 @@ fn test_insert_value() { .is_err_and(|e| e == BuilderError::ExtractOutOfRange)); let struct_alloca = builder.build_alloca(struct_type, "struct_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 struct_value = builder .build_load(struct_alloca, "struct_load") .unwrap() .into_struct_value(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let struct_value = builder .build_load(struct_type, struct_alloca, "struct_load") .unwrap() @@ -1286,19 +1124,9 @@ fn run_memcpy_on<'ctx>( let i32_type = context.i32_type(); let i64_type = context.i64_type(); let array_len = 4; - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let fn_type = i32_type.ptr_type(AddressSpace::default()).fn_type(&[], false); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let fn_type = context.ptr_type(AddressSpace::default()).fn_type(&[], false); let fn_value = module.add_function("test_fn", fn_type, None); let builder = context.create_builder(); @@ -1313,26 +1141,9 @@ fn run_memcpy_on<'ctx>( // Initialize the array with the values [1, 2, 3, 4] for index in 0..4 { let index_val = i32_type.const_int(index, false); - #[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 elem_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let elem_ptr = unsafe { builder .build_in_bounds_gep(element_type, array_ptr, &[index_val], "index") @@ -1348,26 +1159,9 @@ fn run_memcpy_on<'ctx>( let bytes_to_copy = elems_to_copy * std::mem::size_of::(); let size_val = i64_type.const_int(bytes_to_copy as u64, false); let index_val = i32_type.const_int(2, false); - #[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 dest_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let dest_ptr = unsafe { builder .build_in_bounds_gep(element_type, array_ptr, &[index_val], "index") @@ -1418,19 +1212,9 @@ fn run_memmove_on<'ctx>( let i32_type = context.i32_type(); let i64_type = context.i64_type(); let array_len = 4; - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let fn_type = i32_type.ptr_type(AddressSpace::default()).fn_type(&[], false); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let fn_type = context.ptr_type(AddressSpace::default()).fn_type(&[], false); let fn_value = module.add_function("test_fn", fn_type, None); let builder = context.create_builder(); @@ -1445,26 +1229,9 @@ fn run_memmove_on<'ctx>( // Initialize the array with the values [1, 2, 3, 4] for index in 0..4 { let index_val = i32_type.const_int(index, false); - #[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 elem_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let elem_ptr = unsafe { builder .build_in_bounds_gep(element_type, array_ptr, &[index_val], "index") @@ -1480,26 +1247,9 @@ fn run_memmove_on<'ctx>( let bytes_to_copy = elems_to_copy * std::mem::size_of::(); let size_val = i64_type.const_int(bytes_to_copy as u64, false); let index_val = i32_type.const_int(2, false); - #[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 dest_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let dest_ptr = unsafe { builder .build_in_bounds_gep(element_type, array_ptr, &[index_val], "index") @@ -1551,19 +1301,9 @@ fn run_memset_on<'ctx>( let i32_type = context.i32_type(); let i64_type = context.i64_type(); let array_len = 4; - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let fn_type = i32_type.ptr_type(AddressSpace::default()).fn_type(&[], false); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let fn_type = context.ptr_type(AddressSpace::default()).fn_type(&[], false); let fn_value = module.add_function("test_fn", fn_type, None); let builder = context.create_builder(); @@ -1584,26 +1324,9 @@ fn run_memset_on<'ctx>( // Memset the second half of the array as -1 let val = i8_type.const_all_ones(); let index = i32_type.const_int(2, false); - #[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 part_2 = unsafe { builder.build_in_bounds_gep(array_ptr, &[index], "index") }.unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let part_2 = unsafe { builder .build_in_bounds_gep(element_type, array_ptr, &[index], "index") @@ -1654,33 +1377,13 @@ fn test_bit_cast() { let i32_type = context.i32_type(); let f64_type = context.f64_type(); let i64_type = context.i64_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()); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let i64_ptr_type = i64_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let i64_ptr_type = context.ptr_type(AddressSpace::default()); let i32_vec_type = i32_type.vec_type(2); let arg_types = [ @@ -1736,37 +1439,15 @@ fn test_atomicrmw() { let i31_type = context.custom_width_int_type(31); let i4_type = context.custom_width_int_type(4); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_value = i32_type.ptr_type(AddressSpace::default()).get_undef(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_value = context.ptr_type(AddressSpace::default()).get_undef(); let zero_value = i32_type.const_zero(); let result = builder.build_atomicrmw(AtomicRMWBinOp::Add, ptr_value, zero_value, AtomicOrdering::Unordered); assert!(result.is_ok()); - #[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 i64_type = context.i64_type(); let ptr_value = i64_type.ptr_type(AddressSpace::default()).get_undef(); @@ -1775,37 +1456,17 @@ fn test_atomicrmw() { assert!(result.is_err()); } - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_value = i31_type.ptr_type(AddressSpace::default()).get_undef(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_value = context.ptr_type(AddressSpace::default()).get_undef(); let zero_value = i31_type.const_zero(); let result = builder.build_atomicrmw(AtomicRMWBinOp::Add, ptr_value, zero_value, AtomicOrdering::Unordered); assert!(result.is_err()); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_value = i4_type.ptr_type(AddressSpace::default()).get_undef(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_value = context.ptr_type(AddressSpace::default()).get_undef(); let zero_value = i4_type.const_zero(); let result = builder.build_atomicrmw(AtomicRMWBinOp::Add, ptr_value, zero_value, AtomicOrdering::Unordered); @@ -1826,33 +1487,13 @@ fn test_cmpxchg() { let i32_type = context.i32_type(); let i64_type = context.i64_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()); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let i32_ptr_ptr_type = i32_ptr_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_ptr_type = context.ptr_type(AddressSpace::default()); let ptr_value = i32_ptr_type.get_undef(); @@ -1927,19 +1568,7 @@ fn test_cmpxchg() { ); assert!(result.is_err()); - #[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 ptr_value = i32_ptr_ptr_type.get_undef(); let zero_value = i32_type.const_zero(); @@ -1990,19 +1619,7 @@ fn test_cmpxchg() { ); assert!(result.is_ok()); - #[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 ptr_value = i32_ptr_type.get_undef(); let zero_value = i32_ptr_type.const_zero(); @@ -2025,35 +1642,15 @@ fn test_safe_struct_gep() { 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); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let struct_ptr_ty = struct_ty.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let struct_ptr_ty = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[i32_ptr_ty.into(), struct_ptr_ty.into()], false); let fn_value = module.add_function("", fn_type, None); @@ -2064,19 +1661,7 @@ fn test_safe_struct_gep() { let i32_ptr = fn_value.get_first_param().unwrap().into_pointer_value(); let struct_ptr = fn_value.get_last_param().unwrap().into_pointer_value(); - #[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)] { assert!(builder.build_struct_gep(i32_ptr, 0, "struct_gep").is_err()); assert!(builder.build_struct_gep(i32_ptr, 10, "struct_gep").is_err()); @@ -2084,12 +1669,7 @@ fn test_safe_struct_gep() { assert!(builder.build_struct_gep(struct_ptr, 1, "struct_gep").is_ok()); assert!(builder.build_struct_gep(struct_ptr, 2, "struct_gep").is_err()); } - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] { assert!(builder.build_struct_gep(i32_ty, i32_ptr, 0, "struct_gep").is_err()); assert!(builder.build_struct_gep(i32_ty, i32_ptr, 10, "struct_gep").is_err()); diff --git a/tests/all/test_context.rs b/tests/all/test_context.rs index 003eedf1439..c4730c6382f 100644 --- a/tests/all/test_context.rs +++ b/tests/all/test_context.rs @@ -53,19 +53,9 @@ fn test_values_get_context() { let i8_type = context.i8_type(); let f32_type = context.f32_type(); let f32_vec_type = f32_type.vec_type(3); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let f32_array_type = f32_type.array_type(2); let fn_type = f32_type.fn_type(&[], false); diff --git a/tests/all/test_debug_info.rs b/tests/all/test_debug_info.rs index 31408f0ef92..e1f92265a22 100644 --- a/tests/all/test_debug_info.rs +++ b/tests/all/test_debug_info.rs @@ -25,27 +25,9 @@ fn test_smoke() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -86,9 +68,9 @@ fn test_smoke() { let loc = dibuilder.create_debug_location(&context, 0, 0, lexical_block.as_debug_info_scope(), None); - #[cfg(any(feature = "llvm7-0", feature = "llvm8-0",))] + #[llvm_versions(7..9)] builder.set_current_debug_location(&context, loc); - #[cfg(not(any(feature = "llvm7-0", feature = "llvm8-0",)))] + #[llvm_versions(..)] builder.set_current_debug_location(loc); dibuilder.finalize(); @@ -115,27 +97,9 @@ fn test_struct_with_placeholders() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -247,27 +211,9 @@ fn test_no_explicit_finalize() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -296,27 +242,9 @@ fn test_replacing_placeholder_with_placeholder() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -327,7 +255,7 @@ fn test_replacing_placeholder_with_placeholder() { compile_unit.get_file(), 0, compile_unit.get_file().as_debug_info_scope(), - #[cfg(not(any(feature = "llvm8-0", feature = "llvm9-0")))] + #[llvm_versions(..)] 32, ); @@ -359,27 +287,9 @@ fn test_anonymous_basic_type() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -415,27 +325,9 @@ fn test_global_expressions() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -489,27 +381,9 @@ fn test_pointer_types() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -547,27 +421,9 @@ fn test_reference_types() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); @@ -606,27 +462,9 @@ fn test_array_type() { 0, false, false, - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] - "", - #[cfg(any( - feature = "llvm11-0", - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(11..)] + "", + #[llvm_versions(11..)] "", ); diff --git a/tests/all/test_execution_engine.rs b/tests/all/test_execution_engine.rs index bd056f00003..57f242a61ee 100644 --- a/tests/all/test_execution_engine.rs +++ b/tests/all/test_execution_engine.rs @@ -54,22 +54,12 @@ fn test_jit_execution_engine() { let module = context.create_module("main_module"); 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 i8_ptr_ptr_type = context .i8_type() .ptr_type(AddressSpace::default()) .ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let i8_ptr_ptr_type = context.ptr_type(AddressSpace::default()); let one_i32 = i32_type.const_int(1, false); let three_i32 = i32_type.const_int(3, false); diff --git a/tests/all/test_instruction_conversion.rs b/tests/all/test_instruction_conversion.rs index e129e711af9..452a2845f5f 100644 --- a/tests/all/test_instruction_conversion.rs +++ b/tests/all/test_instruction_conversion.rs @@ -110,19 +110,9 @@ fn test_conversion_to_pointer_value() { builder.position_at_end(basic_block); // Create a PointerType instruction - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let i64_ptr_type = context.i64_type().ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let i64_ptr_type = context.ptr_type(AddressSpace::default()); let alloca_instr = builder .build_alloca(i64_ptr_type, "alloca") diff --git a/tests/all/test_instruction_values.rs b/tests/all/test_instruction_values.rs index 539bbc1396d..46032240807 100644 --- a/tests/all/test_instruction_values.rs +++ b/tests/all/test_instruction_values.rs @@ -11,19 +11,9 @@ fn test_operands() { let builder = context.create_builder(); let void_type = context.void_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[f32_ptr_type.into()], false); @@ -87,19 +77,7 @@ fn test_operands() { assert!(free_instruction.set_operand(0, arg1)); // Module is no longer valid because free takes an i8* not f32* - #[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)] assert!(module.verify().is_err()); assert!(free_instruction.set_operand(0, free_operand0)); @@ -267,19 +245,9 @@ fn test_instructions() { let void_type = context.void_type(); let i64_type = context.i64_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[f32_ptr_type.into(), f32_type.into()], false); @@ -371,19 +339,9 @@ fn test_volatile_atomicrmw_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(), i32_type.into()], false); @@ -438,19 +396,9 @@ fn test_mem_instructions() { let void_type = context.void_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[f32_ptr_type.into(), f32_type.into()], false); @@ -516,19 +464,9 @@ fn test_mem_instructions() { let void_type = context.void_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[f32_ptr_type.into(), f32_type.into()], false); @@ -546,26 +484,9 @@ fn test_mem_instructions() { let f32_val = f32_type.const_float(std::f64::consts::PI); let store_instruction = builder.build_store(arg1, f32_val).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 load = builder.build_load(arg1, "").unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let load = builder.build_load(f32_type, arg1, "").unwrap(); let load_instruction = load.as_instruction_value().unwrap(); @@ -613,19 +534,9 @@ fn test_atomic_ordering_mem_instructions() { let void_type = context.void_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let f32_ptr_type = f32_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let f32_ptr_type = context.ptr_type(AddressSpace::default()); let fn_type = void_type.fn_type(&[f32_ptr_type.into(), f32_type.into()], false); @@ -643,26 +554,9 @@ fn test_atomic_ordering_mem_instructions() { let f32_val = f32_type.const_float(std::f64::consts::PI); let store_instruction = builder.build_store(arg1, f32_val).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 load = builder.build_load(arg1, "").unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let load = builder.build_load(f32_type, arg1, "").unwrap(); let load_instruction = load.as_instruction_value().unwrap(); @@ -706,19 +600,9 @@ fn test_metadata_kinds() { let i8_type = context.i8_type(); let f32_type = context.f32_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_type = i8_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let struct_type = context.struct_type(&[i8_type.into(), f32_type.into()], false); let vector_type = i8_type.vec_type(2); @@ -753,19 +637,9 @@ fn test_find_instruction_with_name() { 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); diff --git a/tests/all/test_module.rs b/tests/all/test_module.rs index 668dc6e6992..661cfb46250 100644 --- a/tests/all/test_module.rs +++ b/tests/all/test_module.rs @@ -346,7 +346,7 @@ fn test_get_set_target() { assert_eq!(module.get_name().to_str(), Ok("mod")); assert_eq!(module.get_triple(), TargetTriple::create("")); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] assert_eq!(module.get_source_file_name().to_str(), Ok("mod")); module.set_name("mod2"); @@ -355,7 +355,7 @@ fn test_get_set_target() { assert_eq!(module.get_name().to_str(), Ok("mod2")); assert_eq!(module.get_triple(), triple); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] { module.set_source_file_name("foo.rs"); @@ -438,7 +438,7 @@ fn test_linking_modules() { #[test] fn test_metadata_flags() { - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] { let context = Context::create(); let module = context.create_module("my_module"); diff --git a/tests/all/test_passes.rs b/tests/all/test_passes.rs index d1138e61362..d7b324cba3c 100644 --- a/tests/all/test_passes.rs +++ b/tests/all/test_passes.rs @@ -13,29 +13,10 @@ fn test_init_all_passes_for_module() { let module = context.create_module("my_module"); let pass_manager = PassManager::create(()); - #[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)] pass_manager.add_argument_promotion_pass(); pass_manager.add_constant_merge_pass(); - #[cfg(not(any( - feature = "llvm4-0", - feature = "llvm5-0", - feature = "llvm6-0", - feature = "llvm7-0", - feature = "llvm8-0", - feature = "llvm9-0" - )))] + #[llvm_versions(10..)] pass_manager.add_merge_functions_pass(); pass_manager.add_dead_arg_elimination_pass(); pass_manager.add_function_attrs_pass(); @@ -43,13 +24,7 @@ fn test_init_all_passes_for_module() { pass_manager.add_always_inliner_pass(); pass_manager.add_global_dce_pass(); pass_manager.add_global_optimizer_pass(); - #[cfg(not(any( - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0" - )))] + #[llvm_versions(..)] pass_manager.add_ip_constant_propagation_pass(); #[cfg(not(feature = "llvm16-0"))] pass_manager.add_prune_eh_pass(); @@ -78,19 +53,7 @@ fn test_init_all_passes_for_module() { pass_manager.add_loop_rotate_pass(); pass_manager.add_loop_reroll_pass(); pass_manager.add_loop_unroll_pass(); - #[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)] pass_manager.add_loop_unswitch_pass(); pass_manager.add_memcpy_optimize_pass(); pass_manager.add_partially_inline_lib_calls_pass(); @@ -103,21 +66,9 @@ fn test_init_all_passes_for_module() { pass_manager.add_scalar_repl_aggregates_pass_with_threshold(1); pass_manager.add_simplify_lib_calls_pass(); pass_manager.add_tail_call_elimination_pass(); - #[cfg(not(any( - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0" - )))] + #[llvm_versions(..)] pass_manager.add_constant_propagation_pass(); - #[cfg(any( - feature = "llvm12-0", - feature = "llvm13-0", - feature = "llvm14-0", - feature = "llvm15-0", - feature = "llvm16-0" - ))] + #[llvm_versions(12..17)] pass_manager.add_instruction_simplify_pass(); pass_manager.add_demote_memory_to_register_pass(); pass_manager.add_verifier_pass(); @@ -130,19 +81,12 @@ fn test_init_all_passes_for_module() { pass_manager.add_early_cse_mem_ssa_pass(); pass_manager.add_new_gvn_pass(); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm16-0")))] + #[llvm_versions(7..)] pass_manager.add_aggressive_inst_combiner_pass(); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] pass_manager.add_loop_unroll_and_jam_pass(); - #[cfg(not(any( - feature = "llvm4-0", - feature = "llvm5-0", - feature = "llvm6-0", - feature = "llvm7-0", - feature = "llvm15-0", - feature = "llvm16-0" - )))] + #[llvm_versions(8..)] { pass_manager.add_coroutine_early_pass(); pass_manager.add_coroutine_split_pass(); @@ -193,19 +137,7 @@ fn test_pass_manager_builder() { pass_manager_builder.populate_module_pass_manager(&module_pass_manager); - #[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 module2 = module.clone(); @@ -215,9 +147,9 @@ fn test_pass_manager_builder() { assert!(lto_pass_manager.run_on(&module2)); } - #[cfg(any(feature = "llvm4-0", feature = "llvm5-0"))] + #[llvm_versions(..6)] assert!(!module_pass_manager.run_on(&module)); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0")))] + #[llvm_versions(6..)] assert!(module_pass_manager.run_on(&module)); } @@ -239,7 +171,7 @@ fn test_pass_registry() { pass_registry.initialize_ipa(); pass_registry.initialize_codegen(); pass_registry.initialize_target(); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm16-0")))] + #[llvm_versions(7..)] pass_registry.initialize_aggressive_inst_combiner(); } diff --git a/tests/all/test_targets.rs b/tests/all/test_targets.rs index dad038bdf73..15f4bc8c71f 100644 --- a/tests/all/test_targets.rs +++ b/tests/all/test_targets.rs @@ -97,12 +97,12 @@ fn test_target_and_target_machine() { let bad_target2 = Target::from_triple(&TargetTriple::create("sadas")); - #[cfg(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm7-0"))] + #[llvm_versions(..8)] assert_eq!( bad_target2.unwrap_err().to_string(), "No available targets are compatible with this triple." ); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm7-0")))] + #[llvm_versions(8..)] assert_eq!( bad_target2.unwrap_err().to_string(), "No available targets are compatible with triple \"sadas\"" @@ -165,7 +165,7 @@ fn test_target_and_target_machine() { assert_eq!(target_machine.get_cpu().to_str(), Ok("x86-64")); assert_eq!(target_machine.get_feature_string().to_str(), Ok("+avx2")); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] { // TODO: Try and find a triple that actually gets normalized.. assert_eq!( diff --git a/tests/all/test_types.rs b/tests/all/test_types.rs index d1e782652fa..b149b9e75de 100644 --- a/tests/all/test_types.rs +++ b/tests/all/test_types.rs @@ -160,12 +160,7 @@ fn sized_types(global_ctx: &Context) { let f80_type = global_ctx.x86_f80_type(); let f128_type = global_ctx.f128_type(); let ppc_f128_type = global_ctx.ppc_f128_type(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = global_ctx.ptr_type(AddressSpace::default()); let struct_type = global_ctx.struct_type(&[i8_type.into(), f128_type.into()], false); let struct_type2 = global_ctx.struct_type(&[], false); @@ -191,12 +186,7 @@ fn sized_types(global_ctx: &Context) { assert!(f80_type.is_sized()); assert!(f128_type.is_sized()); assert!(ppc_f128_type.is_sized()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] assert!(ptr_type.is_sized()); assert!(struct_type.is_sized()); assert!(struct_type2.is_sized()); @@ -207,12 +197,7 @@ fn sized_types(global_ctx: &Context) { assert!(!fn_type3.is_sized()); assert!(!fn_type4.is_sized()); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] { assert!(bool_type.ptr_type(AddressSpace::default()).is_sized()); assert!(i8_type.ptr_type(AddressSpace::default()).is_sized()); @@ -244,12 +229,7 @@ fn sized_types(global_ctx: &Context) { assert!(f80_type.array_type(42).is_sized()); assert!(f128_type.array_type(42).is_sized()); assert!(ppc_f128_type.array_type(42).is_sized()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] assert!(ptr_type.array_type(42).is_sized()); assert!(struct_type.array_type(0).is_sized()); assert!(struct_type2.array_type(0).is_sized()); @@ -268,12 +248,7 @@ fn sized_types(global_ctx: &Context) { assert!(f80_type.vec_type(42).is_sized()); assert!(f128_type.vec_type(42).is_sized()); assert!(ppc_f128_type.vec_type(42).is_sized()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] assert!(ptr_type.vec_type(42).is_sized()); let opaque_struct_type = global_ctx.opaque_struct_type("opaque"); @@ -281,12 +256,7 @@ fn sized_types(global_ctx: &Context) { assert!(!opaque_struct_type.is_sized()); assert!(!opaque_struct_type.array_type(0).is_sized()); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] { let opaque_struct_ptr_type = opaque_struct_type.ptr_type(AddressSpace::default()); assert!(opaque_struct_ptr_type.is_sized()); @@ -309,19 +279,9 @@ fn test_const_zero() { let f128_type = context.f128_type(); let ppc_f128_type = context.ppc_f128_type(); let struct_type = context.struct_type(&[i8_type.into(), f128_type.into()], false); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_type = f64_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let vec_type = f64_type.vec_type(42); let array_type = f64_type.array_type(42); @@ -442,36 +402,14 @@ fn test_type_copies() { #[test] fn test_ptr_type() { let context = Context::create(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let 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 ptr_type = context.ptr_type(AddressSpace::default()); assert_eq!(ptr_type.get_address_space(), AddressSpace::default()); - #[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)] assert_eq!(ptr_type.get_element_type().into_int_type(), context.i8_type()); // Fn ptr: @@ -480,19 +418,7 @@ fn test_ptr_type() { #[allow(deprecated)] let fn_ptr_type = fn_type.ptr_type(AddressSpace::default()); - #[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)] assert_eq!(fn_ptr_type.get_element_type().into_function_type(), fn_type); assert_eq!(fn_ptr_type.get_context(), context); @@ -511,30 +437,15 @@ fn test_basic_type_enum() { &context.f64_type(), // derived types &int.array_type(0), - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] &int.ptr_type(addr), - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] &context.ptr_type(addr), &context.struct_type(&[int.as_basic_type_enum()], false), &int.vec_type(1), ]; for basic_type in types { - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] assert_eq!( basic_type.as_basic_type_enum().ptr_type(addr), basic_type.ptr_type(addr) @@ -561,19 +472,9 @@ fn test_ptr_address_space() { for index in spaces { let address_space = AddressSpace::try_from(index).unwrap(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr = context.i32_type().ptr_type(address_space); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr = context.ptr_type(address_space); assert_eq!(ptr.get_address_space(), address_space); } diff --git a/tests/all/test_values.rs b/tests/all/test_values.rs index bba39fab60d..247c4b3c1d3 100644 --- a/tests/all/test_values.rs +++ b/tests/all/test_values.rs @@ -111,12 +111,7 @@ fn test_set_get_name() { let f32_type = context.f32_type(); let f64_type = context.f64_type(); let f128_type = context.f128_type(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let array_type = f64_type.array_type(42); let ppc_f128_type = context.ppc_f128_type(); @@ -131,19 +126,9 @@ fn test_set_get_name() { let f32_val = f32_type.const_float(0.0); let f64_val = f64_type.const_float(0.0); let f128_val = f128_type.const_float(0.0); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_val = bool_type.ptr_type(AddressSpace::default()).const_null(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_val = ptr_type.const_null(); let array_val = f64_type.const_array(&[f64_val]); let struct_val = context.const_struct(&[i8_val.into(), f128_val.into()], false); @@ -200,19 +185,9 @@ fn test_set_get_name() { assert_eq!(ppc_f128_val.get_name().to_str(), Ok("")); let void_type = context.void_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_type = bool_type.ptr_type(AddressSpace::default()); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let struct_type = context.struct_type(&[bool_type.into()], false); let vec_type = bool_type.vec_type(1); @@ -284,12 +259,7 @@ fn test_undef() { let f32_type = context.f32_type(); let f64_type = context.f64_type(); let f128_type = context.f128_type(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let array_type = f64_type.array_type(42); let ppc_f128_type = context.ppc_f128_type(); @@ -306,19 +276,9 @@ fn test_undef() { let f32_val = f32_type.const_float(0.0); let f64_val = f64_type.const_float(0.0); let f128_val = f128_type.const_float(0.0); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_val = bool_type.ptr_type(AddressSpace::default()).const_null(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_val = ptr_type.const_null(); let array_val = f64_type.const_array(&[f64_val]); let struct_val = context.const_struct(&[i8_val.into(), f128_val.into()], false); @@ -351,19 +311,9 @@ fn test_undef() { let f32_undef = f32_type.get_undef(); let f64_undef = f64_type.get_undef(); let f128_undef = f128_type.get_undef(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_undef = bool_type.ptr_type(AddressSpace::default()).get_undef(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_undef = ptr_type.get_undef(); let array_undef = array_type.get_undef(); let struct_undef = context.struct_type(&[bool_type.into()], false).get_undef(); @@ -401,12 +351,7 @@ fn test_poison() { let f32_type = context.f32_type(); let f64_type = context.f64_type(); let f128_type = context.f128_type(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_type = context.ptr_type(AddressSpace::default()); let array_type = f64_type.array_type(42); let ppc_f128_type = context.ppc_f128_type(); @@ -423,19 +368,9 @@ fn test_poison() { let f32_val = f32_type.const_float(0.0); let f64_val = f64_type.const_float(0.0); let f128_val = f128_type.const_float(0.0); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_val = bool_type.ptr_type(AddressSpace::default()).const_null(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_val = ptr_type.const_null(); let array_val = f64_type.const_array(&[f64_val]); let struct_val = context.const_struct(&[i8_val.into(), f128_val.into()], false); @@ -468,19 +403,9 @@ fn test_poison() { let f32_poison = f32_type.get_poison(); let f64_poison = f64_type.get_poison(); let f128_poison = f128_type.get_poison(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let ptr_poison = bool_type.ptr_type(AddressSpace::default()).get_poison(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] let ptr_poison = ptr_type.get_poison(); let array_poison = array_type.get_poison(); let struct_poison = context.struct_type(&[bool_type.into()], false).get_poison(); @@ -594,13 +519,13 @@ fn test_metadata() { assert_eq!(context.get_kind_id("associated"), 22); } - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0")))] + #[llvm_versions(6..)] { assert_eq!(context.get_kind_id("callees"), 23); assert_eq!(context.get_kind_id("irr_loop"), 24); } - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] { assert_eq!(module.get_global_metadata_size("my_string_md"), 0); assert_eq!(module.get_global_metadata("my_string_md").len(), 0); @@ -624,7 +549,7 @@ fn test_metadata() { let f32_type = context.f32_type(); // let f64_type = context.f64_type(); // let f128_type = context.f128_type(); - // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))] + // #[llvm_versions(15..)] // let ptr_type = context.ptr_type(AddressSpace::default()); // let array_type = f64_type.array_type(42); // let ppc_f128_type = context.ppc_f128_type(); @@ -641,9 +566,9 @@ fn test_metadata() { // let f64_val = f64_type.const_float(0.0); // let f128_val = f128_type.const_float(0.0); // let ppc_f128_val = ppc_f128_type.const_float(0.0); - // #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))] + // #[llvm_versions(..15)] // let ptr_val = bool_type.ptr_type(AddressSpace::default()).const_null(); - // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))] + // #[llvm_versions(15..)] // let ptr_val = ptr_type.const_null(); // let array_val = f64_type.const_array(&[f64_val]); // let struct_val = context.const_struct(&[i8_val.into(), f128_val.into()], false); @@ -747,7 +672,7 @@ fn test_metadata() { #[test] fn test_floats() { - #[cfg(not(any(feature = "llvm15-0", feature = "llvm18-0")))] + #[llvm_versions(..18)] { use inkwell::FloatPredicate; @@ -782,7 +707,7 @@ fn test_floats() { let f64_one = f64_type.const_float(1.); let f64_two = f64_type.const_float(2.); - #[cfg(not(any(feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))] + #[llvm_versions(..16)] { let neg_two = f64_two.const_neg(); @@ -942,7 +867,7 @@ fn test_globals() { let global = module.add_global(i8_type, None, "my_global"); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] assert_eq!(global.get_unnamed_address(), UnnamedAddress::None); assert!(global.get_previous_global().is_none()); assert!(global.get_next_global().is_none()); @@ -958,7 +883,7 @@ fn test_globals() { assert_eq!(global.get_dll_storage_class(), DLLStorageClass::default()); assert_eq!(global.get_visibility(), GlobalVisibility::default()); assert_eq!(global.get_linkage(), External); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm7-0")))] + #[llvm_versions(8..)] assert_eq!(global.get_value_type(), AnyTypeEnum::IntType(i8_type)); assert_eq!(module.get_first_global().unwrap(), global); assert_eq!(module.get_last_global().unwrap(), global); @@ -970,7 +895,7 @@ fn test_globals() { assert!(module.get_global("my_global").is_none()); assert_eq!(module.get_global("glob").unwrap(), global); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] global.set_unnamed_address(UnnamedAddress::Local); global.set_dll_storage_class(DLLStorageClass::Import); global.set_initializer(&i8_zero); @@ -981,7 +906,7 @@ fn test_globals() { global.set_section(Some("not sure what goes here")); // REVIEW: Not sure why this is Global when we set it to Local - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] assert_eq!(global.get_unnamed_address(), UnnamedAddress::Global); assert_eq!(global.get_dll_storage_class(), DLLStorageClass::Import); assert_eq!(global.get_initializer().unwrap().into_int_value(), i8_zero); @@ -1006,14 +931,14 @@ fn test_globals() { assert_eq!(global.get_linkage(), Private); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] global.set_unnamed_address(UnnamedAddress::Global); global.set_dll_storage_class(DLLStorageClass::Export); global.set_thread_local(false); global.set_linkage(External); global.set_visibility(GlobalVisibility::Protected); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] assert_eq!(global.get_unnamed_address(), UnnamedAddress::Global); assert!(!global.is_thread_local()); assert_eq!(global.get_visibility(), GlobalVisibility::Protected); @@ -1065,7 +990,7 @@ fn test_globals() { // REVIEW: This doesn't seem to work. LLVM bug? assert!(global2.is_externally_initialized()); - #[cfg(not(any(feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))] + #[llvm_versions(7..)] { assert!(global.get_comdat().is_none()); @@ -1434,19 +1359,9 @@ fn test_non_fn_ptr_called() { let builder = context.create_builder(); let module = context.create_module("my_mod"); let i8_type = context.i8_type(); - #[cfg(not(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - )))] + #[llvm_versions(..15)] let i8_ptr_type = 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 fn_type = i8_type.fn_type(&[i8_ptr_type.into()], false); let fn_value = module.add_function("my_func", fn_type, None); @@ -1454,30 +1369,13 @@ fn test_non_fn_ptr_called() { let i8_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value(); builder.position_at_end(bb); - #[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)] { use inkwell::values::CallableValue; let callable_value = CallableValue::try_from(i8_ptr_param).unwrap(); builder.build_call(callable_value, &[], "call").unwrap(); } - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] builder .build_indirect_call(i8_ptr_type.fn_type(&[], false), i8_ptr_param, &[], "call") .unwrap(); @@ -1520,19 +1418,9 @@ fn test_aggregate_returns() { let builder = context.create_builder(); let module = context.create_module("my_mod"); 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_three = i32_type.const_int(3, false); let i32_seven = i32_type.const_int(7, false); @@ -1544,26 +1432,9 @@ fn test_aggregate_returns() { let ptr_param2 = fn_value.get_nth_param(1).unwrap().into_pointer_value(); builder.position_at_end(bb); - #[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)] builder.build_ptr_diff(ptr_param1, ptr_param2, "diff").unwrap(); - #[cfg(any( - feature = "llvm15-0", - feature = "llvm16-0", - feature = "llvm17-0", - feature = "llvm18-0" - ))] + #[llvm_versions(15..)] builder .build_ptr_diff(i32_ptr_type, ptr_param1, ptr_param2, "diff") .unwrap();