Skip to content

Commit 75530c0

Browse files
authored
Merge pull request rust-lang#106 from wasmerio/debug
A block without a parent doesn't have a next/previous. Return None in those cases.
2 parents b06c41e + f8e9228 commit 75530c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/basic_block.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl BasicBlock {
9595
/// assert_eq!(basic_block3.get_previous_basic_block().unwrap(), basic_block2);
9696
/// ```
9797
pub fn get_previous_basic_block(&self) -> Option<BasicBlock> {
98+
if self.get_parent().is_none() {
99+
return None;
100+
}
101+
98102
let bb = unsafe {
99103
LLVMGetPreviousBasicBlock(self.basic_block)
100104
};
@@ -130,6 +134,10 @@ impl BasicBlock {
130134
/// assert!(basic_block3.get_next_basic_block().is_none());
131135
/// ```
132136
pub fn get_next_basic_block(&self) -> Option<BasicBlock> {
137+
if self.get_parent().is_none() {
138+
return None;
139+
}
140+
133141
let bb = unsafe {
134142
LLVMGetNextBasicBlock(self.basic_block)
135143
};

0 commit comments

Comments
 (0)