[PATCH] D125994: [NFC] Define move and copy constructors and copy assignment operators for MDOperand.
Wolfgang Pieb via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 21 13:15:31 PDT 2022
wolfgangp updated this revision to Diff 431173.
wolfgangp added a comment.
Only define the move constructor and move assignment operator. Use retrack() instead of relying on the destructor to untrack the source op.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125994/new/
https://reviews.llvm.org/D125994
Files:
llvm/include/llvm/IR/Metadata.h
Index: llvm/include/llvm/IR/Metadata.h
===================================================================
--- llvm/include/llvm/IR/Metadata.h
+++ llvm/include/llvm/IR/Metadata.h
@@ -775,10 +775,21 @@
public:
MDOperand() = default;
- MDOperand(MDOperand &&) = delete;
MDOperand(const MDOperand &) = delete;
- MDOperand &operator=(MDOperand &&) = delete;
+ MDOperand(MDOperand &&Op) {
+ MD = Op.MD;
+ if (MD)
+ (void)MetadataTracking::retrack(Op.MD, MD);
+ Op.MD = nullptr;
+ }
MDOperand &operator=(const MDOperand &) = delete;
+ MDOperand &operator=(MDOperand &&Op) {
+ MD = Op.MD;
+ if (MD)
+ (void)MetadataTracking::retrack(Op.MD, MD);
+ Op.MD = nullptr;
+ return *this;
+ }
~MDOperand() { untrack(); }
Metadata *get() const { return MD; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125994.431173.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220521/7aac6849/attachment.bin>
More information about the llvm-commits
mailing list