forked from OSchip/llvm-project
NFC: Simplify ModuleTerminatorOp by using the HasParent trait.
PiperOrigin-RevId: 261962104
This commit is contained in:
parent
55f2e24ab3
commit
8920afb0a6
|
@ -107,13 +107,11 @@ public:
|
|||
/// the terminator in their custom syntax for brevity.
|
||||
class ModuleTerminatorOp
|
||||
: public Op<ModuleTerminatorOp, OpTrait::ZeroOperands, OpTrait::ZeroResult,
|
||||
OpTrait::IsTerminator> {
|
||||
OpTrait::HasParent<ModuleOp>::Impl, OpTrait::IsTerminator> {
|
||||
public:
|
||||
using Op::Op;
|
||||
static StringRef getOperationName() { return "module_terminator"; }
|
||||
|
||||
static void build(Builder *, OperationState *) {}
|
||||
LogicalResult verify();
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -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<ModuleOp>(getOperation()->getParentOp()))
|
||||
return emitOpError() << "is expected to terminate a '"
|
||||
<< ModuleOp::getOperationName() << "' operation";
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -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"() : () -> ()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue