File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,10 @@ public struct BasicBlock: IRValue {
40
40
return Instruction ( llvm: val)
41
41
}
42
42
43
- /// Returns the parent of this basic block, if it exists.
44
- public func parent( ) -> BasicBlock ? {
45
- guard let blockRef = LLVMGetBasicBlockParent ( llvm) else { return nil }
46
- return BasicBlock ( llvm: blockRef )
43
+ /// Returns the parent function of this basic block, if it exists.
44
+ public var parent : Function ? {
45
+ guard let functionRef = LLVMGetBasicBlockParent ( llvm) else { return nil }
46
+ return Function ( llvm: functionRef )
47
47
}
48
48
49
49
/// Returns the basic block following this basic block, if it exists.
Original file line number Diff line number Diff line change @@ -400,6 +400,11 @@ public class IRBuilder {
400
400
return BasicBlock ( llvm: blockRef)
401
401
}
402
402
403
+ /// Gets the function this builder is building into.
404
+ public var currentFunction : Function ? {
405
+ return insertBlock? . parent
406
+ }
407
+
403
408
/// Inserts the given instruction into the IR Builder.
404
409
///
405
410
/// - parameter inst: The instruction to insert.
You can’t perform that action at this time.
0 commit comments