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

Context::metadata_string doc example returns an error #484

Open
DaniPopes opened this issue Mar 22, 2024 · 0 comments
Open

Context::metadata_string doc example returns an error #484

DaniPopes opened this issue Mar 22, 2024 · 0 comments
Labels

Comments

@DaniPopes
Copy link
Contributor

Describe the Bug
Context::metadata_string doc example returns "metadata is expected to be a node.", due to calling InstructionValue::set_metadata

To Reproduce

inkwell/src/context.rs

Lines 1970 to 2001 in 69c5a3f

/// Creates a `MetadataValue` string for the current context. It can be assigned to a value.
///
/// # Example
///
/// ```no_run
/// use inkwell::context::Context;
///
/// let context = Context::create();
/// let md_string = context.metadata_string("Floats are awesome!");
/// let f32_type = context.f32_type();
/// let f32_one = f32_type.const_float(1.);
/// let void_type = context.void_type();
///
/// let builder = context.create_builder();
/// let module = context.create_module("my_mod");
/// let fn_type = void_type.fn_type(&[f32_type.into()], false);
/// let fn_value = module.add_function("my_func", fn_type, None);
/// let entry_block = context.append_basic_block(fn_value, "entry");
///
/// builder.position_at_end(entry_block);
///
/// let ret_instr = builder.build_return(None).unwrap();
///
/// assert!(md_string.is_string());
///
/// ret_instr.set_metadata(md_string, 0);
/// ```
// REVIEW: Seems to be unassigned to anything
#[inline]
pub fn metadata_string(&self, string: &str) -> MetadataValue<'ctx> {
self.context.metadata_string(string)
}

Expected Behavior
A working example

LLVM Version (please complete the following information):

  • LLVM Version: 17.0
  • Inkwell Branch Used: llvm17-0

Desktop (please complete the following information):

  • OS: N/A

Additional Context
Opened an issue since I don't know how to fix it myself (:

@TheDan64 TheDan64 added the bug label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants