Skip to content

Deprecate BasicBlock.delete() with a stern warning #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2017
Merged
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
24 changes: 16 additions & 8 deletions Sources/LLVM/BasicBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,11 @@ public struct BasicBlock: IRValue {
}
}

/// 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 instructions that reference
/// this basic block before deleting it.
public func delete() {
LLVMDeleteBasicBlock(llvm)
}

/// Removes this basic block from a function but keeps it alive.
///
/// - note: To ensure correct removal of the block, you must invalidate any
/// references to it and its child instructions. The block must also
/// have no successor blocks that make reference to it.
public func removeFromParent() {
LLVMRemoveBasicBlockFromParent(llvm)
}
Expand All @@ -87,6 +83,18 @@ public struct BasicBlock: IRValue {
}
}

extension BasicBlock {
/// 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 instructions that reference
/// this basic block before deleting it.
@available(*, deprecated, message: "it is hard to use correctly and will be removed. See BasicBlock.removeFromParent() instead")
public func delete() {
LLVMDeleteBasicBlock(llvm)
}

}

extension BasicBlock {
/// An `Address` represents a function-relative address of a basic block for
/// use with the `indirectbr` instruction.
Expand Down