Rephrasing last statement invariant check in ReturnOp::verify() to be more

elegant.

PiperOrigin-RevId: 209094070
This commit is contained in:
Tatiana Shpeisman 2018-08-16 20:19:44 -07:00 committed by jpienaar
parent ec1cfe2268
commit 6fabf75051
1 changed files with 2 additions and 2 deletions

View File

@ -438,8 +438,8 @@ void ReturnOp::print(OpAsmPrinter *p) const {
const char *ReturnOp::verify() const {
// ReturnOp must be part of an ML function.
if (auto *stmt = dyn_cast<OperationStmt>(getOperation())) {
MLFunction *func = dyn_cast_or_null<MLFunction>(stmt->getBlock());
if (!func || &func->back() != stmt)
StmtBlock *block = stmt->getBlock();
if (!block || !isa<MLFunction>(block) || &block->back() != stmt)
return "must be the last statement in the ML function";
// Return success. Checking that operand types match those in the function