[Mlir-commits] [mlir] [mlir][IR] Insert operations before `SingleBlock`'s terminator (PR #65959)
Mehdi Amini
llvmlistbot at llvm.org
Sat Sep 16 20:17:09 PDT 2023
================
@@ -236,10 +236,15 @@ void Block::eraseArguments(function_ref<bool(BlockArgument)> shouldEraseFn) {
/// Get the terminator operation of this block. This function asserts that
/// the block has a valid terminator operation.
Operation *Block::getTerminator() {
- assert(!empty() && back().mightHaveTrait<OpTrait::IsTerminator>());
+ assert(hasTerminator());
return &back();
}
+/// Check whether this block has a terminator.
+bool Block::hasTerminator() {
+ return !empty() && back().mightHaveTrait<OpTrait::IsTerminator>();
+}
----------------
joker-eph wrote:
The API is misnamed: this should be "mightHaveTerminator", as the trait check indicates.
https://github.com/llvm/llvm-project/pull/65959
More information about the Mlir-commits
mailing list