From 6fabf75051c6ec1fd7bf7b61987cc4e72bf650e3 Mon Sep 17 00:00:00 2001 From: Tatiana Shpeisman Date: Thu, 16 Aug 2018 20:19:44 -0700 Subject: [PATCH] Rephrasing last statement invariant check in ReturnOp::verify() to be more elegant. PiperOrigin-RevId: 209094070 --- mlir/lib/IR/StandardOps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir/lib/IR/StandardOps.cpp b/mlir/lib/IR/StandardOps.cpp index 5bfa2d3251e6..723dcc234348 100644 --- a/mlir/lib/IR/StandardOps.cpp +++ b/mlir/lib/IR/StandardOps.cpp @@ -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(getOperation())) { - MLFunction *func = dyn_cast_or_null(stmt->getBlock()); - if (!func || &func->back() != stmt) + StmtBlock *block = stmt->getBlock(); + if (!block || !isa(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