Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/LLVM/BasicBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/LLVM/Function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Sources/LLVM/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down