1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use llvm_sys::{core::LLVMGetBasicBlockParent, prelude::LLVMBasicBlockRef};
use std::marker::PhantomData;
use super::FnValue;
#[derive(Copy, Clone)]
pub struct BasicBlock<'llvm>(LLVMBasicBlockRef, PhantomData<&'llvm ()>);
impl<'llvm> BasicBlock<'llvm> {
pub(super) fn new(bb_ref: LLVMBasicBlockRef) -> BasicBlock<'llvm> {
assert!(!bb_ref.is_null());
BasicBlock(bb_ref, PhantomData)
}
#[inline]
pub(super) fn bb_ref(&self) -> LLVMBasicBlockRef {
self.0
}
pub fn get_parent(&self) -> FnValue<'llvm> {
let value_ref = unsafe { LLVMGetBasicBlockParent(self.bb_ref()) };
assert!(!value_ref.is_null());
FnValue::new(value_ref)
}
}