From: River Riddle Date: Tue, 6 Aug 2019 18:46:01 +0000 (-0700) Subject: NFC: Simplify ModuleTerminatorOp by using the HasParent trait. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8920afb0a636e5477ef7f4ffacd6c1137e30a84a;p=platform%2Fupstream%2Fllvm.git NFC: Simplify ModuleTerminatorOp by using the HasParent trait. PiperOrigin-RevId: 261962104 --- diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 0bdd5f2..147337f 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -107,13 +107,11 @@ public: /// the terminator in their custom syntax for brevity. class ModuleTerminatorOp : public Op { + OpTrait::HasParent::Impl, OpTrait::IsTerminator> { public: using Op::Op; static StringRef getOperationName() { return "module_terminator"; } - static void build(Builder *, OperationState *) {} - LogicalResult verify(); }; //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp index 73510a1..b1c56c2 100644 --- a/mlir/lib/IR/Module.cpp +++ b/mlir/lib/IR/Module.cpp @@ -86,14 +86,3 @@ LogicalResult ModuleOp::verify() { /// Return body of this module. Region &ModuleOp::getBodyRegion() { return getOperation()->getRegion(0); } Block *ModuleOp::getBody() { return &getBodyRegion().front(); } - -//===----------------------------------------------------------------------===// -// Module Terminator Operation. -//===----------------------------------------------------------------------===// - -LogicalResult ModuleTerminatorOp::verify() { - if (!isa_and_nonnull(getOperation()->getParentOp())) - return emitOpError() << "is expected to terminate a '" - << ModuleOp::getOperationName() << "' operation"; - return success(); -} diff --git a/mlir/test/IR/invalid-module-op.mlir b/mlir/test/IR/invalid-module-op.mlir index 02ebe92..56cea78 100644 --- a/mlir/test/IR/invalid-module-op.mlir +++ b/mlir/test/IR/invalid-module-op.mlir @@ -38,6 +38,6 @@ func @module_op() { // ----- func @module_op() { - // expected-error@+1 {{is expected to terminate a 'module' operation}} + // expected-error@+1 {{expects parent op 'module'}} "module_terminator"() : () -> () }