Skip to content

Commit

Permalink
Merge pull request #8 from folkertdev/fix-invoke-tests
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
folkertdev authored Jun 12, 2021
2 parents 98f9714 + 772d82d commit b5aa513
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl<'ctx> Builder<'ctx> {
/// ```no_run
/// use inkwell::context::Context;
/// use inkwell::AddressSpace;
/// use inkwell::module::Linkage;
///
/// let context = Context::create();
/// let module = context.create_module("sum");
Expand Down Expand Up @@ -235,7 +236,7 @@ impl<'ctx> Builder<'ctx> {
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
///
/// let null = i8_ptr_type.const_zero();
/// let res = builder.build_landing_pad(exception_type, personality_function, &[null], false, "res");
/// let res = builder.build_landing_pad(exception_type, personality_function, &[null.into()], false, "res");
///
/// // we handle the exception by returning a default value
/// builder.build_return(Some(&f32_type.const_zero()));
Expand Down Expand Up @@ -297,6 +298,7 @@ impl<'ctx> Builder<'ctx> {
/// ```no_run
/// use inkwell::context::Context;
/// use inkwell::AddressSpace;
/// use inkwell::module::Linkage;
///
/// let context = Context::create();
/// let module = context.create_module("sum");
Expand Down Expand Up @@ -325,6 +327,7 @@ impl<'ctx> Builder<'ctx> {
/// ```no_run
/// use inkwell::context::Context;
/// use inkwell::AddressSpace;
/// use inkwell::module::Linkage;
///
/// let context = Context::create();
/// let module = context.create_module("sum");
Expand All @@ -347,7 +350,7 @@ impl<'ctx> Builder<'ctx> {
/// let null = i8_ptr_type.const_zero();
///
/// // make the catch all landing pad
/// let res = builder.build_landing_pad(exception_type, personality_function, &[null], false, "res");
/// let res = builder.build_landing_pad(exception_type, personality_function, &[null.into()], false, "res");
/// ```
///
/// * **catch a type of exception**: Catch a specific type of exception. The example uses C++'s type info.
Expand All @@ -356,6 +359,7 @@ impl<'ctx> Builder<'ctx> {
/// use inkwell::context::Context;
/// use inkwell::module::Linkage;
/// use inkwell::AddressSpace;
/// use inkwell::values::BasicValue;
///
/// let context = Context::create();
/// let module = context.create_module("sum");
Expand All @@ -379,7 +383,8 @@ impl<'ctx> Builder<'ctx> {
/// type_info_int.set_linkage(Linkage::External);
///
/// // make the catch landing pad
/// let res = builder.build_landing_pad(exception_type, personality_function, &[type_info_int], false, "res");
/// let clause = type_info_int.as_basic_value_enum();
/// let res = builder.build_landing_pad(exception_type, personality_function, &[clause], false, "res");
/// ```
///
/// * **filter**: A filter clause encodes that only some types of exceptions are valid at this
Expand Down Expand Up @@ -414,7 +419,7 @@ impl<'ctx> Builder<'ctx> {
///
/// // make the filter landing pad
/// let filter_pattern = i8_ptr_type.const_array(&[type_info_int.as_any_value_enum().into_pointer_value()]);
/// let res = builder.build_landing_pad(exception_type, personality_function, &[filter_pattern], false, "res");
/// let res = builder.build_landing_pad(exception_type, personality_function, &[filter_pattern.into()], false, "res");
/// ```
pub fn build_landing_pad<T>(
&self,
Expand Down Expand Up @@ -465,6 +470,7 @@ impl<'ctx> Builder<'ctx> {
/// ```no_run
/// use inkwell::context::Context;
/// use inkwell::AddressSpace;
/// use inkwell::module::Linkage;
///
/// let context = Context::create();
/// let module = context.create_module("sum");
Expand Down
7 changes: 3 additions & 4 deletions tests/all/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ fn test_build_invoke_cleanup_resume() {
let i32_type = context.i32_type();
let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);

let clauses: &[inkwell::values::PointerValue] = &[];
let res = builder.build_landing_pad( exception_type, personality_function, clauses, true, "res");
let res = builder.build_landing_pad(exception_type, personality_function, &[], true, "res");

// do cleanup ...

Expand Down Expand Up @@ -193,7 +192,7 @@ fn test_build_invoke_catch_all() {
let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);

let null = i8_ptr_type.const_zero();
let res = builder.build_landing_pad(exception_type, personality_function, &[null], false, "res");
let res = builder.build_landing_pad(exception_type, personality_function, &[null.into()], false, "res");

let fakepi = f32_type.const_zero();

Expand Down Expand Up @@ -269,7 +268,7 @@ fn landing_pad_filter() {

// make the filter landing pad
let filter_pattern = i8_ptr_type.const_array(&[type_info_int.as_any_value_enum().into_pointer_value()]);
let res = builder.build_landing_pad(exception_type, personality_function, &[filter_pattern], false, "res");
let res = builder.build_landing_pad(exception_type, personality_function, &[filter_pattern.into()], false, "res");

let fakepi = f32_type.const_zero();

Expand Down

0 comments on commit b5aa513

Please sign in to comment.