[Mlir-commits] [mlir] [mlir] Apply rule of five for Pass / OperationPass (PR #80998)
Andrei Golubev
llvmlistbot at llvm.org
Thu Feb 8 05:20:59 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:
on further investigation it turns out there's a bunch of not-really-movable members there. also, note that the copy-ctor is *protected*. additionally, there's a [`clone()` method](https://github.com/llvm/llvm-project/blob/ec1fcb381d884ca53e2e0dd4075f946c8f002de2/mlir/include/mlir/Pass/Pass.h#L200) that returns a `unique_ptr`. so, I guess, the expected semantics of the class is to always wrap it into a smart pointer.
thus, i propose we mark all of the special member functions deleted except for the copy-ctor which seems to be used by the clone functionality and call it a day.
https://github.com/llvm/llvm-project/pull/80998
More information about the Mlir-commits
mailing list