@@ -97,6 +97,12 @@ public struct BasicBlock: BasicBlockRef {
9797 self . context = context
9898 }
9999
100+ /// Create a new basic block without inserting it into a function.
101+ public static func createBasicBlockInContext( context: Context , name: String ) -> BasicBlockRef ? {
102+ guard let blockRef = LLVMCreateBasicBlockInContext ( context. contextRef, name) else { return nil }
103+ return BasicBlock ( llvm: blockRef)
104+ }
105+
100106 /// Given that this block and a given block share a parent function, move this
101107 /// block before the given block in that function's basic block list.
102108 ///
@@ -146,7 +152,7 @@ public struct BasicBlock: BasicBlockRef {
146152 /// Returns the first instruction in the basic block, if it exists.
147153 public static func getFirstInstruction( basicBlock: BasicBlockRef ) -> ValueRef ? {
148154 guard let val = LLVMGetFirstInstruction ( basicBlock. basicBlockRef) else { return nil }
149- return Values ( llvm: val)
155+ return Value ( llvm: val)
150156 }
151157
152158 /// Returns the first instruction in the basic block, if it exists.
@@ -157,7 +163,7 @@ public struct BasicBlock: BasicBlockRef {
157163 /// Returns the first instruction in the basic block, if it exists.
158164 public static func getLastInstruction( basicBlock: BasicBlockRef ) -> ValueRef ? {
159165 guard let val = LLVMGetLastInstruction ( basicBlock. basicBlockRef) else { return nil }
160- return Values ( llvm: val)
166+ return Value ( llvm: val)
161167 }
162168
163169 /// Returns the parent function of this basic block, if it exists.
@@ -249,7 +255,7 @@ public struct BasicBlock: BasicBlockRef {
249255 /// Convert a basic block instance to a value type.
250256 public static func basicBlockAsValue( basicBlockRef: BasicBlockRef ) -> ValueRef ? {
251257 guard let valueRef = LLVMBasicBlockAsValue ( basicBlockRef. basicBlockRef) else { return nil }
252- return Values ( llvm: valueRef)
258+ return Value ( llvm: valueRef)
253259 }
254260
255261 /// Determine whether an LLVMValueRef is itself a basic block.
@@ -347,14 +353,14 @@ public struct BasicBlock: BasicBlockRef {
347353 /// Returns the terminator instruction for current block. If a basic block is well formed or `nil` if it is not well formed.
348354 public var getBasicBlockTerminator : ValueRef ? {
349355 guard let valueRef = LLVMGetBasicBlockTerminator ( llvm) else { return nil }
350- return Values ( llvm: valueRef)
356+ return Value ( llvm: valueRef)
351357 }
352358
353359 /// Returns the terminator instruction if a basic block is well formed or `nil` if it is not well formed.
354360 /// The returned LLVMValueRef corresponds to an llvm::Instruction.
355361 public static func getBasicBlockTerminator( basicBlockRef: BasicBlockRef ) -> ValueRef ? {
356362 guard let valueRef = LLVMGetBasicBlockTerminator ( basicBlockRef. basicBlockRef) else { return nil }
357- return Values ( llvm: valueRef)
363+ return Value ( llvm: valueRef)
358364 }
359365}
360366
0 commit comments