File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 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 {
4040 return Instruction ( llvm: val)
4141 }
4242
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 )
4747 }
4848
4949 /// 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 {
400400 return BasicBlock ( llvm: blockRef)
401401 }
402402
403+ /// Gets the function this builder is building into.
404+ public var currentFunction : Function ? {
405+ return insertBlock? . parent
406+ }
407+
403408 /// Inserts the given instruction into the IR Builder.
404409 ///
405410 /// - parameter inst: The instruction to insert.
You can’t perform that action at this time.
0 commit comments