[Mlir-commits] [mlir] [mlir] Apply rule of five for Pass / OperationPass (PR #80998)
Andrei Golubev
llvmlistbot at llvm.org
Thu Feb 8 00:44:44 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;
----------------
andrey-golubev wrote:
> 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).
yes, but I'm not sure whether the compiler would (should) see it: I guess by design the moved-from object can only be assigned-to or deleted. so even though we see that move == copy, it doesn't mean that the compiler has to adhere to this? (all it knows about is "there's a move construction / move assignment operation happening") - maybe inlined code is special though.
(also, i'm pretty sure some static analyzer would come around and say what we do is bad, lol.)
> Note that what I suggested would do a partial-copy when using std::move
I guess this would still work through the copy-ctor? `Pass pseudoMove(std::move(other)); // calls copy-ctor when move-ctor is deleted`?
Anyhow, let me ponder on this for a bit, perhaps there's a nice way forward.
https://github.com/llvm/llvm-project/pull/80998
More information about the Mlir-commits
mailing list