Skip to content

Commit f9a93d3

Browse files
[mlir] Apply rule of five for Pass / OperationPass
Define all special member functions of C++ types (mlir::Pass and mlir::OperationPass) since one of them is already provided. As part of this, enable move semantics for these types as it probably makes sense since copy semantics is present. Co-authored-by: Asya Pronina <[email protected]>
1 parent d42f395 commit f9a93d3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mlir/include/mlir/Pass/Pass.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ class Pass {
161161
explicit Pass(TypeID passID, std::optional<StringRef> opName = std::nullopt)
162162
: passID(passID), opName(opName) {}
163163
Pass(const Pass &other) : Pass(other.passID, other.opName) {}
164+
Pass &operator=(const Pass &other) {
165+
this->passID = other.passID;
166+
this->opName = other.opName;
167+
return *this;
168+
}
169+
Pass(Pass &&) = default;
170+
Pass &operator=(Pass &&) = default;
164171

165172
/// Returns the current pass state.
166173
detail::PassExecutionState &getPassState() {
@@ -352,6 +359,9 @@ class OperationPass : public Pass {
352359
protected:
353360
OperationPass(TypeID passID) : Pass(passID, OpT::getOperationName()) {}
354361
OperationPass(const OperationPass &) = default;
362+
OperationPass &operator=(const OperationPass &) = default;
363+
OperationPass(OperationPass &&) = default;
364+
OperationPass &operator=(OperationPass &&) = default;
355365

356366
/// Support isa/dyn_cast functionality.
357367
static bool classof(const Pass *pass) {
@@ -391,6 +401,9 @@ class OperationPass<void> : public Pass {
391401
protected:
392402
OperationPass(TypeID passID) : Pass(passID) {}
393403
OperationPass(const OperationPass &) = default;
404+
OperationPass &operator=(const OperationPass &) = default;
405+
OperationPass(OperationPass &&) = default;
406+
OperationPass &operator=(OperationPass &&) = default;
394407

395408
/// Indicate if the current pass can be scheduled on the given operation type.
396409
/// By default, generic operation passes can be scheduled on any operation.

0 commit comments

Comments
 (0)