diff --git a/Sources/LLVM/BasicBlock.swift b/Sources/LLVM/BasicBlock.swift index 33000845..613eaa11 100644 --- a/Sources/LLVM/BasicBlock.swift +++ b/Sources/LLVM/BasicBlock.swift @@ -50,7 +50,10 @@ public struct BasicBlock: IRValue, Sequence { return BasicBlock(llvm: blockRef) } - /// Removes this basic block from a function and deletes it. + /// Deletes the basic block from its containing function. + /// - note: This does not remove breaks to this block from the + /// function. Ensure you have removed all insructions that reference + /// this basic block before deleting it. public func delete() { LLVMDeleteBasicBlock(llvm) } diff --git a/Sources/LLVM/Function.swift b/Sources/LLVM/Function.swift index 2cfd5c5d..0e4cbe62 100644 --- a/Sources/LLVM/Function.swift +++ b/Sources/LLVM/Function.swift @@ -99,6 +99,14 @@ public class Function: IRValue { return BasicBlock(llvm: block) } + /// Deletes the function from its containing module. + /// - note: This does not remove calls to this function from the + /// module. Ensure you have removed all insructions that reference + /// this function before deleting it. + public func delete() { + LLVMDeleteFunction(llvm) + } + /// Retrieves the underlying LLVM value object. public func asLLVM() -> LLVMValueRef { return llvm diff --git a/Sources/LLVM/Global.swift b/Sources/LLVM/Global.swift index 3a992c52..97ef4e03 100644 --- a/Sources/LLVM/Global.swift +++ b/Sources/LLVM/Global.swift @@ -33,6 +33,14 @@ public struct Global: IRValue { set { LLVMSetThreadLocal(asLLVM(), newValue.llvm) } } + /// Deletes the global variable from its containing module. + /// - note: This does not remove references to this global from the + /// module. Ensure you have removed all insructions that reference + /// this global before deleting it. + public func delete() { + LLVMDeleteGlobal(llvm) + } + /// Retrieves the underlying LLVM value object. public func asLLVM() -> LLVMValueRef { return llvm