[PATCH] D125994: [NFC] Define move and copy constructors and copy assignment operators for MDOperand.

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 12:52:00 PDT 2022


dexonsmith added a comment.

Can you add a unit test for this? Ideally something that could expose errors if the tracking logic isn’t right, so probably a TempMDTuple or something assigned/moved between operands.



================
Comment at: llvm/include/llvm/IR/Metadata.h:778
   MDOperand() = default;
-  MDOperand(MDOperand &&) = delete;
-  MDOperand(const MDOperand &) = delete;
-  MDOperand &operator=(MDOperand &&) = delete;
-  MDOperand &operator=(const MDOperand &) = delete;
+  MDOperand(const MDOperand &&Op) {
+    MD = Op.MD;
----------------
There shouldn’t be a `const` here, and `Op` should probably be reset. Is there a `retrack()` function for that operation?


================
Comment at: llvm/include/llvm/IR/Metadata.h:782
+  }
+  MDOperand(const MDOperand &Op) {
+    MD = Op.MD;
----------------
I don’t think we need this and it seems better to error here. I think we should keep the copy constructor/operator deleted and make this move-only.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125994/new/

https://reviews.llvm.org/D125994



More information about the llvm-commits mailing list