[Mlir-commits] [mlir] [mlir] Apply rule of five for Pass / OperationPass (PR #80998)
Markus Böck
llvmlistbot at llvm.org
Wed Feb 7 09:59:07 PST 2024
================
@@ -161,6 +161,13 @@ class Pass {
explicit Pass(TypeID passID, std::optional<StringRef> opName = std::nullopt)
: passID(passID), opName(opName) {}
Pass(const Pass &other) : Pass(other.passID, other.opName) {}
+ Pass &operator=(const Pass &other) {
+ this->passID = other.passID;
+ this->opName = other.opName;
+ return *this;
+ }
+ Pass(Pass &&) = delete;
----------------
zero9178 wrote:
By calling the copy constructor from the move constructor the "moved-from object is in valid but unspecified state" post-condition is upheld since not moving the object but just copying its fields (as the copy constructor does), leaves them in a valid state (the same state as before). Note that this is also only just a convention as to how move constructors should be implemented (if implemented) and not part of the semantics of the core language (just some STL types).
Note that what I suggested would do a partial-copy when using `std::move`, which should be fine as you said, and does not do a partial-move of the fields.
https://github.com/llvm/llvm-project/pull/80998
More information about the Mlir-commits
mailing list