diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1779,7 +1779,17 @@ static AbstractOperation::VerifyInvariantsFn getVerifyInvariantsFn() { return &verifyInvariants; } + + static constexpr bool hasNoDataMembers() { + // Checking that the derived class does not define any member by comparing + // its size to an ad-hoc EmptyOp. + class EmptyOp : public Op {}; + return sizeof(ConcreteType) == sizeof(EmptyOp); + } + static LogicalResult verifyInvariants(Operation *op) { + static_assert(hasNoDataMembers(), + "Op class shouldn't define new data members"); return failure( failed(op_definition_impl::verifyTraits(op)) || failed(cast(op).verify()));