In the trait verifier of SingleBlockImplicitTerminator, report the name of the
unexpected terminator op found in the end of the block in addition to the name
of the expected terminator op. This may simplify debugging, especially in
cases where the terminator is omitted for brevity and/or after a long series of
conversions.
PiperOrigin-RevId:
259287452
Block &block = region.front();
if (block.empty())
return failure();
- if (isa<TerminatorOpType>(block.back()))
+ Operation &terminator = block.back();
+ if (isa<TerminatorOpType>(terminator))
continue;
return op->emitOpError("expects regions to end with '" +
- TerminatorOpType::getOperationName() + "'")
+ TerminatorOpType::getOperationName() +
+ "', found '" +
+ terminator.getName().getStringRef() + "'")
.attachNote()
<< "in custom textual format, the absence of terminator implies "
"'"
func @return_inside_loop() {
affine.for %i = 1 to 100 {
- // expected-error@-1 {{op expects regions to end with 'affine.terminator'}}
+ // expected-error@-1 {{op expects regions to end with 'affine.terminator', found 'std.return'}}
// expected-note@-2 {{in custom textual format, the absence of terminator implies}}
return
}