pub struct FunctionValue<'ctx> { /* private fields */ }

Implementations

Instantiate a new FunctionValue from a raw LLVM value pointer.

Gets the name of a FunctionValue.

View the control flow graph and produce a .dot file

Only view the control flow graph

Adds an Attribute to a particular location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

Counts the number of Attributes belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.count_attributes(AttributeLoc::Return), 2);

Get all Attributes belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.attributes(AttributeLoc::Return), vec![string_attribute, enum_attribute]);

Removes a string Attribute belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");

fn_value.add_attribute(AttributeLoc::Return, string_attribute);
fn_value.remove_string_attribute(AttributeLoc::Return, "my_key");

Removes an enum Attribute belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, enum_attribute);
fn_value.remove_enum_attribute(AttributeLoc::Return, 1);

Gets an enum Attribute belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let enum_attribute = context.create_enum_attribute(1, 1);

fn_value.add_attribute(AttributeLoc::Return, enum_attribute);

assert_eq!(fn_value.get_enum_attribute(AttributeLoc::Return, 1), Some(enum_attribute));

Gets a string Attribute belonging to the specified location in this FunctionValue.

Example
use inkwell::attributes::AttributeLoc;
use inkwell::context::Context;

let context = Context::create();
let module = context.create_module("my_mod");
let void_type = context.void_type();
let fn_type = void_type.fn_type(&[], false);
let fn_value = module.add_function("my_fn", fn_type, None);
let string_attribute = context.create_string_attribute("my_key", "my_val");

fn_value.add_attribute(AttributeLoc::Return, string_attribute);

assert_eq!(fn_value.get_string_attribute(AttributeLoc::Return, "my_key"), Some(string_attribute));

Gets the GlobalValue version of this FunctionValue. This allows you to further inspect its global properties or even convert it to a PointerValue.

Set the debug info descriptor

Get the debug info descriptor

Get the section to which this function belongs

Set the section to which this function should belong

Trait Implementations

Returns an enum containing a typed version of AnyValue.

Prints a value to a LLVMString

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.