Skip to content

Commit c1b02a1

Browse files
joker-ephjpienaar
authored andcommitted
Add an assertion on the builder to ensure that a block is set before creating an operation
This is more friendly for the user than a raw segfault PiperOrigin-RevId: 236504102
1 parent eeeef09 commit c1b02a1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mlir/lib/IR/Builders.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ Block *FuncBuilder::createBlock(Block *insertBefore) {
310310

311311
/// Create an operation given the fields represented as an OperationState.
312312
Instruction *FuncBuilder::createOperation(const OperationState &state) {
313+
assert(block && "createOperation() called without setting builder's block");
313314
auto *op = Instruction::create(state.location, state.name, state.operands,
314315
state.types, state.attributes,
315316
state.successors, state.numBlockLists,

0 commit comments

Comments
 (0)